From 9136ed6c6f811d2c6dfe977989d5ff8c41f28a30 Mon Sep 17 00:00:00 2001 From: Jesus Alvarez Date: Mon, 4 Sep 2017 15:22:57 -0700 Subject: [PATCH] Minor syntax cleanups for PKGBUILD output --- build.sh | 37 ++++++++++++++++++++++++------------- lib.sh | 13 ++++++++++--- repo.sh | 8 ++++---- src/spl-utils/PKGBUILD.sh | 2 +- src/spl/PKGBUILD.sh | 10 +++++----- src/zfs-dkms/PKGBUILD.sh | 2 +- src/zfs-utils/PKGBUILD.sh | 2 +- src/zfs/PKGBUILD.sh | 2 +- 8 files changed, 47 insertions(+), 29 deletions(-) diff --git a/build.sh b/build.sh index 40dafe1..eb400ba 100755 --- a/build.sh +++ b/build.sh @@ -199,34 +199,45 @@ generate_package_files() { build_packages() { for pkg in "${pkg_list[@]}"; do - # get version of any package that has been build previously + # get version of any package that has been built previously run_cmd_show_and_capture_output "ls \"${script_dir}/packages/${kernel_name}/${pkg}/\"${pkg}*.pkg.tar.xz | grep \"$pkg\" | grep -v \"headers\" | tail -1" pkg_path=${run_cmd_output} - vers=$(package_version_from_path ${pkg_path}) - - # get current version - eval $(source "${script_dir}/packages/${kernel_name}/${pkg}/PKGBUILD"; - echo current_vers="${pkgver}"; - echo current_rel="${pkgrel}"; - ) - # stop if version has already been build - if [[ ${run_cmd_return} -eq 0 && ${vers} = ${current_vers}-${current_rel} ]]; then - msg "${pkg}=${vers} has already been build, skipping" - continue + + if [[ ${pkg_path} == "" ]]; then + msg2 "No previously built packages exist for ${pkg}!" + else + vers=$(package_version_from_path ${pkg_path}) + + # get current version + eval $(source "${script_dir}/packages/${kernel_name}/${pkg}/PKGBUILD"; + echo current_vers="${pkgver}"; + echo current_rel="${pkgrel}"; + ) + + # stop if version has already been built + if [[ ${run_cmd_return} -eq 0 && ${vers} == ${current_vers}-${current_rel} ]]; then + msg "${pkg}=${vers} has already been built, skipping" + continue + fi + fi msg "Building ${pkg}..." + + # Cleanup all previously built packages for the current package cleanup ${pkg} + run_cmd "cd \"${script_dir}/packages/${kernel_name}/${pkg}\" && ccm64 s && mksrcinfo" if [[ ${run_cmd_return} -ne 0 ]]; then error "A problem occurred building the package" exit 1 fi - # if [[ "${pkg}" == "zfs-utils-common" ]]; then + # if [[ "${pkg}" == "spl-linux-hardened-git" ]]; then # msg2 "${pkg} package files:" # run_cmd "tree ${chroot_path}/build/${pkg}/pkg" # exit # fi + exit 1 done run_cmd "find . -iname \"*.log\" -print -exec rm {} \\;" } diff --git a/lib.sh b/lib.sh index 759c789..c83e36a 100644 --- a/lib.sh +++ b/lib.sh @@ -372,9 +372,15 @@ kernel_version_full() { local arg=$1 if ! kernel_version_has_minor_version $1; then debug "kernel_version_full: Have kernel without minor version!" - # Kernel version has the format 3.14, so add a 0. - local arg=$(echo ${arg} | cut -f1 -d-) - local rev=$(echo ${1} | cut -f2 -d-) + if [[ ${1} =~ ^([[:digit:]]+\.[[:digit:]]+)\.?([[:alpha:][:digit:]]+)?\-([[:digit:]]+) ]]; then + local arg=${BASH_REMATCH[1]} + local minor=${BASH_REMATCH[2]} + local rev=${BASH_REMATCH[3]} + if [[ ${minor} =~ ^[[:alpha:]]+ ]]; then + printf "${arg}.0.${minor}-${rev}" + return 0 + fi + fi printf "${arg}.0-${rev}" return 0 fi @@ -755,6 +761,7 @@ pkgbuild_cleanup() { sed -i '/^\s*$/d' $1 sed -i 's/"\ )$/")/g' $1 # Readd blanklines above build and package + sed -i '/^pkgver\(\)/{x;p;x;}' $1 sed -i '/^build\(\)/{x;p;x;}' $1 sed -i '/^package\(\)/{x;p;x;}' $1 } diff --git a/repo.sh b/repo.sh index 7bbdca0..a68995b 100755 --- a/repo.sh +++ b/repo.sh @@ -186,7 +186,7 @@ repo_package_list() { repo_package_backup() { msg "Getting a list of packages to backup..." - + local pkgs=() for ipkg in ${package_list[@]}; do IFS=';' read -a pkgopt <<< "${ipkg}" @@ -195,16 +195,16 @@ repo_package_backup() { vers="${pkgopt[1]}" pkgp="${pkgopt[2]}" dest="${pkgopt[3]}" - + debug "pkg: ${name}" local o="" if [[ ${#pkgs[@]} -ne 0 ]]; then local o="-o" fi - + pkgs+=("$o -regextype egrep -regex '.*${name}-[a-z0-9\.\_]+-[0-9]+-x86_64.pkg.tar.xz'") done - + # only run find, if new packages will be copied if [[ ! ${#pkgs[@]} -eq 0 ]]; then run_cmd_show_and_capture_output_no_dry_run "find ${repo_target} -type f ${pkgs[@]}" diff --git a/src/spl-utils/PKGBUILD.sh b/src/spl-utils/PKGBUILD.sh index 259cebc..4fe51d2 100755 --- a/src/spl-utils/PKGBUILD.sh +++ b/src/spl-utils/PKGBUILD.sh @@ -31,7 +31,7 @@ package() { EOF if [[ ${archzfs_package_group} =~ -git$ ]]; then - sed -i "/^build()/ i pkgver() { \n cd \"${spl_workdir}\" \n git describe --long | sed 's/^spl-//;s/\\\([^-]*-g\\\)/r\\\1/;s/-/./g' \n}" ${spl_utils_pkgbuild_path}/PKGBUILD + sed -i "/^build()/i pkgver() { cd \"${spl_workdir}\"\n git describe --long | sed 's/^spl-//;s/\\\([^-]*-g\\\)/r\\\1/;s/-/./g'\n}" ${spl_utils_pkgbuild_path}/PKGBUILD fi pkgbuild_cleanup "${spl_utils_pkgbuild_path}/PKGBUILD" diff --git a/src/spl/PKGBUILD.sh b/src/spl/PKGBUILD.sh index 516aa0e..fb5b4be 100755 --- a/src/spl/PKGBUILD.sh +++ b/src/spl/PKGBUILD.sh @@ -31,11 +31,11 @@ package_${spl_pkgname}() { groups=("${archzfs_package_group}") conflicts=(${spl_conflicts}) ${spl_replaces} - + cd "${spl_workdir}" make DESTDIR="\${pkgdir}" install mv "\${pkgdir}/lib" "\${pkgdir}/usr/" - + # Remove src dir rm -r "\${pkgdir}"/usr/src } @@ -43,11 +43,11 @@ package_${spl_pkgname}() { package_${spl_pkgname}-headers() { pkgdesc="Solaris Porting Layer kernel headers." conflicts=(${spl_headers_conflicts}) - + cd "${spl_workdir}" make DESTDIR="\${pkgdir}" install rm -r "\${pkgdir}/lib" - + # Remove reference to \${srcdir} sed -i "s+\${srcdir}++" \${pkgdir}/usr/src/spl-*/${kernel_mod_path}/Module.symvers } @@ -55,7 +55,7 @@ package_${spl_pkgname}-headers() { EOF if [[ ${archzfs_package_group} =~ -git$ ]]; then - sed -i "/^build()/ i pkgver() { \n cd \"${spl_workdir}\" \n echo \$(git describe --long | sed 's/^spl-//;s/\\\([^-]*-g\\\)/r\\\1/;s/-/./g').${kernel_version_full_pkgver} \n}" ${spl_pkgbuild_path}/PKGBUILD + sed -i "/^build()/i pkgver() {\n cd \"${spl_workdir}\"\n echo \$(git describe --long | sed 's/^spl-//;s/\\\([^-]*-g\\\)/r\\\1/;s/-/./g').${kernel_version_full_pkgver}\n}" ${spl_pkgbuild_path}/PKGBUILD fi pkgbuild_cleanup "${spl_pkgbuild_path}/PKGBUILD" diff --git a/src/zfs-dkms/PKGBUILD.sh b/src/zfs-dkms/PKGBUILD.sh index d98bb7b..9bcb128 100755 --- a/src/zfs-dkms/PKGBUILD.sh +++ b/src/zfs-dkms/PKGBUILD.sh @@ -46,7 +46,7 @@ package() { EOF if [[ ${archzfs_package_group} =~ -git$ ]]; then - sed -i "/^build()/ i pkgver() { \n cd \"${zfs_workdir}\" \n git describe --long | sed 's/^zfs-//;s/\\\([^-]*-g\\\)/r\\\1/;s/-/./g' \n}" ${zfs_dkms_pkgbuild_path}/PKGBUILD + sed -i "/^build()/i pkgver() {\n cd \"${zfs_workdir}\"\n git describe --long | sed 's/^zfs-//;s/\\\([^-]*-g\\\)/r\\\1/;s/-/./g'\n}" ${zfs_dkms_pkgbuild_path}/PKGBUILD fi pkgbuild_cleanup "${zfs_dkms_pkgbuild_path}/PKGBUILD" diff --git a/src/zfs-utils/PKGBUILD.sh b/src/zfs-utils/PKGBUILD.sh index 97bca1b..8db7d64 100755 --- a/src/zfs-utils/PKGBUILD.sh +++ b/src/zfs-utils/PKGBUILD.sh @@ -59,7 +59,7 @@ package() { EOF if [[ ${archzfs_package_group} =~ -git$ ]]; then - sed -i "/^build()/ i pkgver() { \n cd \"${zfs_workdir}\" \n git describe --long | sed 's/^zfs-//;s/\\\([^-]*-g\\\)/r\\\1/;s/-/./g' \n}" ${zfs_utils_pkgbuild_path}/PKGBUILD + sed -i "/^build()/i pkgver() {\n cd \"${zfs_workdir}\"\n git describe --long | sed 's/^zfs-//;s/\\\([^-]*-g\\\)/r\\\1/;s/-/./g'\n}" ${zfs_utils_pkgbuild_path}/PKGBUILD fi pkgbuild_cleanup "${zfs_utils_pkgbuild_path}/PKGBUILD" diff --git a/src/zfs/PKGBUILD.sh b/src/zfs/PKGBUILD.sh index db50b6c..48f8821 100755 --- a/src/zfs/PKGBUILD.sh +++ b/src/zfs/PKGBUILD.sh @@ -57,7 +57,7 @@ package_${zfs_pkgname}-headers() { EOF if [[ ${archzfs_package_group} =~ -git$ ]]; then - sed -i "/^build()/ i pkgver() { \n cd \"${zfs_workdir}\" \n echo \$(git describe --long | sed 's/^zfs-//;s/\\\([^-]*-g\\\)/r\\\1/;s/-/./g').${kernel_version_full_pkgver} \n}" ${zfs_pkgbuild_path}/PKGBUILD + sed -i "/^build()/i pkgver() {\n cd \"${zfs_workdir}\"\n echo \$(git describe --long | sed 's/^zfs-//;s/\\\([^-]*-g\\\)/r\\\1/;s/-/./g').${kernel_version_full_pkgver}\n}" ${zfs_pkgbuild_path}/PKGBUILD fi pkgbuild_cleanup "${zfs_pkgbuild_path}/PKGBUILD"