Ok, this is really the final refactor

for now ...
pull/57/merge
Jesus Alvarez 9 years ago
parent 261e0cfa17
commit 2c9abd5925
  1. 235
      build.sh
  2. 2
      conf.sh
  3. 234
      lib.sh
  4. 2
      packages/linux-lts/spl-linux-lts
  5. 2
      packages/linux-lts/spl-utils-linux-lts
  6. 2
      packages/linux-lts/zfs-linux-lts
  7. 2
      packages/linux-lts/zfs-utils-linux-lts
  8. 2
      packages/linux/spl-linux
  9. 2
      packages/linux/spl-linux-git
  10. 2
      packages/linux/spl-utils-linux
  11. 2
      packages/linux/spl-utils-linux-git
  12. 2
      packages/linux/zfs-linux
  13. 2
      packages/linux/zfs-linux-git
  14. 2
      packages/linux/zfs-utils-linux
  15. 2
      packages/linux/zfs-utils-linux-git
  16. 103
      push.sh
  17. 342
      repo.sh
  18. 94
      scraper.sh
  19. 12
      src/kernels/linux-lts.sh
  20. 22
      src/kernels/linux.sh
  21. 2
      src/zfs/zfs.install.sh
  22. 94
      verifier.sh

@ -8,33 +8,22 @@
#
NAME=$(basename $0)
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
COMMANDS=()
MODE=""
MODE_NAME=""
MODE_LIST=()
UPDATE_FUNCS=()
args=("$@")
script_name=$(basename $0)
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if ! source ${SCRIPT_DIR}/lib.sh; then
if ! source ${script_dir}/lib.sh; then
echo "!! ERROR !! -- Could not load lib.sh!"
exit 1
exit 155
fi
source_safe "${SCRIPT_DIR}/conf.sh"
# setup signal traps
trap "trap_quit" TERM HUP QUIT
trap "trap_abort" INT
trap "trap_usr1" USR1
trap "trap_exit" EXIT
source_safe "${script_dir}/conf.sh"
usage() {
echo "${NAME} - A build script for archzfs"
echo "${script_name} - A build script for archzfs"
echo
echo "Usage: ${NAME} [options] mode command [command ...]"
echo "Usage: ${script_name} [options] mode command [command ...]"
echo
echo "Options:"
echo
@ -46,10 +35,10 @@ usage() {
echo
echo "Modes:"
echo
for mode in "${MODE_LIST[@]}"; do
mode_name=$(echo ${mode} | cut -f2 -d:)
mode_desc=$(echo ${mode} | cut -f3 -d:)
echo -e " ${mode_name} ${mode_desc}"
for ml in "${mode_list[@]}"; do
mn=$(echo ${ml} | cut -f2 -d:)
md=$(echo ${ml} | cut -f3 -d:)
echo -e " ${mn} ${md}"
done
echo
echo "Commands:"
@ -63,25 +52,25 @@ usage() {
echo
echo "Examples:"
echo
echo " ${NAME} -C :: Remove all compiled packages"
echo " ${NAME} git make -u :: Update the chroot and build all of the packages"
echo " ${NAME} lts update :: Update PKGBUILDS only"
echo " ${NAME} git update make -u :: Update PKGBUILDs, update the chroot, and make all of the packages"
echo " ${NAME} lts update-test test -u :: Update PKGBUILDs (use testing versions), update the chroot, and make all of the packages"
trap - EXIT # Prevents exit log output
echo " ${script_name} std -C :: Remove all compiled packages for the standard kernels"
echo " ${script_name} std make -u :: Update the chroot and build all of the packages"
echo " ${script_name} lts update :: Update PKGBUILDS only"
echo " ${script_name} std update make -u :: Update PKGBUILDs, update the chroot, and make all of the packages"
echo " ${script_name} lts update-test test -u :: Update PKGBUILDs (use testing versions), update the chroot, and make all of the packages"
exit 155
}
build_sources() {
for pkg in ${pkg_list}; do
for pkg in "${pkg_list[@]}"; do
msg "Building source for ${pkg}";
run_cmd "cd \"${SCRIPT_DIR}/packages/${MODE_NAME}/${pkg}\" && mkaurball -f"
run_cmd "cd \"${script_dir}/packages/${kernel_name}/${pkg}\" && mksrcinfo && mkaurball -f"
done
}
sign_packages() {
files=$(find ${SCRIPT_DIR} -iname "*.pkg.tar.xz")
files=$(find ${script_dir} -iname "*.pkg.tar.xz")
debug "Found files: ${files}"
msg "Signing the packages with GPG"
for f in ${files}; do
@ -94,14 +83,14 @@ sign_packages() {
git_check_repo() {
for pkg in ${pkg_list}; do
for pkg in "${pkg_list[@]}"; do
local reponame="spl"
local url="${spl_git_url}"
if [[ ${pkg} =~ ^zfs ]]; then
url="${zfs_git_url}"
reponame="zfs"
fi
local repopath="${SCRIPT_DIR}/packages/${MODE_NAME}/${pkg}/${reponame}"
local repopath="${script_dir}/packages/${kernel_name}/${pkg}/${reponame}"
debug "GIT URL: ${url}"
debug "GIT REPO: ${repopath}"
@ -109,14 +98,14 @@ git_check_repo() {
if [[ ! -d "${repopath}" ]]; then
msg2 "Cloning repo '${repopath}'"
run_cmd_no_dry_run "git clone --mirror '${url}' '${repopath}'"
if [[ ${RUN_CMD_RETURN} -ne 0 ]]; then
if [[ ${run_cmd_return} -ne 0 ]]; then
error "Failure while cloning ${url} repo"
exit 1
fi
else
msg2 "Updating repo '${repopath}'"
run_cmd_no_dry_run "cd ${repopath} && git fetch --all -p"
if [[ ${RUN_CMD_RETURN} -ne 0 ]]; then
if [[ ${run_cmd_return} -ne 0 ]]; then
error "Failure while fetching ${url} repo"
exit 1
fi
@ -129,7 +118,7 @@ git_calc_pkgver() {
for repo in "spl" "zfs"; do
msg2 "Cloning working copy for ${repo}"
local sha=${spl_git_commit}
local kernvers=$(kernel_version_full_no_hyphen ${kernel_version})
local kernvers=${kernel_version_full_pkgver}
if [[ ${repo} =~ ^zfs ]]; then
sha=${zfs_git_commit}
fi
@ -141,7 +130,7 @@ git_calc_pkgver() {
local cmd="/usr/bin/bash -s << EOF 2>/dev/null\\n"
cmd+="[[ -d temp ]] && rm -r temp\\n"
cmd+="mkdir temp && cd temp\\n"
cmd+="git clone ../packages/${MODE_NAME}/${pkg}/${repo} && cd ${repo}\\n"
cmd+="git clone ../packages/${kernel_name}/${pkg}/${repo} && cd ${repo}\\n"
cmd+="git checkout -b azb ${sha}\\n"
cmd+="EOF\\n"
run_cmd_no_output_no_dry_run "${cmd}"
@ -153,10 +142,10 @@ git_calc_pkgver() {
run_cmd_no_output_no_dry_run "${cmd}"
if [[ ${repo} =~ ^spl ]]; then
spl_pkgver=${RUN_CMD_OUTPUT}
spl_pkgver=${run_cmd_output}
debug "spl_pkgver: ${spl_pkgver}"
elif [[ ${repo} =~ ^zfs ]]; then
zfs_pkgver=${RUN_CMD_OUTPUT}
zfs_pkgver=${run_cmd_output}
debug "zfs_pkgver: ${zfs_pkgver}"
fi
@ -205,45 +194,36 @@ generate_package_files() {
# Finally, generate the update packages ...
msg2 "Creating spl-utils PKGBUILD"
run_cmd_no_output "source ${SCRIPT_DIR}/src/spl-utils/PKGBUILD.sh"
run_cmd_no_output "source ${script_dir}/src/spl-utils/PKGBUILD.sh"
msg2 "Copying spl-utils.hostid"
run_cmd_no_output "cp ${SCRIPT_DIR}/src/spl-utils/spl-utils.hostid ${spl_utils_pkgbuild_path}/spl-utils.hostid"
run_cmd_no_output "cp ${script_dir}/src/spl-utils/spl-utils.hostid ${spl_utils_pkgbuild_path}/spl-utils.hostid"
msg2 "Creating spl PKGBUILD"
run_cmd_no_output "source ${SCRIPT_DIR}/src/spl/PKGBUILD.sh"
run_cmd_no_output "source ${script_dir}/src/spl/PKGBUILD.sh"
msg2 "Creating spl.install"
run_cmd_no_output "source ${SCRIPT_DIR}/src/spl/spl.install.sh"
run_cmd_no_output "source ${script_dir}/src/spl/spl.install.sh"
msg2 "Creating zfs-utils PKGBUILD"
run_cmd_no_output "source ${SCRIPT_DIR}/src/zfs-utils/PKGBUILD.sh"
run_cmd_no_output "source ${script_dir}/src/zfs-utils/PKGBUILD.sh"
msg2 "Copying zfs-utils.bash-completion"
run_cmd_no_output "cp ${SCRIPT_DIR}/src/zfs-utils/zfs-utils.bash-completion-r1 ${zfs_utils_pkgbuild_path}/zfs-utils.bash-completion-r1"
run_cmd_no_output "cp ${script_dir}/src/zfs-utils/zfs-utils.bash-completion-r1 ${zfs_utils_pkgbuild_path}/zfs-utils.bash-completion-r1"
msg2 "Copying zfs-utils.initcpio.hook"
run_cmd_no_output "cp ${SCRIPT_DIR}/src/zfs-utils/zfs-utils.initcpio.hook ${zfs_utils_pkgbuild_path}/zfs-utils.initcpio.hook"
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"
run_cmd_no_output "cp ${script_dir}/src/zfs-utils/zfs-utils.initcpio.install ${zfs_utils_pkgbuild_path}/zfs-utils.initcpio.install"
msg2 "Creating zfs PKGBUILD"
run_cmd_no_output "source ${SCRIPT_DIR}/src/zfs/PKGBUILD.sh"
run_cmd_no_output "source ${script_dir}/src/zfs/PKGBUILD.sh"
msg2 "Creating zfs.install"
run_cmd_no_output "source ${SCRIPT_DIR}/src/zfs/zfs.install.sh"
}
generate_mode_list() {
for mode in $(ls ${SCRIPT_DIR}/src/kernels); do
mode_name=$(source ${SCRIPT_DIR}/src/kernels/${mode}; echo ${mode_name})
mode_desc=$(source ${SCRIPT_DIR}/src/kernels/${mode}; echo ${mode_desc})
MODE_LIST+=("${mode%.*}:${mode_name}:${mode_desc}")
done
run_cmd_no_output "source ${script_dir}/src/zfs/zfs.install.sh"
}
build_packages() {
for pkg in ${pkg_list}; do
for pkg in "${pkg_list[@]}"; do
msg "Building ${pkg}..."
run_cmd "cd \"${SCRIPT_DIR}/packages/${MODE_NAME}/${pkg}\" && sudo ccm64 s && mksrcinfo"
if [[ ${RUN_CMD_RETURN} -ne 0 ]]; then
run_cmd "cd \"${script_dir}/packages/${kernel_name}/${pkg}\" && sudo ccm64 s && mksrcinfo"
if [[ ${run_cmd_return} -ne 0 ]]; then
error "A problem occurred building the package"
exit 1
fi
@ -254,90 +234,62 @@ build_packages() {
}
get_kernel_update_funcs() {
for kernel in $(ls ${SCRIPT_DIR}/src/kernels); do
if [[ ${kernel%.*} != ${MODE_NAME} ]]; then
continue
fi
updatefuncs=$(cat "${SCRIPT_DIR}/src/kernels/${kernel}" | grep -oh "update_.*_pkgbuilds")
for func in ${updatefuncs}; do UPDATE_FUNCS+=("${func}"); done
done
}
# Do this early so it is possible to see the output
if check_debug; then
DEBUG=1
fi
generate_mode_list
if [[ $# -lt 1 ]]; then
usage;
exit 0;
usage
fi
ARGS=("$@")
for (( a = 0; a < $#; a++ )); do
if [[ ${ARGS[$a]} == "make" ]]; then
COMMANDS+=("make")
elif [[ ${ARGS[$a]} == "test" ]]; then
COMMANDS+=("test")
elif [[ ${ARGS[$a]} == "update" ]]; then
COMMANDS+=("update")
elif [[ ${ARGS[$a]} == "update-test" ]]; then
COMMANDS+=("update-test")
elif [[ ${ARGS[$a]} == "sources" ]]; then
COMMANDS+=("sources")
elif [[ ${ARGS[$a]} == "sign" ]]; then
COMMANDS+=("sign")
elif [[ ${ARGS[$a]} == "-C" ]]; then
COMMANDS+=("cleanup")
elif [[ ${ARGS[$a]} == "-u" ]]; then
COMMANDS+=("update_chroot")
elif [[ ${ARGS[$a]} == "-n" ]]; then
DRY_RUN=1
elif [[ ${ARGS[$a]} == "-d" ]]; then
DEBUG=1
elif [[ ${ARGS[$a]} == "-h" ]]; then
usage;
exit 0;
if [[ ${args[$a]} == "make" ]]; then
commands+=("make")
elif [[ ${args[$a]} == "test" ]]; then
commands+=("test")
elif [[ ${args[$a]} == "update" ]]; then
commands+=("update")
elif [[ ${args[$a]} == "update-test" ]]; then
commands+=("update-test")
elif [[ ${args[$a]} == "sources" ]]; then
commands+=("sources")
elif [[ ${args[$a]} == "sign" ]]; then
commands+=("sign")
elif [[ ${args[$a]} == "-C" ]]; then
commands+=("cleanup")
elif [[ ${args[$a]} == "-u" ]]; then
commands+=("update_chroot")
elif [[ ${args[$a]} == "-n" ]]; then
dry_run=1
elif [[ ${args[$a]} == "-d" ]]; then
debug_flag=1
elif [[ ${args[$a]} == "-h" ]]; then
usage
else
check_mode "${ARGS[$a]}"
debug "have mode '${MODE}'"
check_mode "${args[$a]}"
debug "have mode '${mode}'"
fi
done
if have_command "cleanup" && [[ $# -gt 1 ]]; then
echo
error "-C should be used by itself!"
usage;
exit 0;
fi
if ! have_command "cleanup" && [[ ${#COMMANDS[@]} -eq 0 || ${MODE} == "" ]]; then
if [[ ${#commands[@]} -eq 0 || ${mode} == "" ]]; then
echo
error "A build mode and command must be selected!"
usage;
exit 0;
usage
fi
if have_command "cleanup"; then
msg "Cleaning up work files..."
run_cmd "find . \( -iname \"*.log\" -o -iname \"*.pkg.tar.xz*\" -o -iname \"*.src.tar.gz\" \) -print -exec rm -rf {} \\;"
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
msg "$(date) :: ${NAME} started..."
msg "$(date) :: ${script_name} started..."
if have_command "update_chroot"; then
@ -346,30 +298,29 @@ if have_command "update_chroot"; then
fi
if [[ ${MODE} != "" ]]; then
get_kernel_update_funcs
get_kernel_update_funcs
debug_print_default_vars
export SCRIPT_DIR MODE MODE_NAME BUILD SIGN SOURCES UPDATE_PKGBUILDS
source_safe "src/kernels/${MODE_NAME}.sh"
export script_dir mode kernel_name
source_safe "src/kernels/${kernel_name}.sh"
for func in "${UPDATE_FUNCS[@]}"; do
debug "Evaluating '${func}'"
"${func}"
if have_command "update"; then
msg "Updating PKGBUILDs for kernel '${MODE_NAME}'"
generate_package_files
fi
if have_command "make"; then
build_packages
sign_packages
build_sources
fi
if have_command "sources"; then
build_sources
fi
done
if have_command "sign"; then
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
sign_packages
build_sources
fi
if have_command "sources"; then
build_sources
fi
done
if have_command "sign"; then
sign_packages
fi

@ -13,6 +13,8 @@ zfs_initcpio_hook_hash="67a96169d36853d8f18ee5a2443ecfcd2461a20f9109f4b281bee394
email="jeezusjr@gmail.com"
# Repository path and name
repo_name="archzfs"
repo_name_test="archzfs-testing"
repo_basepath="/data/pacman/repo"
# SSH login address (can use ssh config Hosts)

234
lib.sh

@ -2,25 +2,42 @@
shopt -s nullglob
dry_run=0
debug_flag=0
mode=""
kernel_name="" # set by generate_mode_list
mode_list=() # set by generate_mode_list
update_funcs=() # set by generate_mode_list
commands=()
# setup signal traps
trap "trap_quit" TERM HUP QUIT
trap "trap_abort" INT
trap "trap_usr1" USR1
trap "trap_exit" EXIT
# check if messages are to be printed using color
unset ALL_OFF BOLD BLACK BLUE GREEN RED YELLOW WHITE DEFAULT CYAN MAGENTA
ALL_OFF="\e[0m"
BOLD="\e[1m"
BLACK="${BOLD}\e[30m"
RED="${BOLD}\e[31m"
GREEN="${BOLD}\e[32m"
YELLOW="${BOLD}\e[33m"
BLUE="${BOLD}\e[34m"
MAGENTA="${BOLD}\e[35m"
CYAN="${BOLD}\e[36m"
WHITE="${BOLD}\e[37m"
DEFAULT="${BOLD}\e[39m"
readonly ALL_OFF BOLD BLACK BLUE GREEN RED YELLOW WHITE DEFAULT CYAN MAGENTA
unset all_off bold black blue green red yellow white default cyan magenta
all_off="\e[0m"
bold="\e[1m"
black="${bold}\e[30m"
red="${bold}\e[31m"
green="${bold}\e[32m"
yellow="${bold}\e[33m"
blue="${bold}\e[34m"
magenta="${bold}\e[35m"
cyan="${bold}\e[36m"
white="${bold}\e[37m"
default="${bold}\e[39m"
readonly all_off bold black blue green red yellow white default cyan magenta
plain() {
local mesg=$1; shift
printf "${ALL_OFF}%s${ALL_OFF}\n\n" "${mesg}"
printf "${all_off}%s${all_off}\n\n" "${mesg}"
if [[ $# -gt 0 ]]; then
printf '%s ' "${@}"
printf '\n\n'
@ -30,13 +47,13 @@ plain() {
plain_one_line() {
local mesg=$1; shift
printf "${ALL_OFF}${ALL_OFF}%s %s\n\n" "${mesg}" "${@}"
printf "${all_off}${all_off}%s %s\n\n" "${mesg}" "${@}"
}
msg() {
local mesg=$1; shift
printf "${GREEN}====${ALL_OFF} ${BOLD}%s${ALL_OFF}\n\n" "$mesg"
printf "${green}====${all_off} ${bold}%s${all_off}\n\n" "$mesg"
if [[ $# -gt 0 ]]; then
printf '%s ' "${@}"
printf '\n\n'
@ -46,7 +63,7 @@ msg() {
msg2() {
local mesg=$1; shift
printf "${BLUE}++++ ${ALL_OFF}${BOLD}${mesg}${ALL_OFF}\n\n" "$mesg"
printf "${blue}++++ ${all_off}${bold}${mesg}${all_off}\n\n" "$mesg"
if [[ $# -gt 0 ]]; then
printf '%s ' "${@}"
printf '\n\n'
@ -56,7 +73,7 @@ msg2() {
warning() {
local mesg=$1; shift
printf "${YELLOW}==== WARNING: ${ALL_OFF}${BOLD}${mesg}${ALL_OFF}\n\n" "$mesg" 1>&2
printf "${yellow}==== WARNING: ${all_off}${bold}${mesg}${all_off}\n\n" "$mesg" 1>&2
if [[ $# -gt 0 ]]; then
printf '%s ' "${@}" 1>&2
printf '\n\n'
@ -66,7 +83,7 @@ warning() {
error() {
local mesg=$1; shift
printf "${RED}==== ERROR: ${ALL_OFF}${RED}${BOLD}${mesg}${ALL_OFF}\n\n" "$mesg" 1>&2
printf "${red}==== ERROR: ${all_off}${red}${bold}${mesg}${all_off}\n\n" "$mesg" 1>&2
if [[ $# -gt 0 ]]; then
printf '%s ' "${@}" 1>&2
printf '\n\n'
@ -76,9 +93,9 @@ error() {
debug() {
# $1: The message to print.
if [[ $DEBUG -eq 1 ]]; then
if [[ ${debug_flag} -eq 1 ]]; then
local mesg=$1; shift
printf "${MAGENTA}~~~~ DEBUG: ${ALL_OFF}${BOLD}${mesg}${ALL_OFF}\n\n" "$mesg" 1>&2
printf "${magenta}~~~~ DEBUG: ${all_off}${bold}${mesg}${all_off}\n\n" "$mesg" 1>&2
if [[ $# -gt 0 ]]; then
printf '%s ' "${@}" 1>&2
printf '\n\n'
@ -89,7 +106,7 @@ debug() {
test_pass() {
local mesg=$1; shift
printf "${GREEN}==== PASS: ${ALL_OFF}${BOLD}${mesg}${ALL_OFF}\n\n" "$mesg" 1>&2
printf "${green}==== PASS: ${all_off}${bold}${mesg}${all_off}\n\n" "$mesg" 1>&2
if [[ $# -gt 0 ]]; then
printf '%s ' "${@}" 1>&2
printf '\n\n'
@ -99,7 +116,7 @@ test_pass() {
test_fail() {
local mesg=$1; shift
printf "${RED}==== FAILED: ${ALL_OFF}${RED}${BOLD}${mesg}${ALL_OFF}\n\n" "$mesg" 1>&2
printf "${red}==== FAILED: ${all_off}${red}${bold}${mesg}${all_off}\n\n" "$mesg" 1>&2
if [[ $# -gt 0 ]]; then
printf '%s ' "${@}" 1>&2
printf '\n\n'
@ -160,7 +177,7 @@ function relativePath() {
norun() {
local mesg=$1; shift
printf "${MAGENTA}XXXX NORUN: ${ALL_OFF}${BOLD}${mesg}${ALL_OFF}\n\n" "$mesg"
printf "${magenta}XXXX NORUN: ${all_off}${bold}${mesg}${all_off}\n\n" "$mesg"
if [[ $# -gt 0 ]]; then
printf '%s ' "$@"
printf '\n\n'
@ -170,43 +187,43 @@ norun() {
# Runs a command. Ouput is not captured
# To use this function, define the following in your calling script:
# RUN_CMD_RETURN=""
# run_cmd_return=""
run_cmd() {
# $@: The command and args to run
if [[ $DRY_RUN -eq 1 ]]; then
if [[ ${dry_run} -eq 1 ]]; then
norun "CMD:" "$@"
else
plain "Running command:" "$@"
plain_one_line "Output:"
echo -e "$@" | source /dev/stdin
RUN_CMD_RETURN=$?
run_cmd_return=$?
echo
plain_one_line "Command returned:" "${RUN_CMD_RETURN}"
plain_one_line "Command returned:" "${run_cmd_return}"
fi
}
# Runs a command. Ouput is not captured. DRY_RUN=1 is ignored.
# Runs a command. Ouput is not captured. dry_run=1 is ignored.
# To use this function, define the following in your calling script:
# RUN_CMD_RETURN=""
# run_cmd_return=""
run_cmd_no_dry_run() {
# $@: The command and args to run
plain "Running command:" "$@"
plain_one_line "Output:"
echo -e "$@" | source /dev/stdin
RUN_CMD_RETURN=$?
run_cmd_return=$?
echo
plain_one_line "Command returned:" "${RUN_CMD_RETURN}"
plain_one_line "Command returned:" "${run_cmd_return}"
}
# Runs a command, capture the output in RUN_CMD_OUTPUT, but also show stdout.
# Runs a command, capture the output in run_cmd_output, but also show stdout.
# To use this function, define the following in your calling script:
# RUN_CMD_OUTPUT=""
# RUN_CMD_RETURN=""
# run_cmd_output=""
# run_cmd_return=""
run_cmd_show_and_capture_output() {
# $@: The command and args to run
if [[ $DRY_RUN -eq 1 ]]; then
if [[ ${dry_run} -eq 1 ]]; then
norun "CMD:" "$@"
else
plain "Running command:" "$@"
@ -219,19 +236,19 @@ run_cmd_show_and_capture_output() {
# lib.sh: line 145: /bin/cat: Argument list too long
exec 6>&1 # Link file descriptor 6 with stdout.
RUN_CMD_OUTPUT=$(echo -e "$@" | source /dev/stdin | tee >(cat - >&6); exit ${PIPESTATUS[1]})
run_cmd_output=$(echo -e "$@" | source /dev/stdin | tee >(cat - >&6); exit ${PIPESTATUS[1]})
exec 1>&6 6>&- # Restore stdout and close file descriptor #6.
RUN_CMD_RETURN=$?
run_cmd_return=$?
echo
plain_one_line "Command returned:" "${RUN_CMD_RETURN}"
plain_one_line "Command returned:" "${run_cmd_return}"
fi
}
# Runs a command, capture the output in RUN_CMD_OUTPUT, but also show stdout. Ignores DRY_RUN=1.
# Runs a command, capture the output in run_cmd_output, but also show stdout. Ignores dry_run=1.
# To use this function, define the following in your calling script:
# RUN_CMD_OUTPUT=""
# RUN_CMD_RETURN=""
# run_cmd_output=""
# run_cmd_return=""
run_cmd_show_and_capture_output_no_dry_run() {
# $@: The command and args to run
plain "Running command:" "$@"
@ -244,41 +261,41 @@ run_cmd_show_and_capture_output_no_dry_run() {
# lib.sh: line 145: /bin/cat: Argument list too long
exec 6>&1 # Link file descriptor 6 with stdout.
RUN_CMD_OUTPUT=$(echo -e "$@" | source /dev/stdin | tee >(cat - >&6); exit ${PIPESTATUS[1]})
run_cmd_output=$(echo -e "$@" | source /dev/stdin | tee >(cat - >&6); exit ${PIPESTATUS[1]})
exec 1>&6 6>&- # Restore stdout and close file descriptor #6.
RUN_CMD_RETURN=$?
run_cmd_return=$?
echo
plain_one_line "Command returned:" "${RUN_CMD_RETURN}"
plain_one_line "Command returned:" "${run_cmd_return}"
}
# Runs the command, does not show output to stdout
# To use this function, define the following in your calling script:
# RUN_CMD_OUTPUT=""
# RUN_CMD_RETURN=""
# run_cmd_output=""
# run_cmd_return=""
run_cmd_no_output() {
# $@: The command and args to run
if [[ $DRY_RUN -eq 1 ]]; then
if [[ ${dry_run} -eq 1 ]]; then
norun "CMD:" "$@"
else
plain "Running command:" "$@"
RUN_CMD_OUTPUT=$(echo -e "$@" | source /dev/stdin)
RUN_CMD_RETURN=$?
plain_one_line "Command returned:" "${RUN_CMD_RETURN}"
run_cmd_output=$(echo -e "$@" | source /dev/stdin)
run_cmd_return=$?
plain_one_line "Command returned:" "${run_cmd_return}"
fi
}
# Runs the command, does not show output to stdout, ignores DRY_RUN=1
# Runs the command, does not show output to stdout, ignores dry_run=1
# To use this function, define the following in your calling script:
# RUN_CMD_OUTPUT=""
# RUN_CMD_RETURN=""
# run_cmd_output=""
# run_cmd_return=""
run_cmd_no_output_no_dry_run() {
# $@: The command and args to run
plain "Running command:" "$@"
RUN_CMD_OUTPUT=$(echo -e "$@" | source /dev/stdin)
RUN_CMD_RETURN=$?
plain_one_line "Command returned:" "${RUN_CMD_RETURN}"
run_cmd_output=$(echo -e "$@" | source /dev/stdin)
run_cmd_return=$?
plain_one_line "Command returned:" "${run_cmd_return}"
}
@ -347,57 +364,120 @@ kernel_version_full_no_hyphen() {
# from makepkg
source_safe() {
shopt -u extglob
if ! source "$@"; then
error "Failed to source $1"
exit 1
fi
shopt -s extglob
export script_dir mode kernel_name
shopt -u extglob
if ! source "$@"; then
error "Failed to source $1"
exit 1
fi
shopt -s extglob
}
check_mode() {
# $1 the mode to check for
for mode in "${MODE_LIST[@]}"; do
debug "check_mode: on '${mode}'"
local moden=$(echo ${mode} | cut -f2 -d:)
debug "check_mode: checking '$1'"
for m in "${mode_list[@]}"; do
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 '${MODE}', only one mode can be used at a time!"
if [[ ${mode} != "" ]]; then
error "Already have mode '${moden}', only one mode can be used at a time!"
usage
exit 1
exit 155
fi
MODE="$1"
MODE_NAME=$(echo ${mode} | cut -f1 -d:)
mode="$1"
kernel_name=$(echo ${m} | cut -f1 -d:)
return
fi
done
error "Unrecognized argument '$1'"
usage
exit 1
exit 155
}
have_command() {
# $1: The command to check for
# returns 0 if true, and 1 for false
debug "have_command: checking '$1'"
for cmd in "${COMMANDS[@]}"; do
debug "have_command: loop '$cmd'"
for cmd in "${commands[@]}"; do
# debug "have_command: loop '$cmd'"
if [[ ${cmd} == $1 ]]; then
debug "have_command: '$1' is defined"
return 0
fi
done
debug "have_command: '$1' is not defined"
return 1
}
check_debug() {
# Returns 0 if DEBUG argument is defined and 1 if not
for (( a = 0; a < $#; a++ )); do
if [[ ${ARGS[$a]} == "-d" ]]; then
# args must be defined in the source script that loads lib.sh!
# Returns 0 if debug argument is defined and 1 if not
for (( a = 0; a < "${#args[@]}"; a++ )); do
if [[ ${args[$a]} == "-d" ]]; then
return 0
fi
done
return 1
}
generate_mode_list() {
for m in $(ls ${script_dir}/src/kernels); do
mn=$(source ${script_dir}/src/kernels/${m}; echo ${mode_name})
md=$(source ${script_dir}/src/kernels/${m}; echo ${mode_desc})
mode_list+=("${m%.*}:${mn}:${md}")
done
}
get_kernel_update_funcs() {
for kernel in $(ls ${script_dir}/src/kernels); do
if [[ ${kernel%.*} != ${kernel_name} ]]; then
continue
fi
updatefuncs=$(cat "${script_dir}/src/kernels/${kernel}" | grep -oh "update_.*_pkgbuilds")
for func in ${updatefuncs}; do update_funcs+=("${func}"); done
done
}
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 [[ ${#update_funcs[@]} -gt 0 ]]; then
debug_print_array "update_funcs" "${update_funcs[@]}"
fi
if [[ ${#commands[@]} -gt 0 ]]; then
debug_print_array "commands" "${commands[@]}"
fi
}
debug_print_array() {
# $1 array name
# $2 array
if [[ $# -lt 2 ]]; then
warning "debug_print_array: Array '$1' is empty"
return
fi
local name=$1; shift
for item in "${@}"; do
debug "${name} (array item): ${item}"
done
}
# Do this early so it is possible to see the output
if check_debug; then
debug_flag=1
debug "debug mode is enabled"
fi

@ -1 +1 @@
Subproject commit d4689156d9931143f9ceeb9673a2007e1809fb68
Subproject commit 60311383f98996725eb6c43542f711f3d700cec1

@ -1 +1 @@
Subproject commit 2c758f6f220fc3bb2e94a0b1d8d2b3efd10f25d3
Subproject commit e6d100576248afed90f17fcdc43dfbe96face3c6

@ -1 +1 @@
Subproject commit ec96b0798d96bf2c23c221de4a054b23143685fe
Subproject commit 83041adbc91f696f09f1e02752cb29403e2510af

@ -1 +1 @@
Subproject commit adcb2fd8c264119f7027654c330ab48f86b29a6f
Subproject commit a41e764f2f4643bce58ee169930eada9e3e3b9c5

@ -1 +1 @@
Subproject commit c0e497a7b653fb67e084edf0c37a3c65595f08b1
Subproject commit 76e74bf7c83193ac865ca7d6dfbe27611f8f2b2f

@ -1 +1 @@
Subproject commit bb66809559aee02936bd864f5f27ebd0aa5adfeb
Subproject commit 25b88671d1e203794d268c364ac0e142f24c301c

@ -1 +1 @@
Subproject commit dada84f59f6e0e891bccdef2cc7da398f48aabb6
Subproject commit c8d3fba90c7043b561131875f5738c7508533284

@ -1 +1 @@
Subproject commit f9b2e2c19616ee2b44274ead8ca7a3f323b0db0d
Subproject commit 149d79ec6444bed9356dd479fbc68285f1cf868b

@ -1 +1 @@
Subproject commit 5583681b0fdc243382e901ae390c31aab4d0256b
Subproject commit e63cad79f56f405c5a12f25457171e4f47ea8d80

@ -1 +1 @@
Subproject commit 0a5f32ffdc6fbf747fe77cab007a58632ba5d666
Subproject commit 88de868436c8353468fb2f79e08b7c011f52522c

@ -1 +1 @@
Subproject commit 650c426aac0033aea4f214c3fdca2879d1e025b2
Subproject commit fe123c63f8ae0732e8c620e3e4acb1dcd533efe2

@ -1 +1 @@
Subproject commit 247d8f08d3bd0bf6350e25d7aa6811d60c849ca9
Subproject commit 21c1c7a5cc0280761f44c8503e86fd84b6f1eb3c

@ -1,4 +1,4 @@
#!/bin/bash -e
#!/bin/bash
#
@ -7,41 +7,47 @@
#
NAME=$(basename $0)
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
args=("$@")
script_name=$(basename $0)
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
push=0
push_repo=0
if ! source ${SCRIPT_DIR}/lib.sh; then
if ! source ${script_dir}/lib.sh; then
echo "!! ERROR !! -- Could not load lib.sh!"
exit 1
exit 155
fi
source_safe "${SCRIPT_DIR}/conf.sh"
source_safe "${script_dir}/conf.sh"
usage() {
echo "${NAME} - Pushes the packages sources to AUR using burp."
echo "${script_name} - Pushes the packages sources to AUR using burp."
echo
echo "Usage: ${NAME} [options] [mode]"
echo "Usage: ${script_name} [options] [mode]"
echo
echo "Options:"
echo
echo " -h: Show help information."
echo " -n: Dryrun; Output commands, but don't do anything."
echo " -d: Show debug info."
echo " -r: Push the archzfs repositories."
echo " -p: Commit changes and push."
echo
echo "Modes:"
echo
for mode in "${MODE_LIST[@]}"; do
mode_name=$(echo ${mode} | cut -f2 -d:)
mode_desc=$(echo ${mode} | cut -f3 -d:)
echo -e " ${mode_name} ${mode_desc}"
for ml in "${mode_list[@]}"; do
mn=$(echo ${ml} | cut -f2 -d:)
md=$(echo ${ml} | cut -f3 -d:)
echo -e " ${mn} ${md}"
done
echo
echo "Example Usage:"
echo
echo " ${NAME} std :: Push the default package sources."
echo " ${NAME} lts :: Push the lts package sources."
trap - EXIT # Prevents exit log output
echo " ${script_name} std :: Show package changes."
echo " ${script_name} std -p :: Push the default package sources."
echo " ${script_name} lts -p :: Push the lts package sources."
exit 155
}
@ -49,64 +55,83 @@ generate_mode_list
if [[ $# -lt 1 ]]; then
usage;
exit 1
usage
fi
ARGS=("$@")
for (( a = 0; a < $#; a++ )); do
if [[ ${ARGS[$a]} == "-n" ]]; then
DRY_RUN=1
elif [[ ${ARGS[$a]} == "-d" ]]; then
DEBUG=1
elif [[ ${ARGS[$a]} == "-h" ]]; then
usage;
exit 0;
if [[ ${args[$a]} == "-n" ]]; then
dry_run=1
elif [[ ${args[$a]} == "-d" ]]; then
debug_flag=1
elif [[ ${args[$a]} == "-p" ]]; then
push=1
elif [[ ${args[$a]} == "-r" ]]; then
push_repo=1
elif [[ ${args[$a]} == "-h" ]]; then
usage
else
check_mode "${ARGS[$a]}"
debug "have mode '${MODE}'"
check_mode "${args[$a]}"
debug "have mode '${mode}'"
fi
done
if [[ ${MODE} == "" ]]; then
if [[ ${mode} == "" && ${push_repo} -eq 0 ]]; then
echo
error "A mode must be selected!"
usage
exit 155
fi
msg "$(date) :: ${NAME} started..."
msg "$(date) :: ${script_name} started..."
push_packages() {
for pkg in ${pkg_list}; do
for pkg in "${pkg_list[@]}"; do
msg "Packaging ${pkg}..."
local cmd="cd \"${PWD}/packages/${MODE_NAME}/${pkg}\" && "
cmd+="mksrcinfo && "
cmd+="git add . && git commit -m 'Semi-automated update for ${zfs_pkgver}-${zfs_pkgrel}' && "
cmd+="git push"
local cmd="cd \"${PWD}/packages/${kernel_name}/${pkg}\" && "
if [[ ${push} -eq 1 ]]; then
cmd+="git diff && echo && echo && git add . && git commit -m 'Semi-automated update for ${zfs_pkgver}-${zfs_pkgrel}'; "
cmd+="git push"
else
cmd+="git diff"
fi
run_cmd "${cmd}"
done
}
push_repo() {
if [[ ${dry_run} -eq 1 ]]; then
dry="-n"
elif [[ ${push_repo} -ne 1 ]]; then
return
fi
run_cmd "rsync -vrtlh --delete-before ${repo_basepath}/${repo_name} ${package_backup_dir} webfaction:/home/jalvarez/webapps/default/ ${dry}"
}
push_repo
if [[ ${mode} == "" ]]; then
exit
fi
get_kernel_update_funcs
debug_print_default_vars
export SCRIPT_DIR MODE MODE_NAME BUILD SIGN SOURCES UPDATE_PKGBUILDS
source_safe "src/kernels/${MODE_NAME}.sh"
export script_dir mode kernel_name
source_safe "src/kernels/${kernel_name}.sh"
for func in "${UPDATE_FUNCS[@]}"; do
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

@ -1,4 +1,4 @@
#!/bin/bash -e
#!/bin/bash
#
@ -6,28 +6,26 @@
#
NAME=$(basename $0)
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
args=("$@")
script_name=$(basename $0)
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
repo_name="" # The destination repo for the packages
package_list=() # A list of packages to add. Array items are in the form of "name;pkg.tar.xz;repo_path".
package_src_list=() # A list of package sources to move
package_exist_list=()
if ! source ${SCRIPT_DIR}/lib.sh; then
if ! source ${script_dir}/lib.sh; then
echo "!! ERROR !! -- Could not load lib.sh!"
exit 1
exit 155
fi
source_safe "${SCRIPT_DIR}/conf.sh"
# setup signal traps
trap "trap_quit" TERM HUP QUIT
trap "trap_abort" INT
trap "trap_usr1" USR1
trap "trap_exit" EXIT
source_safe "${script_dir}/conf.sh"
usage() {
echo "${NAME} - Adds the compiled packages to the archzfs repo."
echo "${script_name} - Adds the compiled packages to the archzfs repo."
echo
echo "Usage: ${NAME} [options] [mode] [repo] [package [...]]"
echo "Usage: ${script_name} [options] (mode) (repo)"
echo
echo "Options:"
echo
@ -37,9 +35,11 @@ usage() {
echo
echo "Modes:"
echo
echo " std Use the standard packages. Used by default."
echo " git Use the git packages."
echo " lts Use the lts packages."
for ml in "${mode_list[@]}"; do
mn=$(echo ${ml} | cut -f2 -d:)
md=$(echo ${ml} | cut -f3 -d:)
echo -e " ${mn} ${md}"
done
echo
echo "Repository target:"
echo
@ -48,252 +48,178 @@ usage() {
echo
echo "Example Usage:"
echo
echo " ${NAME} :: Add standard packages to the archzfs repo."
echo " ${NAME} lts -n -d :: Show output commands and debug info."
echo " ${NAME} git package.tar.xz :: Add package.tar.xz to the archzfs repo."
echo " ${NAME} gts *.tar.xz :: Add *.tar.xz to the archzfs repo."
trap - EXIT # Prevents exit log output
echo " ${script_name} lts azfs -n -d :: Show output commands and debug info."
exit 155
}
ARGS=("$@")
for (( a = 0; a < $#; a++ )); do
if [[ ${ARGS[$a]} == "std" ]]; then
MODE_STD=1
MODE="std"
elif [[ ${ARGS[$a]} == "git" ]]; then
MODE_STD=0
MODE_GIT=1
MODE="git"
elif [[ ${ARGS[$a]} == "lts" ]]; then
MODE_STD=0
MODE_LTS=1
MODE="lts"
elif [[ ${ARGS[$a]} == "azfs" ]]; then
REPO="archzfs"
elif [[ ${ARGS[$a]} == "test" ]]; then
REPO="archzfs-testing"
elif [[ ${ARGS[$a]} == "-n" ]]; then
DRY_RUN=1
elif [[ ${ARGS[$a]} == "-d" ]]; then
DEBUG=1
elif [[ ${ARGS[$a]} == "-h" ]]; then
usage;
exit 0;
fi
done
generate_mode_list
if [[ $# -lt 1 ]]; then
usage;
exit 0;
usage
fi
if [[ ${REPO} == "" ]]; then
error "No destination repo specified!"
exit 1
for (( a = 0; a < $#; a++ )); do
if [[ ${args[$a]} == "azfs" ]]; then
repo_name="archzfs"
elif [[ ${args[$a]} == "test" ]]; then
# TODO: NOT IMPLMENTED YET
repo_name="archzfs-testing"
elif [[ ${args[$a]} == "-n" ]]; then
dry_run=1
elif [[ ${args[$a]} == "-d" ]]; then
debug_flag=1
elif [[ ${args[$a]} == "-h" ]]; then
usage
else
check_mode "${args[$a]}"
debug "have mode '${mode}'"
fi
done
if [[ $# -lt 1 ]]; then
usage
fi
if [[ ${MODE} == "" ]]; then
if [[ ${mode} == "" ]]; then
echo
error "A mode must be selected!"
usage;
exit 0;
usage
fi
msg "$(date) :: ${NAME} started..."
# The abs path to the repo
REPO_TARGET=${REPO_BASEPATH}/${REPO}
# Set the kernel version
if [[ ${MODE_STD} -eq 1 ]]; then
KERNEL_VERSION=$(kernel_version_full ${STD_KERNEL_VERSION})
KERNEL_VERSION_NO_HYPHEN=$(kernel_version_full_no_hyphen ${STD_KERNEL_VERSION})
PKGVER_MATCH="${ZOL_VERSION}_${KERNEL_VERSION_NO_HYPHEN}-${STD_PKGREL}"
elif [[ ${MODE_LTS} -eq 1 ]]; then
KERNEL_VERSION=$(kernel_version_full ${LTS_KERNEL_VERSION})
KERNEL_VERSION_NO_HYPHEN=$(kernel_version_full_no_hyphen ${LTS_KERNEL_VERSION})
PKGVER_MATCH="${ZOL_VERSION}_${KERNEL_VERSION_NO_HYPHEN}-${LTS_PKGREL}"
elif [[ ${MODE_GIT} -eq 1 ]]; then
KERNEL_VERSION=$(kernel_version_full ${GIT_KERNEL_VERSION})
KERNEL_VERSION_NO_HYPHEN=$(kernel_version_full_no_hyphen ${GIT_KERNEL_VERSION})
PKGVER_MATCH="${ZOL_VERSION}.*${KERNEL_VERSION_NO_HYPHEN}-${GIT_PKGREL}"
if [[ ${repo_name} == "" ]]; then
error "No destination repo specified!"
exit 155
fi
debug "DRY_RUN: "${DRY_RUN}
debug "REPO: "${REPO}
debug "REPO_TARGET: ${REPO_TARGET}"
debug "KERNEL_VERSION: ${KERNEL_VERSION}"
debug "KERNEL_VERSION_NO_HYPHEN: ${KERNEL_VERSION_NO_HYPHEN}"
debug "PKGVER_MATCH: ${PKGVER_MATCH}"
# A list of packages to install. Pulled from the command line.
pkgs=()
# Extract any packages from the arguments passed to the script
for arg in "$@"; do
if [[ ${arg} =~ pkg.tar.xz$ ]]; then
pkgs+=("${pkgs[@]}" ${arg})
fi
done
repo_package_list() {
msg "Generating a list of packages to add..."
debug_print_array "pkg_list" "${pkg_list[@]}"
if [[ ${REPO} != "" ]]; then
msg "Creating a list of packages to add..."
local pkgs=()
# Get the local packages if no packages were passed to the script
if [[ "${#pkgs[@]}" -eq 0 ]]; then
# Get packages from the backup directory if the repo is demz-repo-archiso
run_cmd_show_and_capture_output_no_dry_run "find packages/${MODE}/ -iname '*${KERNEL_VERSION_NO_HYPHEN}*.pkg.tar.xz'"
for pkg in ${RUN_CMD_OUTPUT}; do
pkgs+=(${pkg})
done
fi
# A list of packages to add. The strings are in the form of
# "name;pkg.tar.xz;repo_path". There must be no spaces.
pkg_list=()
# A list of package sources to move
pkg_src_list=()
# Get packages from the backup directory
path="packages/${kernel_name}/{$(printf '%s,' ${pkg_list[@]} | cut -d ',' -f 1-${#pkg_list[@]})}/"
run_cmd_show_and_capture_output_no_dry_run "find ${path} -iname '*${kernel_version_full_pkgver}*.pkg.tar.xz'"
for pkg in ${run_cmd_output}; do
pkgs+=(${pkg})
done
for pkg in ${pkgs[@]}; do
arch=$(package_arch_from_path ${pkg})
name=$(package_name_from_path ${pkg})
vers=$(package_version_from_path ${pkg})
debug "Version match check: arch: ${arch} name: ${name} vers: ${vers} PKGVER_MATCH: ${PKGVER_MATCH}"
match="${zol_version::-1}.*${kernel_version_full_pkgver}-${zfs_pkgrel}"
debug "Version match check: arch: ${arch} name: ${name} vers: ${vers} vers_match: ${match}"
if ! [[ ${vers} =~ ^${PKGVER_MATCH} ]]; then
if ! [[ ${vers} =~ ^${match} ]]; then
debug "Version mismatch!"
continue
fi
if [[ ${arch} == "any" ]]; then
repos=`realpath ${REPO_TARGET}/x86_64`
for repo in ${repos}; do
debug "Package: pkgname: ${name} pkgver: ${vers} pkgpath: ${pkg} pkgdest: ${REPO_TARGET}/${arch}"
# Each index is [name, version, pkgpath, pkgdest]
pkg_list+=("${name};${vers};${pkg};${repo}")
done
continue
fi
debug "Using: pkgname: ${name} pkgver: ${vers} pkgpath: ${pkg} pkgdest: ${repo_target}/${arch}"
package_list+=("${name};${vers};${pkg};${repo_target}/${arch}")
package_src_list+=("packages/${kernel_name}/${name}/${name}-${vers}.src.tar.gz")
done
debug "Using: pkgname: ${name} pkgver: ${vers} pkgpath: ${pkg} pkgdest: ${REPO_TARGET}/${arch}"
pkg_list+=("${name};${vers};${pkg};${REPO_TARGET}/${arch}")
debug_print_array "package_list" ${package_list[@]}
}
litem="packages/${MODE}/${name}/${name}-${vers}.src.tar.gz;${REPO_TARGET}/${arch}"
debug "Source: srcname: ${name}-${vers}.src.tar.gz srcdest: ${REPO_TARGET}/${arch}"
pkg_src_list+=(${litem})
repo_package_backup() {
run_cmd_show_and_capture_output_no_dry_run "find ${repo_target} -type f -iname '${name}*.pkg.tar.xz'"
for x in ${run_cmd_output}; do
ename=$(package_name_from_path ${x})}
evers=$(package_version_from_path ${x})}
if [[ ${ename} == ${name} && ${evers} != ${vers} ]]; then
# The '*' globs the signatures and package sources
epkg="${repo_name}/${ename}-${evers}*"
package_exist_list+=(${epkg})
fi
done
debug_print_array "package_exist_list" ${package_exist_list[@]}
}
if [[ ${#pkg_list[@]} == 0 ]]; then
repo_add() {
if [[ ${#package_list[@]} == 0 ]]; then
error "No packages to process!"
exit 1
fi
exist_pkg_mv_list=()
new_pkg_cp_list=()
pkg_add_list=()
src_mv_list=()
local pkg_cp_list=()
local pkg_add_list=()
local dest=""
local arch="x86_64"
for ipkg in ${pkg_list[@]}; do
for ipkg in ${package_list[@]}; do
IFS=';' read -a pkgopt <<< "${ipkg}"
name="${pkgopt[0]}"
vers="${pkgopt[1]}"
pkgp="${pkgopt[2]}"
repo="${pkgopt[3]}"
msg2 "Processing package ${name}-${vers} to ${repo}"
[[ ! -d ${repo} ]] && run_cmd "mkdir -p ${repo}"
# Move the old packages to backup
for x in $(find ${repo} -type f -iname "${name}*.pkg.tar.xz"); do
ename=$(package_name_from_path ${x})}
evers=$(package_version_from_path ${x})}
if [[ ${ename} == ${name} && ${evers} != ${vers} ]]; then
# The '*' globs the signatures and package sources
epkg="${repo}/${ename}-${evers}*"
debug "epkg: ${epkg}"
exist_pkg_mv_list+=(${epkg})
fi
done
dest="${pkgopt[3]}"
msg2 "Processing package ${name}-${vers} to ${dest}"
[[ ! -d ${dest} ]] && run_cmd "mkdir -p ${dest}"
debug "name: ${name} vers: ${vers} pkgp: ${pkgp} dest: ${dest}"
# The * is to catch the signature
new_pkg_cp_list+=("${pkgp}*;${repo}")
pkg_cp_list+=("${pkgp}*")
bname=$(basename ${pkgp})
pkg_add_list+=("${repo}/${bname};${repo}")
pkg_add_list+=("${dest}/${bname}")
done
# Build mv list with unique source packages since i686 and x86_64 both have identical source packages. If we attempt to
# move with identical file names, cp will fail with the "cp: will not overwrite just-created" error.
exist_pkg_mv_list_uniq=()
for ((i = 0; i < ${#exist_pkg_mv_list[@]}; i++)); do
if [[ ${exist_pkg_mv_list[$i]} != *src.tar.gz ]]; then
exist_pkg_mv_list_uniq+=(${exist_pkg_mv_list[$i]})
continue
fi
done
debug_print_array "pkg_cp_list" "${pkg_cp_list[@]}"
debug_print_array "pkg_add_list" "${pkg_add_list[@]}"
msg "Performing file operations..."
msg "Copying the new ${arch} packages to the repo..."
# Remove the existing packages in the repo path
if [[ ${exist_pkg_mv_list[@]} -ne 0 ]]; then
run_cmd "rm -f ${exist_pkg_mv_list[*]}"
run_cmd "cp -fv ${pkg_cp_list[@]} ${package_src_list[@]} ${repo_target}/${arch}/"
if [[ ${run_cmd_return} -ne 0 ]]; then
error "An error occurred copying the packages to the repo!"
exit 1
fi
for arch in "x86_64"; do
msg "Copying the new ${arch} packages to the repo..."
cp_list="" # The packages to copy in one string
ra_list="" # The packages to add to the repo in one string
repo="" # The destination repo
# Create the command file lists from the arrays
for pkg in "${new_pkg_cp_list[@]}"; do
if [[ "${pkg}" == *${arch}* ]]; then
cp_list="$cp_list "$(echo "${pkg}" | cut -d \; -f 1)
repo=$(echo "${pkg}" | cut -d \; -f 2)
ra=$(echo "${pkg}" | cut -d \; -f 1 | xargs basename)
ra_list="${ra_list} ${repo}/${ra%?}"
fi
done
if [[ ${cp_list} == "" ]]; then
warning "No packages to copy!"
continue
fi
run_cmd "repo-add -k ${gpg_sign_key} -s -v ${repo_target}/${arch}/${repo_name}.db.tar.xz ${pkg_add_list[@]}"
if [[ ${run_cmd_return} -ne 0 ]]; then
error "An error occurred adding the package to the repo!"
exit 1
fi
}
run_cmd "cp -fv ${cp_list} ${repo}/"
run_cmd "repo-add -k ${GPG_SIGN_KEY} -s -v ${repo}/${REPO}.db.tar.xz ${ra_list}"
if [[ ${RUN_CMD_RETURN} -ne 0 ]]; then
error "An error occurred adding the package to the repo!"
exit 1
fi
done
# Copy package sources
msg "Copy package sources"
for arch in "x86_64"; do
src_cp_list=()
for src in "${pkg_src_list[@]}"; do
if [[ "${src}" == *${arch}* ]]; then
debug "SRC='${src}'"
src_cp_list="${src_cp_list} "$(echo "${src}" | cut -d \; -f 1)
repo=$(echo "${src}" | cut -d \; -f 2)
fi
done
run_cmd "cp -fv ${src_cp_list} ${repo}/"
done
fi
msg "$(date) :: ${script_name} started..."
# The abs path to the repo
repo_target=${repo_basepath}/${repo_name}
get_kernel_update_funcs
debug_print_default_vars
debug "repo_name: ${repo_name}"
debug "repo_target: ${repo_target}"
source_safe "src/kernels/${kernel_name}.sh"
for func in "${update_funcs[@]}"; do
debug "Evaluating '${func}'"
"${func}"
repo_package_list
done
# These can be commented out individually
# repo_package_backup
repo_add

@ -1,4 +1,4 @@
#!/bin/bash -e
#!/bin/bash
#
@ -8,28 +8,22 @@
#
NAME=$(basename $0)
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
args=("$@")
script_name=$(basename $0)
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if ! source ${SCRIPT_DIR}/lib.sh; then
if ! source ${script_dir}/lib.sh; then
echo "!! ERROR !! -- Could not load lib.sh!"
exit 1
exit 155
fi
source_safe "${SCRIPT_DIR}/conf.sh"
# setup signal traps
trap "trap_quit" TERM HUP QUIT
trap "trap_abort" INT
trap "trap_usr1" USR1
trap "trap_exit" EXIT
source_safe "${script_dir}/conf.sh"
usage() {
echo "${NAME} - A cheap webpage scraper."
echo "${script_name} - A cheap webpage scraper."
echo
echo "Usage: ${NAME} [options]"
echo "Usage: ${script_name} [options]"
echo
echo "Options:"
echo
@ -39,29 +33,28 @@ usage() {
echo
echo "Examples:"
echo
echo " ${NAME} -d :: Show debug output."
echo " ${NAME} -n :: Don't run commands, but show output."
trap - EXIT # Prevents exit log output
echo " ${script_name} -d :: Show debug output."
echo " ${script_name} -n :: Don't run commands, but show output."
exit 155
}
ARGS=("$@")
for (( a = 0; a < $#; a++ )); do
if [[ ${ARGS[$a]} == "-n" ]]; then
DRY_RUN=1
elif [[ ${ARGS[$a]} == "-d" ]]; then
DEBUG=1
elif [[ ${ARGS[$a]} == "-h" ]]; then
usage;
exit 0;
if [[ ${args[$a]} == "-n" ]]; then
dry_run=1
elif [[ ${args[$a]} == "-d" ]]; then
debug_flag=1
elif [[ ${args[$a]} == "-h" ]]; then
usage
fi
done
msg "$(date) :: ${NAME} started..."
msg "$(date) :: ${script_name} started..."
CHECK_WEBPAGE_RETVAL=0
check_webpage_retval=0
has_error=0
check_webpage() {
@ -74,32 +67,32 @@ check_webpage() {
run_cmd_no_output "curl -sL ${1}"
if [[ ${DRY_RUN} -eq 1 ]]; then
if [[ ${dry_run} -eq 1 ]]; then
return
fi
if [[ $(echo ${RUN_CMD_OUTPUT} | \grep -q "504 Gateway Timeout"; echo $?) -eq 0 ]]; then
CHECK_WEBPAGE_RETVAL=-1
if [[ $(echo ${run_cmd_output} | \grep -q "504 Gateway Timeout"; echo $?) -eq 0 ]]; then
check_webpage_retval=-1
return
elif [[ $(echo ${RUN_CMD_OUTPUT} | \grep -q "503 Service Unavailable"; echo $?) -eq 0 ]]; then
CHECK_WEBPAGE_RETVAL=-1
elif [[ $(echo ${run_cmd_output} | \grep -q "503 Service Unavailable"; echo $?) -eq 0 ]]; then
check_webpage_retval=-1
return
elif [[ ${RUN_CMD_OUTPUT} == "RETVAL: 7" ]]; then
CHECK_WEBPAGE_RETVAL=-1
elif [[ ${run_cmd_output} == "RETVAL: 7" ]]; then
check_webpage_retval=-1
return
fi
SCRAPED_STRING=$(echo "${RUN_CMD_OUTPUT}" | \grep -Po -m 1 "${2}")
debug "Got \"${SCRAPED_STRING}\" from webpage."
local scraped_string=$(echo "${run_cmd_output}" | \grep -Po -m 1 "${2}")
debug "Got \"${scraped_string}\" from webpage."
if [[ ${SCRAPED_STRING} != "$3" ]]; then
error "Checking '$1' expected '$3' got '${SCRAPED_STRING}'"
if [[ ${scraped_string} != "$3" ]]; then
error "Checking '$1' expected '$3' got '${scraped_string}'"
debug "Returning 1 from check_webpage()"
CHECK_WEBPAGE_RETVAL=1
check_webpage_retval=1
return
fi
CHECK_WEBPAGE_RETVAL=0
check_webpage_retval=0
return
}
@ -107,23 +100,20 @@ check_webpage() {
check_result() {
# $1 current line
# $2 changed line
if [[ ${CHECK_WEBPAGE_RETVAL} -eq 0 ]]; then
if [[ ${check_webpage_retval} -eq 0 ]]; then
msg2 "The $1 version is current."
elif [[ ${CHECK_WEBPAGE_RETVAL} -eq 1 ]]; then
elif [[ ${check_webpage_retval} -eq 1 ]]; then
error "The $2 is out-of-date!"
HAS_ERROR=1
elif [[ ${CHECK_WEBPAGE_RETVAL} -eq -1 ]]; then
has_error=1
elif [[ ${check_webpage_retval} -eq -1 ]]; then
warning "The $2 package page was unreachable!"
else
error "Check returned ${CHECK_WEBPAGE_RETVAL}"
HAS_ERROR=1
error "Check returned ${check_webpage_retval}"
has_error=1
fi
}
HAS_ERROR=0
# Bail if no internet
# Please thank Comcast for this requirement...
if [[ $(ping -w 1 -c 1 8.8.8.8 &> /dev/null; echo $?) != 0 ]]; then
@ -169,7 +159,7 @@ check_zol_version() {
# Check ZFSonLinux.org
#
msg "Checking zfsonlinux.org for new versions..."
check_webpage "http://zfsonlinux.org/" "(?<=downloads/zfsonlinux/spl/spl-)[\d\.]+(?=.tar.gz)" "${ZOL_VERSION}"
check_webpage "http://zfsonlinux.org/" "(?<=downloads/zfsonlinux/spl/spl-)[\d\.]+(?=.tar.gz)" "${zol_version}"
check_result "ZOL stable version" "ZOL stable version"
}
@ -186,6 +176,6 @@ check_zol_version
# This is the end
# My only friend, the end
#
if [[ ${HAS_ERROR} -eq 1 ]]; then
if [[ ${has_error} -eq 1 ]]; then
exit 1;
fi

@ -3,7 +3,7 @@ mode_name="lts"
mode_desc="Select and use the packages for the linux-lts kernel"
# Kernel versions for LTS packages
pkgrel="3"
pkgrel="4"
kernel_version="4.4.8-1"
kernel_version_next="4.5"
@ -27,7 +27,7 @@ header="\
#"
update_linux_lts_pkgbuilds() {
pkg_list="spl-utils-linux-lts spl-linux-lts zfs-utils-linux-lts zfs-linux-lts"
pkg_list=("spl-utils-linux-lts" "spl-linux-lts" "zfs-utils-linux-lts" "zfs-linux-lts")
kernel_version_full=$(kernel_version_full ${kernel_version})
kernel_version_full_pkgver=$(kernel_version_full_no_hyphen ${kernel_version})
kernel_version_major=${kernel_version%-*}
@ -41,10 +41,10 @@ update_linux_lts_pkgbuilds() {
spl_pkgname="spl-linux-lts"
zfs_utils_pkgname="zfs-utils-linux-lts"
zfs_pkgname="zfs-linux-lts"
spl_utils_pkgbuild_path="packages/${MODE_NAME}/${spl_utils_pkgname}"
spl_pkgbuild_path="packages/${MODE_NAME}/${spl_pkgname}"
zfs_utils_pkgbuild_path="packages/${MODE_NAME}/${zfs_utils_pkgname}"
zfs_pkgbuild_path="packages/${MODE_NAME}/${zfs_pkgname}"
spl_utils_pkgbuild_path="packages/${kernel_name}/${spl_utils_pkgname}"
spl_pkgbuild_path="packages/${kernel_name}/${spl_pkgname}"
zfs_utils_pkgbuild_path="packages/${kernel_name}/${zfs_utils_pkgname}"
zfs_pkgbuild_path="packages/${kernel_name}/${zfs_pkgname}"
spl_src_target="http://archive.zfsonlinux.org/downloads/zfsonlinux/spl/spl-${zol_version}.tar.gz"
zfs_src_target="http://archive.zfsonlinux.org/downloads/zfsonlinux/zfs/zfs-${zol_version}.tar.gz"
spl_workdir="\${srcdir}/spl-${zol_version}"

@ -3,7 +3,7 @@ mode_name="std"
mode_desc="Select and use the packages for the default linux kernel"
# Kernel versions for default ZFS packages
pkgrel="3"
pkgrel="4"
kernel_version="4.5.1-1"
kernel_version_next="4.6"
@ -40,7 +40,7 @@ header="\
#"
update_linux_pkgbuilds() {
pkg_list="spl-utils-linux spl-linux zfs-utils-linux zfs-linux"
pkg_list=("spl-utils-linux" "spl-linux" "zfs-utils-linux" "zfs-linux")
kernel_version_full=$(kernel_version_full ${kernel_version})
kernel_version_full_pkgver=$(kernel_version_full_no_hyphen ${kernel_version})
kernel_version_major=${kernel_version%-*}
@ -55,10 +55,10 @@ update_linux_pkgbuilds() {
zfs_utils_pkgname="zfs-utils-linux"
zfs_pkgname="zfs-linux"
# Paths are relative to build.sh
spl_utils_pkgbuild_path="packages/${MODE_NAME}/${spl_utils_pkgname}"
spl_pkgbuild_path="packages/${MODE_NAME}/${spl_pkgname}"
zfs_utils_pkgbuild_path="packages/${MODE_NAME}/${zfs_utils_pkgname}"
zfs_pkgbuild_path="packages/${MODE_NAME}/${zfs_pkgname}"
spl_utils_pkgbuild_path="packages/${kernel_name}/${spl_utils_pkgname}"
spl_pkgbuild_path="packages/${kernel_name}/${spl_pkgname}"
zfs_utils_pkgbuild_path="packages/${kernel_name}/${zfs_utils_pkgname}"
zfs_pkgbuild_path="packages/${kernel_name}/${zfs_pkgname}"
spl_src_target="http://archive.zfsonlinux.org/downloads/zfsonlinux/spl/spl-${zol_version}.tar.gz"
zfs_src_target="http://archive.zfsonlinux.org/downloads/zfsonlinux/zfs/zfs-${zol_version}.tar.gz"
spl_workdir="\${srcdir}/spl-${zol_version}"
@ -68,7 +68,7 @@ update_linux_pkgbuilds() {
}
update_linux_git_pkgbuilds() {
pkg_list="spl-utils-linux-git spl-linux-git zfs-utils-linux-git zfs-linux-git"
pkg_list=("spl-utils-linux-git" "spl-linux-git" "zfs-utils-linux-git" "zfs-linux-git")
kernel_version=${kernel_version_git}
kernel_version_full=$(kernel_version_full ${kernel_version_git})
kernel_version_full_pkgver=$(kernel_version_full_no_hyphen ${kernel_version_git})
@ -86,10 +86,10 @@ update_linux_git_pkgbuilds() {
spl_pkgname="spl-linux-git"
zfs_utils_pkgname="zfs-utils-linux-git"
zfs_pkgname="zfs-linux-git"
spl_utils_pkgbuild_path="packages/${MODE_NAME}/${spl_utils_pkgname}"
spl_pkgbuild_path="packages/${MODE_NAME}/${spl_pkgname}"
zfs_utils_pkgbuild_path="packages/${MODE_NAME}/${zfs_utils_pkgname}"
zfs_pkgbuild_path="packages/${MODE_NAME}/${zfs_pkgname}"
spl_utils_pkgbuild_path="packages/${kernel_name}/${spl_utils_pkgname}"
spl_pkgbuild_path="packages/${kernel_name}/${spl_pkgname}"
zfs_utils_pkgbuild_path="packages/${kernel_name}/${zfs_utils_pkgname}"
zfs_pkgbuild_path="packages/${kernel_name}/${zfs_pkgname}"
spl_src_target="git+${spl_git_url}"
if [[ ${spl_git_commit} != "" ]]; then
spl_src_target="git+${spl_git_url}#commit=${spl_git_commit}"

@ -24,7 +24,7 @@ check_initramfs() {
echo '>>> "hooks" list and then regenerate the initial ramdisk.'
else
echo ">>> Generating initial ramdisk, using mkinitcpio. Please wait..."
mkinitcpio -p ${MODE_NAME}
mkinitcpio -p ${kernel_name}
fi
fi
}

@ -6,28 +6,22 @@
#
NAME=$(basename $0)
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
args=("$@")
script_name=$(basename $0)
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if ! source ${SCRIPT_DIR}/lib.sh; then
if ! source ${script_dir}/lib.sh; then
echo "!! ERROR !! -- Could not load lib.sh!"
exit 1
exit 155
fi
source_safe "${SCRIPT_DIR}/conf.sh"
# setup signal traps
trap "trap_quit" TERM HUP QUIT
trap "trap_abort" INT
trap "trap_usr1" USR1
trap "trap_exit" EXIT
source_safe "${script_dir}/conf.sh"
usage() {
echo "${NAME} - Compares repository hashes."
echo "${script_name} - Compares repository hashes."
echo
echo "Usage: ${NAME} [options]"
echo "Usage: ${script_name} [options]"
echo
echo "Options:"
echo
@ -36,59 +30,51 @@ usage() {
echo
echo "Examples:"
echo
echo " ${NAME} -d :: Show debug output."
trap - EXIT # Prevents exit log output
echo " ${script_name} -d :: Show debug output."
exit 155
}
ARGS=("$@")
for (( a = 0; a < $#; a++ )); do
if [[ ${ARGS[$a]} == "-d" ]]; then
DEBUG=1
elif [[ ${ARGS[$a]} == "-h" ]]; then
usage;
exit 0;
if [[ ${args[$a]} == "-d" ]]; then
debug_flag=1
elif [[ ${args[$a]} == "-h" ]]; then
usage
fi
done
compute_local_repo_hash() {
# $1: The repository to compute
# Sets LOCAL_REPO_HASH
# Sets local_repo_hash
msg2 "Computing local $1 repository hashes..."
run_cmd "cd $REPO_BASEPATH; sha256sum $1/*/*"
if [[ ${RUN_CMD_RETURN} != 0 ]]; then
run_cmd "cd ${repo_basepath}; sha256sum $1/*/*"
if [[ ${run_cmd_return} != 0 ]]; then
error "Could not run local hash!"
exit 1
fi
LFILES=$(echo ${RUN_CMD_OUTPUT} | sort -r)
LOCAL_REPO_HASH=$(echo "$LFILES" | sha256sum | cut -f 1 -d' ')
msg2 "Local hash: $LOCAL_REPO_HASH"
lfiles=$(echo ${run_cmd_output} | sort -r)
local_repo_hash=$(echo "${lfiles}" | sha256sum | cut -f 1 -d' ')
msg2 "Local hash: ${local_repo_hash}"
}
compute_remote_repo_hash() {
# $1: The repository to compute
# Sets REMOTE_REPO_HASH
# Sets remote_repo_hash
msg2 "Computing remote $1 repository hashes..."
run_cmd "ssh $REMOTE_LOGIN 'cd webapps/default; sha256sum $1/*/*'"
if [[ ${RUN_CMD_RETURN} != 0 ]]; then
run_cmd "ssh ${REMOTE_LOGIN} 'cd webapps/default; sha256sum $1/*/*'"
if [[ ${run_cmd_return} != 0 ]]; then
error "Could not run remote hash!"
exit 1
fi
RFILES=$(echo ${RUN_CMD_OUTPUT} | sort -r)
REMOTE_REPO_HASH=$(echo "$RFILES" | sha256sum | cut -f 1 -d' ')
msg2 "Remote hash: $REMOTE_REPO_HASH"
rfiles=$(echo ${run_cmd_output} | sort -r)
remote_repo_hash=$(echo "${rfiles}" | sha256sum | cut -f 1 -d' ')
msg2 "Remote hash: $remote_repo_hash"
}
msg "$(date) :: ${NAME} started..."
msg "$(date) :: ${script_name} started..."
# Bail if no internet
@ -98,23 +84,25 @@ if [[ $(ping -w 1 -c 1 8.8.8.8 &> /dev/null; echo $?) != 0 ]]; then
fi
HAS_ERROR=0
has_error=0
local_repo_hash=""
remote_repo_hash=""
for REPO in 'archzfs'; do
msg "Checking ${REPO}..."
# compare_repo $REPO
compute_local_repo_hash $REPO
compute_remote_repo_hash $REPO
if [[ $LOCAL_REPO_HASH != $REMOTE_REPO_HASH ]]; then
error "The $REPO is out of sync!"
HAS_ERROR=1
for repo in 'archzfs'; do
msg "Checking ${repo}..."
# compare_repo $repo
compute_local_repo_hash ${repo}
compute_remote_repo_hash ${repo}
if [[ ${local_repo_hash} != ${remote_repo_hash} ]]; then
error "The ${repo} is out of sync!"
has_error=1
continue
fi
msg2 "$REPO is in sync"
msg2 "${repo} is in sync"
done
if [[ $HAS_ERROR -eq 1 ]]; then
exit 1;
if [[ ${has_error} -eq 1 ]]; then
exit 1
fi

Loading…
Cancel
Save