From a4a397d9be3d4fece768d93e4d011d34160e4c40 Mon Sep 17 00:00:00 2001 From: artoo Date: Thu, 13 Nov 2014 13:33:38 +0100 Subject: [PATCH] laodvars default makepkg.conf loading --- bin/build-set.in | 12 ++++++------ bin/checkpkg.in | 13 ++----------- bin/chroot-run.in | 8 ++++---- bin/signpkg.in | 3 ++- lib/util-build.sh | 48 ++++++++++++++++++++--------------------------- lib/util.sh | 2 +- 6 files changed, 35 insertions(+), 51 deletions(-) diff --git a/bin/build-set.in b/bin/build-set.in index 2e4de90..c9bf88b 100644 --- a/bin/build-set.in +++ b/bin/build-set.in @@ -17,14 +17,14 @@ if [[ -r @libdir@/messages.sh ]];then source @libdir@/messages.sh fi -if [[ -r @libdir@/util-build.sh ]];then - source @libdir@/util-build.sh -fi - if [[ -r @libdir@/util.sh ]];then source @libdir@/util.sh fi +if [[ -r @libdir@/util-build.sh ]];then + source @libdir@/util-build.sh +fi + pkg_owner=${SUDO_USER:-$USER} if [[ -n $SUDO_USER ]]; then @@ -139,10 +139,10 @@ run(){ chroot_init prepare_dir "${pkgdir}" chroot_build - ch_owner "$(dirname ${pkgdir})" + ch_owner "${pkg_owner}" "$(dirname ${pkgdir})" if ${sign}; then - sign_pkgs + sign_pkgs "${pkg_owner}" fi fi } diff --git a/bin/checkpkg.in b/bin/checkpkg.in index c10a1b0..c6b2e8c 100644 --- a/bin/checkpkg.in +++ b/bin/checkpkg.in @@ -20,17 +20,8 @@ fi shopt -s extglob -# Source makepkg.conf; fail if it is not found -if [[ -r '/etc/makepkg.conf' ]]; then - source '/etc/makepkg.conf' -else - die '/etc/makepkg.conf not found!' -fi - -# Source user-specific makepkg.conf overrides -if [[ -r ~/.makepkg.conf ]]; then - source ~/.makepkg.conf -fi +load_vars "$HOME/.makepkg.conf" +load_vars /etc/makepkg.conf if [[ ! -f PKGBUILD ]]; then die 'This must be run in the directory of a built package.' diff --git a/bin/chroot-run.in b/bin/chroot-run.in index d8429ae..2d40837 100644 --- a/bin/chroot-run.in +++ b/bin/chroot-run.in @@ -14,14 +14,14 @@ if [[ -r @libdir@/messages.sh ]];then source @libdir@/messages.sh fi -if [[ -r @libdir@/util-mount.sh ]];then - source @libdir@/util-mount.sh -fi - if [[ -r @libdir@/util.sh ]];then source @libdir@/util.sh fi +if [[ -r @libdir@/util-mount.sh ]];then + source @libdir@/util-mount.sh +fi + working_dir='' usage() { diff --git a/bin/signpkg.in b/bin/signpkg.in index 19d3b9a..f307aed 100644 --- a/bin/signpkg.in +++ b/bin/signpkg.in @@ -14,7 +14,8 @@ if [[ -r @libdir@/messages.sh ]];then source @libdir@/messages.sh fi -. /etc/makepkg.conf +load_vars "$HOME/.makepkg.conf" +load_vars /etc/makepkg.conf if [ ! -e "$1" ]; then error "Package '$1' does not exists!" diff --git a/lib/util-build.sh b/lib/util-build.sh index 1c0a20a..d0bcb21 100644 --- a/lib/util-build.sh +++ b/lib/util-build.sh @@ -9,23 +9,21 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -ext='pkg.tar.xz' - ch_owner(){ - msg "chown -R [$pkg_owner:users] [$1]" - chown -R "$pkg_owner:users" "$1" + #msg "Changing owner [$1:users] [$2]" + chown -R "$1:users" "$2" } sign_pkgs(){ cd $pkgdir - su $pkg_owner <<'EOF' + su $1 <<'EOF' signpkgs EOF } move_pkg(){ - msg2 "Moving [$1] to [${pkgdir}]" - local + #msg2 "Moving [$1] to [${pkgdir}]" + local ext='pkg.tar.xz' if [[ -n $PKGDEST ]];then mv $PKGDEST/*{any,$arch}.${ext} ${pkgdir}/ else @@ -50,27 +48,21 @@ prepare_dir(){ clean_up(){ msg "Cleaning up ..." - if [[ -n $LOGDEST ]];then - msg2 "Cleaning logs $LOGDEST ..." - rm -r $LOGDEST/*.log - else - msg2 "Cleaning logs $(pwd) ..." - rm -r $(pwd)/*.log + local query=$(find ${pkgdir} -maxdepth 1 -name "*.*") + if [[ -n $query ]];then + rm -v $query fi - msg2 "Cleaning ${pkgdir} ..." - rm -r ${pkgdir}/*.pkg.tar.xz{,.sig} - if [[ -n $SRCDEST ]];then - msg2 "Cleaning src files $SRCDEST ..." - rm -r $SRCDEST/*.?z - else - msg2 "Cleaning src files $(pwd) ..." - rm -r $(pwd)/*.?z + if [[ -z $LOGDEST ]];then + query=$(find $(pwd) -maxdepth 2 -name '*.log') + if [[ -n $query ]];then + rm -v $query + fi fi - if [[ -z $BUILDDIR ]];then - msg2 "Cleaning src $(pwd) ..." - rm -r $(pwd)/src - msg2 "Cleaning pkg $(pwd) ..." - rm -r $(pwd)/pkg + if [[ -z $SRCDEST ]];then + query=$(find $(pwd) -maxdepth 2 -name '*.?z?') + if [[ -n $query ]];then + rm -v $query + fi fi } @@ -94,10 +86,10 @@ blacklist_pkg(){ chroot_clean(){ for copy in "$1"/*; do - [[ -d $copy ]] || continue + [[ -d ${copy} ]] || continue msg2 "Deleting chroot copy '$(basename "${copy}")'..." - lock 9 "$copy.lock" "Locking chroot copy '$copy'" + lock 9 "${copy}.lock" "Locking chroot copy '${copy}'" if [[ "$(stat -f -c %T "${copy}")" == btrfs ]]; then { type -P btrfs && btrfs subvolume delete "${copy}"; } &>/dev/null diff --git a/lib/util.sh b/lib/util.sh index d3eb871..7245f77 100644 --- a/lib/util.sh +++ b/lib/util.sh @@ -154,7 +154,7 @@ load_vars() { [[ -f $mpkg_conf ]] || return 1 - for var in {SRC,SRCPKG,PKG,LOG}DEST MAKEFLAGS PACKAGER BUILDDIR; do + for var in {SRC,SRCPKG,PKG,LOG}DEST MAKEFLAGS PACKAGER CARCH GPGKEY; do [[ -z ${!var} ]] && eval $(grep "^${var}=" "$mpkg_conf") done