index : devtools32 | |
Archlinux32 fork of devtools | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | arch-nspawn.in | 12 | ||||
-rw-r--r-- | archbuild.in | 10 | ||||
-rw-r--r-- | archrelease.in | 2 | ||||
-rw-r--r-- | checkpkg.in | 4 | ||||
-rw-r--r-- | crossrepomove.in | 8 | ||||
-rw-r--r-- | lddd.in | 4 | ||||
-rw-r--r-- | lib/common.sh | 68 | ||||
-rw-r--r-- | makechrootpkg.in | 34 | ||||
-rw-r--r-- | mkarchroot.in | 4 | ||||
-rw-r--r-- | rebuildpkgs.in | 14 |
diff --git a/arch-nspawn.in b/arch-nspawn.in index 6900382..94002f1 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -32,7 +32,7 @@ while getopts 'hC:M:c:' arg; do M) makepkg_conf="$OPTARG" ;; c) cache_dir="$OPTARG" ;; h|?) usage ;; - *) error "invalid argument '$arg'"; usage ;; + *) error "invalid argument '%s'" "$arg"; usage ;; esac done shift $(($OPTIND - 1)) @@ -84,7 +84,7 @@ umask 0022 # Sanity check if [[ ! -f "$working_dir/.arch-chroot" ]]; then - die "'%s' does not appear to be a Arch chroot." "$working_dir" + die "'%s' does not appear to be an Arch chroot." "$working_dir" elif [[ $(cat "$working_dir/.arch-chroot") != $CHROOT_VERSION ]]; then die "chroot '%s' is not at version %s. Please rebuild." "$working_dir" "$CHROOT_VERSION" fi @@ -96,8 +96,14 @@ eval $(grep '^CARCH=' "$working_dir/etc/makepkg.conf") machine_name="${working_dir//[![:alnum:]_-]/-}" machine_name="${machine_name#-}" +#HOST_NAME_MAX="$(printf '%s\n' '#include <limits.h>' 'HOST_NAME_MAX'|cpp -|sed -n '$p')" +HOST_NAME_MAX=64 +if [[ ${#machine_name} -gt "$HOST_NAME_MAX" ]]; then + machine_name="${machine_name:(-${HOST_NAME_MAX})}" + machine_name="${machine_name#-}" +fi -exec ${CARCH:+setarch "$CARCH"} systemd-nspawn 2>/dev/null \ +exec ${CARCH:+setarch "$CARCH"} systemd-nspawn \ -D "$working_dir" \ --machine "$machine_name" \ "${mount_args[@]}" \ diff --git a/archbuild.in b/archbuild.in index b1c96f9..ec70b59 100644 --- a/archbuild.in +++ b/archbuild.in @@ -45,20 +45,20 @@ if (( EUID )); then fi if ${clean_first} || [[ ! -d "${chroots}/${repo}-${arch}" ]]; then - msg "Creating chroot for [${repo}] (${arch})..." + msg "Creating chroot for [%s] (%s)..." "${repo}" "${arch}" for copy in "${chroots}/${repo}-${arch}"/*; do [[ -d $copy ]] || continue - msg2 "Deleting chroot copy '$(basename "${copy}")'..." + msg2 "Deleting chroot copy '%s'..." "$(basename "${copy}")" - lock 9 "$copydir.lock" "Locking chroot copy '$copy'" + lock 9 "$copy.lock" "Locking chroot copy '%s'" "$copy" if [[ "$(stat -f -c %T "${copy}")" == btrfs ]]; then { type -P btrfs && btrfs subvolume delete "${copy}"; } &>/dev/null fi rm -rf --one-file-system "${copy}" done - exec 9>&- + lock_close 9 rm -rf --one-file-system "${chroots}/${repo}-${arch}" mkdir -p "${chroots}/${repo}-${arch}" @@ -76,5 +76,5 @@ else pacman -Syu --noconfirm || abort fi -msg "Building in chroot for [${repo}] (${arch})..." +msg "Building in chroot for [%s] (%s)..." "${repo}" "${arch}" exec makechrootpkg -r "${chroots}/${repo}-${arch}" "${makechrootpkg_args[@]}" diff --git a/archrelease.in b/archrelease.in index 6f52dbc..4ac55db 100644 --- a/archrelease.in +++ b/archrelease.in @@ -58,7 +58,7 @@ done known_files=("${known_files[@]/%/@}") for tag in "$@"; do - stat_busy "Copying ${trunk} to ${tag}" + stat_busy "Copying %s to %s" "${trunk}" "${tag}" if [[ -d repos/$tag ]]; then declare -a trash diff --git a/checkpkg.in b/checkpkg.in index ccbbecd..81e7184 100644 --- a/checkpkg.in +++ b/checkpkg.in @@ -70,8 +70,8 @@ for _pkgname in "${pkgname[@]}"; do echo "${i}: " "$(objdump -p "$TEMPDIR/$i" | grep SONAME)" done else - msg "No soname differences for $_pkgname." + msg "No soname differences for %s." "$_pkgname" fi done -msg "Files saved to $TEMPDIR" +msg "Files saved to %s" "$TEMPDIR" diff --git a/crossrepomove.in b/crossrepomove.in index 912504f..ac08c67 100644 --- a/crossrepomove.in +++ b/crossrepomove.in @@ -39,13 +39,13 @@ setup_workdir pushd $WORKDIR >/dev/null -msg "Downloading sources for ${pkgbase}" +msg "Downloading sources for %s" "${pkgbase}" svn -q checkout -N "${target_svn}" target_checkout mkdir -p "target_checkout/${pkgbase}/repos" svn -q export "${source_svn}/${pkgbase}/trunk" "target_checkout/${pkgbase}/trunk" || die . "target_checkout/${pkgbase}/trunk/PKGBUILD" -msg "Downloading packages for ${pkgbase}" +msg "Downloading packages for %s" "${pkgbase}" for _arch in ${arch[@]}; do if [[ "${_arch[*]}" == 'any' ]]; then repo_arch='x86_64' @@ -59,7 +59,7 @@ for _arch in ${arch[@]}; do done done -msg "Adding ${pkgbase} to ${target_repo}" +msg "Adding %s to %s" "${pkgbase}" "${target_repo}" svn -q add "target_checkout/${pkgbase}" svn -q propset svn:keywords 'Id' "target_checkout/${pkgbase}/trunk/PKGBUILD" svn -q commit -m"${scriptname}: Moving ${pkgbase} from ${source_repo} to ${target_repo}" target_checkout @@ -69,7 +69,7 @@ popd >/dev/null ssh "${server}" "${target_dbscripts}/db-update" || die -msg "Removing ${pkgbase} from ${source_repo}" +msg "Removing %s from %s" "${pkgbase}" "${source_repo}" for _arch in ${arch[@]}; do ssh "${server}" "${source_dbscripts}/db-remove ${source_repo} ${_arch} ${pkgbase}" done @@ -16,7 +16,7 @@ TEMPDIR=$(mktemp -d --tmpdir lddd-script.XXXX) msg 'Go out and drink some tea, this will take a while :) ...' # Check ELF binaries in the PATH and specified dir trees. for tree in $PATH $libdirs $extras; do - msg2 "DIR $tree" + msg2 "DIR %s" "$tree" # Get list of files in tree. files=$(find $tree -type f ! -name '*.a' ! -name '*.la' ! -name '*.py*' ! -name '*.txt' ! -name '*.h' ! -name '*.ttf' ! \ @@ -45,4 +45,4 @@ done # clean list sort -u $TEMPDIR/pacman.txt >> $TEMPDIR/possible-rebuilds.txt -msg "Files saved to $TEMPDIR" +msg "Files saved to %s" "$TEMPDIR" diff --git a/lib/common.sh b/lib/common.sh index cb9db76..dff9b43 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -4,7 +4,7 @@ export LANG=C shopt -s extglob # check if messages are to be printed using color -unset ALL_OFF BOLD BLUE GREEN RED YELLOW +declare ALL_OFF= BOLD= BLUE= GREEN= RED= YELLOW= if [[ -t 2 ]]; then # prefer terminal safe colored and bold text when tput is supported if tput setaf 0 &>/dev/null; then @@ -42,30 +42,36 @@ msg2() { warning() { local mesg=$1; shift - printf "${YELLOW}==> WARNING:${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 + printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } error() { local mesg=$1; shift - printf "${RED}==> ERROR:${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 + printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } stat_busy() { local mesg=$1; shift - printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" >&2 + printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" "$@" >&2 } stat_done() { - printf "${BOLD}done${ALL_OFF}\n" >&2 + printf "${BOLD}$(gettext "done")${ALL_OFF}\n" >&2 } +_setup_workdir=false setup_workdir() { - [[ -z $WORKDIR ]] && WORKDIR=$(mktemp -d --tmpdir "${0##*/}.XXXXXXXXXX") + [[ -z ${WORKDIR:-} ]] && WORKDIR=$(mktemp -d --tmpdir "${0##*/}.XXXXXXXXXX") + _setup_workdir=true + trap 'trap_abort' INT QUIT TERM HUP + trap 'trap_exit' EXIT } cleanup() { - [[ -n $WORKDIR ]] && rm -rf "$WORKDIR" - [[ $1 ]] && exit $1 + if [[ -n ${WORKDIR:-} ]] && $_setup_workdir; then + rm -rf "$WORKDIR" + fi + [[ -n ${1:-} ]] && exit $1 } abort() { @@ -88,9 +94,6 @@ die() { cleanup 1 } -trap 'trap_abort' INT QUIT TERM HUP -trap 'trap_exit' EXIT - ## # usage : in_array( $needle, $haystack ) # return : 0 - found @@ -137,10 +140,19 @@ get_full_version() { # usage : lock( $fd, $file, $message ) ## lock() { - eval "exec $1>"'"$2"' - if ! flock -n $1; then - stat_busy "$3" - flock $1 + local fd=$1 + local file=$2 + local mesg=("${@:3}") + + # Only reopen the FD if it wasn't handed to us + if [[ "$(readlink -f /dev/fd/$fd)" != "$(readlink -f "$file")" ]]; then + mkdir -p "${file%/*}" + eval "exec $fd>"'"$file"' + fi + + if ! flock -n $fd; then + stat_busy "${mesg[@]}" + flock $fd stat_done fi } @@ -149,15 +161,33 @@ lock() { # usage : slock( $fd, $file, $message ) ## slock() { - eval "exec $1>"'"$2"' - if ! flock -sn $1; then - stat_busy "$3" - flock -s $1 + local fd=$1 + local file=$2 + local mesg=("${@:3}") + + # Only reopen the FD if it wasn't handed to us + if [[ "$(readlink -f /dev/fd/$fd)" != "$(readlink -f "$file")" ]]; then + mkdir -p "${file%/*}" + eval "exec $fd>"'"$file"' + fi + + eval "exec $fd>"'"$file"' + if ! flock -sn $fd; then + stat_busy "${mesg[@]}" + flock -s $fd stat_done fi } ## +# usage : lock_close( $fd ) +## +lock_close() { + local fd=$1 + eval "exec $fd>&-" +} + +## # usage: pkgver_equal( $pkgver1, $pkgver2 ) ## pkgver_equal() { diff --git a/makechrootpkg.in b/makechrootpkg.in index d03b703..052ab71 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -12,7 +12,8 @@ m4_include(lib/common.sh) shopt -s nullglob -makepkg_args='-s --noconfirm -L --holdver' +_makepkg_args=(-s --noconfirm -L --holdver) +makepkg_args=("${_makepkg_args[@]}") repack=false update_first=false clean_first=false @@ -46,7 +47,7 @@ usage() { echo 'command:' echo ' mkarchroot <chrootdir>/root base-devel' echo '' - echo "Default makepkg args: $makepkg_args" + echo "Default makepkg args: ${_makepkg_args[*]}" echo '' echo 'Flags:' echo '-h This help' @@ -76,11 +77,12 @@ while getopts 'hcur:I:l:nTD:d:' arg; do r) passeddir="$OPTARG" ;; I) install_pkgs+=("$OPTARG") ;; l) copy="$OPTARG" ;; - n) run_namcap=true; makepkg_args="$makepkg_args -i" ;; + n) run_namcap=true; makepkg_args+=('-i') ;; T) temp_chroot=true; copy+="-$$" ;; - *) makepkg_args="$makepkg_args -$arg $OPTARG" ;; + *) usage >&2 ;; esac done +shift $(($OPTIND - 1)) (( EUID != 0 )) && die 'This script must be run as root.' @@ -101,7 +103,7 @@ else fi # Pass all arguments after -- right to makepkg -makepkg_args="$makepkg_args ${*:$OPTIND}" +makepkg_args+=("$@") # See if -R was passed to makepkg for arg in "${@:OPTIND}"; do @@ -134,14 +136,14 @@ load_vars() { create_chroot() { # Lock the chroot we want to use. We'll keep this lock until we exit. - lock 9 "$copydir.lock" "Locking chroot copy [$copy]" + lock 9 "$copydir.lock" "Locking chroot copy [%s]" "$copy" if [[ ! -d $copydir ]] || $clean_first; then # Get a read lock on the root chroot to make # sure we don't clone a half-updated chroot slock 8 "$chrootdir/root.lock" "Locking clean chroot" - stat_busy "Creating clean working copy [$copy]" + stat_busy "Creating clean working copy [%s]" "$copy" if [[ "$chroottype" == btrfs ]] && ! mountpoint -q "$copydir"; then if [[ -d $copydir ]]; then btrfs subvolume delete "$copydir" >/dev/null || @@ -156,12 +158,12 @@ create_chroot() { stat_done # Drop the read lock again - exec 8>&- + lock_close 8 fi } clean_temporary() { - stat_busy "Removing temporary copy [$copy]" + stat_busy "Removing temporary copy [%s]" "$copy" if [[ "$chroottype" == btrfs ]]; then btrfs subvolume delete "$copydir" >/dev/null || die "Unable to delete subvolume %s" "$copydir" @@ -254,8 +256,8 @@ EOF # This is a little gross, but this way the script is recreated every time in the # working copy - printf $'#!/bin/bash\n%s\n_chrootbuild %q %q' "$(declare -f _chrootbuild)" \ - "$makepkg_args" "$run_namcap" >"$copydir/chrootbuild" + printf $'#!/bin/bash\n%s\n_chrootbuild %q "$@"' "$(declare -f _chrootbuild)" \ + "$run_namcap" >"$copydir/chrootbuild" chmod +x "$copydir/chrootbuild" } @@ -281,8 +283,8 @@ download_sources() { _chrootbuild() { # This function isn't run in makechrootpkg, # so no global variables - local makepkg_args="$1" - local run_namcap="$2" + local run_namcap="$1"; shift + local makepkg_args=("$@") . /etc/profile export HOME=/build @@ -318,7 +320,7 @@ _chrootbuild() { exit 1 fi - sudo -u nobody makepkg $makepkg_args || exit 1 + sudo -u nobody makepkg "${makepkg_args[@]}" || exit 1 if $run_namcap; then pacman -S --needed --noconfirm namcap @@ -352,8 +354,8 @@ move_products() { umask 0022 -load_vars "$USER_HOME/.makepkg.conf" load_vars /etc/makepkg.conf +load_vars "$USER_HOME/.makepkg.conf" # Use PKGBUILD directory if these don't exist [[ -d $PKGDEST ]] || PKGDEST=$PWD @@ -377,7 +379,7 @@ if arch-nspawn "$copydir" \ --bind-ro="$PWD:/startdir_host" \ --bind-ro="$SRCDEST:/srcdest_host" \ "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ - /chrootbuild + /chrootbuild "${makepkg_args[@]}" then move_products else diff --git a/mkarchroot.in b/mkarchroot.in index 7cdb274..07bf7c6 100644 --- a/mkarchroot.in +++ b/mkarchroot.in @@ -15,7 +15,7 @@ CHROOT_VERSION='v3' working_dir='' usage() { - echo "Usage: ${0##*/} [options] working-dir [package-list | app]" + echo "Usage: ${0##*/} [options] working-dir package-list..." echo ' options:' echo ' -C <file> Location of a pacman config file' echo ' -M <file> Location of a makepkg config file' @@ -30,7 +30,7 @@ while getopts 'hC:M:c:' arg; do M) makepkg_conf="$OPTARG" ;; c) cache_dir="$OPTARG" ;; h|?) usage ;; - *) error "invalid argument '$arg'"; usage ;; + *) error "invalid argument '%s'" "$arg"; usage ;; esac done shift $(($OPTIND - 1)) diff --git a/rebuildpkgs.in b/rebuildpkgs.in index 2f71c40..65be0de 100644 --- a/rebuildpkgs.in +++ b/rebuildpkgs.in @@ -49,7 +49,7 @@ pkgs="$@" SVNPATH='svn+ssh://nymeria.archlinux.org/srv/repos/svn-packages/svn' -msg "Work will be done in $(pwd)/rebuilds" +msg "Work will be done in %s/rebuilds" "$(pwd)" REBUILD_ROOT="$(pwd)/rebuilds" mkdir -p "$REBUILD_ROOT" @@ -61,11 +61,11 @@ FAILED="" for pkg in $pkgs; do cd "$REBUILD_ROOT/svn-packages" - msg2 "Building '$pkg'" + msg2 "Building '%s'" "$pkg" /usr/bin/svn update "$pkg" if [[ ! -d "$pkg/trunk" ]]; then FAILED="$FAILED $pkg" - warning "$pkg does not exist in SVN" + warning "%s does not exist in SVN" "$pkg" continue fi cd "$pkg/trunk/" @@ -74,14 +74,14 @@ for pkg in $pkgs; do if ! sudo makechrootpkg -u -d -r "$chrootdir" -- --noconfirm; then FAILED="$FAILED $pkg" - error "$pkg Failed!" + error "%s Failed!" "$pkg" else pkgfile=$(pkg_from_pkgbuild) if [[ -e $pkgfile ]]; then - msg2 "$pkg Complete" + msg2 "%s Complete" "$pkg" else FAILED="$FAILED $pkg" - error "$pkg Failed, no package built!" + error "%s Failed, no package built!" "$pkg" fi fi done @@ -90,7 +90,7 @@ cd "$REBUILD_ROOT" if [[ -n $FAILED ]]; then msg 'Packages failed:' for pkg in $FAILED; do - msg2 "$pkg" + msg2 "%s" "$pkg" done fi |