From f77fb50896071ae7a90b146600319134d39fc9d7 Mon Sep 17 00:00:00 2001 From: Jesus Alvarez Date: Mon, 28 Aug 2017 12:17:23 -0700 Subject: [PATCH] Minor improvements in build scripts Still working on fixing old package archiving... --- build.sh | 22 +++++++++++++------ lib.sh | 8 +++---- push.sh | 8 +------ repo.sh | 67 ++++++++++++++++++++++++++++++++++++++++---------------- 4 files changed, 68 insertions(+), 37 deletions(-) diff --git a/build.sh b/build.sh index bc28b4b..40dafe1 100755 --- a/build.sh +++ b/build.sh @@ -66,6 +66,16 @@ usage() { } +cleanup() { + # $1: the package name + msg "Cleaning up work files..." + fincs='-iname "*.log" -o -iname "*.pkg.tar.xz*" -o -iname "*.src.tar.gz"' + run_cmd "find ${script_dir}/packages/${kernel_name}/$1 \( ${fincs} \) -print -exec rm -rf {} \\;" + run_cmd "rm -rf */src" + run_cmd "rm -rf */*.tar.gz" +} + + build_sources() { for pkg in "${pkg_list[@]}"; do msg "Building source for ${pkg}"; @@ -74,6 +84,7 @@ build_sources() { done } + generate_package_files() { debug "kernel_version_full: ${kernel_version_full}" debug "kernel_mod_path: ${kernel_mod_path}" @@ -152,7 +163,7 @@ generate_package_files() { msg2 "Creating zfs.install" run_cmd_no_output "source ${script_dir}/src/zfs/zfs.install.sh" fi - + if [[ ! -z ${zfs_dkms_pkgbuild_path} ]]; then msg2 "Creating spl-dkms PKGBUILD" run_cmd_no_output "source ${script_dir}/src/spl-dkms/PKGBUILD.sh" @@ -205,6 +216,7 @@ build_packages() { fi msg "Building ${pkg}..." + 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" @@ -293,12 +305,8 @@ source_safe "src/kernels/${kernel_name}.sh" if have_command "cleanup"; then - msg "Cleaning up work files..." - fincs='-iname "*.log" -o -iname "*.pkg.tar.xz*" -o -iname "*.src.tar.gz"' - run_cmd "find ${script_dir}/packages/${kernel_name}/ \( ${fincs} \) -print -exec rm -rf {} \\;" - run_cmd "rm -rf */src" - run_cmd "rm -rf */*.tar.gz" - exit + cleanup + # exit fi diff --git a/lib.sh b/lib.sh index 70ff1d7..759c789 100644 --- a/lib.sh +++ b/lib.sh @@ -386,7 +386,7 @@ kernel_version_full() { kernel_version_full_no_hyphen() { # $1: The full kernel version # returns: output is printed to stdout - echo $(kernel_version_full ${1} | sed s/-/_/g) + echo $(kernel_version_full ${1} | sed s/-/./g) } # from makepkg @@ -822,7 +822,7 @@ git_calc_pkgver() { # Get the version number past the last tag msg2 "Calculating PKGVER" cmd="cd temp/${repo} && " - cmd+="echo \$(git describe --long | sed -r 's/^${repo}-//;s/([^-]*-g)/r\1/;s/-/_/g')" + cmd+="echo \$(git describe --long | sed -r 's/^${repo}-//;s/([^-]*-g)/r\1/;s/-/./g')" run_cmd_no_output_no_dry_run "${cmd}" @@ -830,7 +830,7 @@ git_calc_pkgver() { spl_git_ver=${run_cmd_output} # append kernel version if set if [ ! -z "${kernvers}" ]; then - spl_pkgver=${spl_git_ver}_${kernvers}; + spl_pkgver=${spl_git_ver}.${kernvers}; else spl_pkgver=${spl_git_ver}; fi @@ -839,7 +839,7 @@ git_calc_pkgver() { zfs_git_ver=${run_cmd_output} # append kernel version if set if [ ! -z "${kernvers}" ]; then - zfs_pkgver=${zfs_git_ver}_${kernvers}; + zfs_pkgver=${zfs_git_ver}.${kernvers}; else zfs_pkgver=${zfs_git_ver}; fi diff --git a/push.sh b/push.sh index eb441ff..caeabaa 100755 --- a/push.sh +++ b/push.sh @@ -140,15 +140,9 @@ debug_print_default_vars export script_dir mode kernel_name source_safe "src/kernels/${kernel_name}.sh" + for func in "${update_funcs[@]}"; do debug "Evaluating '${func}'" "${func}" push_packages done - - -# Build the documentation and push it to the remote host -# msg "Building the documentation..." -# rst2html2 web_archzfs.rst > /tmp/archzfs_index.html -# msg2 "Pushing the documentation to the remote host..." -# scp /tmp/archzfs_index.html $REMOTE_LOGIN:webapps/default/archzfs/index.html diff --git a/repo.sh b/repo.sh index c9111f1..ef20c73 100755 --- a/repo.sh +++ b/repo.sh @@ -111,11 +111,34 @@ repo_package_list() { # Get packages from the backup directory path="packages/${kernel_name}/{$(printf '%s,' ${pkg_list[@]} | cut -d ',' -f 1-${#pkg_list[@]})}/" - fcmd="find ${path} -iname '*${kernel_version_full_pkgver}-${spl_pkgrel}*.pkg.tar.xz' -o -iname '*${kernel_version_full_pkgver}-${zfs_pkgrel}*.pkg.tar.xz' " - run_cmd_show_and_capture_output_no_dry_run "${fcmd}" - for pkg in ${run_cmd_output}; do - pkgs+=(${pkg}) - done + if [[ ! -z ${kernel_version_full_pkgver} ]]; then + debug "kernel_version_full_pkgver: ${kernel_version_full_pkgver}" + fcmd="find ${path} -iname '*${kernel_version_full_pkgver}-${spl_pkgrel}*.pkg.tar.xz' -o -iname '*${kernel_version_full_pkgver}-${zfs_pkgrel}*.pkg.tar.xz' " + run_cmd_no_output_no_dry_run "${fcmd}" + for pkg in ${run_cmd_output}; do + pkgs+=(${pkg}) + done + elif [[ ! -z ${spl_pkgver} ]] && [[ ! -z ${zfs_pkgver} ]]; then + debug "spl_pkgver: ${spl_pkgver}" + fcmd="find ${path} -iname '*${spl_pkgver}-${spl_pkgrel}*.pkg.tar.xz' -o -iname '*${zfs_pkgver}-${zfs_pkgrel}*.pkg.tar.xz' " + run_cmd_no_output_no_dry_run "${fcmd}" + for pkg in ${run_cmd_output}; do + pkgs+=(${pkg}) + done + else + debug "kernel_version_full_pkgver and spl_pkgver (and zfs_pkgver) not set!" + debug "Falling back to newest package by mod time for zfs and spl" + for z in $(printf '%s ' ${pkg_list[@]} ); do + # fcmd="find ${path} -iname '*${kernel_name}*-${spl_pkgrel}*.pkg.tar.xz' -o -iname '*${zfs_pkgver}-${zfs_pkgrel}*.pkg.tar.xz' " + fcmd="find packages/${kernel_name} -iname '*${z}*.pkg.tar.xz' -printf '%T@ %p\\n' | sort -n | tail -1 | cut -f2- -d' '" + run_cmd_no_output_no_dry_run "${fcmd}" + for pkg in ${run_cmd_output}; do + pkgs+=(${pkg}) + done + done + fi + + debug_print_array "pkgs" ${pkgs[@]} for pkg in ${pkgs[@]}; do arch=$(package_arch_from_path ${pkg}) @@ -159,33 +182,39 @@ repo_package_backup() { msg "Getting a list of packages to backup..." local pkgs=() for pkg in ${pkg_list[@]}; do + debug "pkg: ${pkg}" local o="" if [[ ${#pkgs[@]} -ne 0 ]]; then local o="-o" fi - pkgs+=("${o} -iname '*${pkg}-[0-9]*.pkg.tar.xz'") + if [[ ${pkg} =~ .*-git$ ]]; then + pkgs+=("${o} -iname '*git*' -regextype egrep -regex '.*${pkg}-(headers-)*[a-z0-9\.\_\-]+-x86_64.pkg.tar.xz'") + elif [[ ${pkg} =~ .*-hardened$ ]]; then + pkgs+=("${o} -not -iname '*git*' -regextype egrep -regex '.*${pkg}-(headers-)*[a-z0-9\.\_\-]+-x86_64.pkg.tar.xz'") + else + pkgs+=("${o} -not -iname '*git*' -regextype egrep -regex '.*${pkg}-(headers-)*[0-9\.\_\-]+-x86_64.pkg.tar.xz'") + fi done - run_cmd_show_and_capture_output_no_dry_run "find ${repo_target} -type f ${pkgs[@]}" + + run_cmd_show_and_capture_output_no_dry_run "find ${repo_target} -type f -iname '*git*' ${pkgs[@]}" + for x in ${run_cmd_output}; do - ename=$(package_name_from_path ${x}) - evers=$(package_version_from_path ${x}) - debug "repo_package_backup: evers: ${evers}" - debug "repo_package_backup: kernel_vers: ${kernel_version_full_pkgver}" - # Ignore current packages if they exist - if [[ ${evers} == *"${kernel_version_full_pkgver}-${spl_pkgrel}"* ]] || \ - [[ ${evers} == *"${kernel_version_full_pkgver}-${zfs_pkgrel}"* ]]; then - debug "repo_package_backup: Ignoring package '${x}'" - continue - fi + debug "Evaluating ${x}" + pkgname=$(package_name_from_path ${x}) + pkgvers=$(package_version_from_path ${x}) + debug "pkgname: ${pkgname}" + debug "pkgvers: ${pkgvers}" # asterisk globs the package signature - epkg="${repo_target}/x86_64/${ename}-${evers}*" - debug "repo_package_backup epkg: ${epkg}" + epkg="${repo_target}/x86_64/${pkgname}-${pkgvers}*" + debug "backing up package: ${epkg}" package_exist_list+=("${epkg}") done + if [[ ${#package_exist_list[@]} -eq 0 ]]; then msg2 "No packages found for backup." return fi + debug_print_array "package_exist_list" "${package_exist_list[@]}" msg "Backing up existing packages..." run_cmd "mv ${package_exist_list[@]} ${package_backup_dir}/"