diff --git a/build.sh b/build.sh index 372931d..50c45d2 100755 --- a/build.sh +++ b/build.sh @@ -132,9 +132,6 @@ generate_package_files() { run_cmd_no_output "cp ${script_dir}/src/zfs-utils/zfs-utils.initcpio.hook ${zfs_utils_pkgbuild_path}/zfs-utils.initcpio.hook" msg2 "Copying zfs-utils.initcpio.install" run_cmd_no_output "cp ${script_dir}/src/zfs-utils/zfs-utils.initcpio.install ${zfs_utils_pkgbuild_path}/zfs-utils.initcpio.install" - - msg2 "Copying zfs-utils manual patch" - run_cmd_no_output "cp ${script_dir}/src/zfs-utils/0001-Correct-man-page-generation.patch ${zfs_utils_pkgbuild_path}/0001-Correct-man-page-generation.patch" fi if [[ ! -z ${zfs_pkgbuild_path} ]]; then @@ -152,7 +149,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" @@ -244,12 +241,12 @@ for (( a = 0; a < $#; a++ )); do usage else check_mode "${args[$a]}" - debug "have mode '${mode}'" + debug_print_array "have modes" "${modes[@]}" fi done -if [[ ${#commands[@]} -eq 0 || ${mode} == "" ]]; then +if [[ ${#commands[@]} -eq 0 || ${#modes[@]} -eq 0 ]]; then echo error "A build mode and command must be selected!" usage @@ -264,77 +261,82 @@ if ! check_internet; then fi -msg "$(date) :: ${script_name} started..." +for mode_item in ${modes[@]}; do -get_conflicts -get_kernel_update_funcs -debug_print_default_vars + debug "mode_item: ${mode_item}" + mode=$(echo ${mode_item} | cut -f1 -d:) + kernel_name=$(echo ${mode_item} | cut -f2 -d:) -export script_dir mode kernel_name -source_safe "src/kernels/${kernel_name}.sh" + msg "$(date) :: processing '${mode}' packages" + get_conflicts + get_kernel_update_funcs + debug_print_default_vars -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 -fi + export script_dir mode kernel_name + 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" + continue + fi -if have_command "reset_pkgs"; then - msg "Performing git reset for packages/${kernel_name}/*" - msg "${update_funcs[@]}" - for func in "${update_funcs[@]}"; do - debug "Evaluating '${func}'" - "${func}" - msg "${pkg_list[@]}" - for pkg in "${pkg_list[@]}"; do - run_cmd "cd '${script_dir}/packages/${kernel_name}/${pkg}' && git reset --hard HEAD" + if have_command "reset_pkgs"; then + msg "Performing git reset for packages/${kernel_name}/*" + msg "${update_funcs[@]}" + for func in "${update_funcs[@]}"; do + debug "Evaluating '${func}'" + "${func}" + msg "${pkg_list[@]}" + for pkg in "${pkg_list[@]}"; do + run_cmd "cd '${script_dir}/packages/${kernel_name}/${pkg}' && git reset --hard HEAD" + done done - done -fi - + fi -if have_command "update_sums"; then - # Only the files in the zfs-utils package will be updated - run_cmd_show_and_capture_output "sha256sum ${script_dir}/src/zfs-utils/zfs-utils.bash-completion-r1" - azsha1=$(echo ${run_cmd_output} | awk '{ print $1 }') - run_cmd_no_output "sed -e 's/^zfs_bash_completion_hash.*/zfs_bash_completion_hash=\"${azsha1}\"/g' -i ${script_dir}/conf.sh" + if have_command "update_sums"; then + # Only the files in the zfs-utils package will be updated + run_cmd_show_and_capture_output "sha256sum ${script_dir}/src/zfs-utils/zfs-utils.bash-completion-r1" + azsha1=$(echo ${run_cmd_output} | awk '{ print $1 }') + run_cmd_no_output "sed -e 's/^zfs_bash_completion_hash.*/zfs_bash_completion_hash=\"${azsha1}\"/g' -i ${script_dir}/conf.sh" - run_cmd_show_and_capture_output "sha256sum ${script_dir}/src/zfs-utils/zfs-utils.initcpio.hook" - azsha2=$(echo ${run_cmd_output} | awk '{ print $1 }') - run_cmd_no_output "sed -e 's/^zfs_initcpio_hook_hash.*/zfs_initcpio_hook_hash=\"${azsha2}\"/g' -i ${script_dir}/conf.sh" + run_cmd_show_and_capture_output "sha256sum ${script_dir}/src/zfs-utils/zfs-utils.initcpio.hook" + azsha2=$(echo ${run_cmd_output} | awk '{ print $1 }') + run_cmd_no_output "sed -e 's/^zfs_initcpio_hook_hash.*/zfs_initcpio_hook_hash=\"${azsha2}\"/g' -i ${script_dir}/conf.sh" - run_cmd_show_and_capture_output "sha256sum ${script_dir}/src/zfs-utils/zfs-utils.initcpio.install" - azsha3=$(echo ${run_cmd_output} | awk '{ print $1 }') - run_cmd_no_output "sed -e 's/^zfs_initcpio_install_hash.*/zfs_initcpio_install_hash=\"${azsha3}\"/g' -i ${script_dir}/conf.sh" + run_cmd_show_and_capture_output "sha256sum ${script_dir}/src/zfs-utils/zfs-utils.initcpio.install" + azsha3=$(echo ${run_cmd_output} | awk '{ print $1 }') + run_cmd_no_output "sed -e 's/^zfs_initcpio_install_hash.*/zfs_initcpio_install_hash=\"${azsha3}\"/g' -i ${script_dir}/conf.sh" - source_safe "${script_dir}/conf.sh" -fi + source_safe "${script_dir}/conf.sh" + fi + if have_command "update_chroot"; then + msg "Updating the x86_64 clean chroot..." + run_cmd "ccm64 u" + fi -if have_command "update_chroot"; then - msg "Updating the x86_64 clean chroot..." - run_cmd "ccm64 u" -fi + for func in "${update_funcs[@]}"; do + debug "Evaluating '${func}'" + "${func}" + if have_command "update"; then + msg "Updating PKGBUILDs for kernel '${kernel_name}'" + generate_package_files + fi + if have_command "make"; then + build_packages + build_sources + fi + if have_command "sources"; then + build_sources + fi + done + exit 0 -for func in "${update_funcs[@]}"; do - debug "Evaluating '${func}'" - "${func}" - if have_command "update"; then - msg "Updating PKGBUILDs for kernel '${kernel_name}'" - generate_package_files - fi - if have_command "make"; then - build_packages - build_sources - fi - if have_command "sources"; then - build_sources - fi done diff --git a/lib.sh b/lib.sh index a35cf38..d25f2ea 100644 --- a/lib.sh +++ b/lib.sh @@ -6,7 +6,7 @@ shopt -s nullglob dry_run=0 debug_flag=0 haz_error=0 -mode="" +modes=() test_mode="" kernel_name="" # set by generate_mode_list mode_list=() # set by generate_mode_list @@ -358,10 +358,10 @@ kernel_version_has_minor_version() { # $1: the kernel version # returns: 0 if the version contains a minor version and 1 if it does not if [[ ${1} =~ ^[[:digit:]]+\.[[:digit:]]+\.([[:digit:]]+) ]]; then - debug "kernel_version_has_minor_version: Have kernel with minor version!" + # debug "kernel_version_has_minor_version: Have kernel with minor version!" return 0 fi - debug "kernel_version_has_minor_version: Have kernel without minor version!" + # debug "kernel_version_has_minor_version: Have kernel without minor version!" return 1 } @@ -391,7 +391,7 @@ kernel_version_full_no_hyphen() { # from makepkg source_safe() { - export script_dir mode kernel_name + export script_dir modes kernel_name shopt -u extglob if ! source "$@"; then error "Failed to source $1" @@ -536,19 +536,20 @@ check_mode() { # $1 the mode to check for debug "check_mode: checking '$1'" for m in "${mode_list[@]}"; do - debug "check_mode: on '${m}'" + # debug "check_mode: on '${m}'" local moden=$(echo ${m} | cut -f2 -d:) - # debug "moden: ${moden}" if [[ "${moden}" == "$1" ]]; then - if [[ ${mode} != "" ]]; then - error "Already have mode '${moden}', only one mode can be used at a time!" - usage - exit 155 - fi - mode="$1" - kernel_name=$(echo ${m} | cut -f1 -d:) + # if [[ ${mode} != "" ]]; then + # error "Already have mode '${moden}', only one mode can be used at a time!" + # usage + # exit 155 + # fi + local kname=$(echo ${m} | cut -f1 -d:) + modes+=("$1:${kname}") + debug "found mode: $1 kernel_name: ${kname}" return fi + debug "${moden} is not selected" done error "Unrecognized argument '$1'" usage @@ -599,7 +600,7 @@ check_test_mode() { have_command() { # $1: The command to check for # returns 0 if true, and 1 for false - debug "have_command: checking '$1'" + # debug "have_command: checking '$1'" for cmd in "${commands[@]}"; do # debug "have_command: loop '$cmd'" if [[ ${cmd} == $1 ]]; then @@ -607,7 +608,7 @@ have_command() { return 0 fi done - debug "have_command: '$1' is not defined" + # debug "have_command: '$1' is not defined" return 1 } @@ -701,11 +702,13 @@ get_conflicts() { debug_print_default_vars() { debug "dry_run: "${dry_run} debug "debug_flag: "${debug_flag} - debug "mode: ${mode}" debug "kernel_name: ${kernel_name}" if [[ ${#mode_list[@]} -gt 0 ]]; then debug_print_array "mode_list" "${mode_list[@]}" fi + if [[ ${#modes[@]} -gt 0 ]]; then + debug_print_array "selected_modes" "${modes[@]}" + fi if [[ ${#update_funcs[@]} -gt 0 ]]; then debug_print_array "update_funcs" "${update_funcs[@]}" fi