From 0fd1e7b1333b8793c1cc448c2a00cb085544cc8c Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 18 Jan 2014 20:30:08 -0500 Subject: libremakepkg: support -r and -w flags, same as librechroot Feature request: https://labs.parabola.nu/issues/458 --- src/chroot-tools/libremakepkg | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index fc6418c..dbeeb81 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -148,8 +148,12 @@ usage() { the documentation there.' echo print 'Options:' + print ' %s options:' librechroot flag "-n <$(_ CHROOT)>" 'Name of the chroot to use' flag "-l <$(_ COPY)>" 'Name of, or absolute path to, the chroot copy to use' + flag "-w <$(_ 'PATH[:PATH]')>" 'Bind mount a file or directory, read/write' + flag "-r <$(_ 'PATH[:PATH]')>" 'Bind mount a file or directory, read-only' + print ' %s options:' libremakepkg flag '-N' "Don't disable networking during build() and package(). PLEASE don't use this unless you have a special reason, its use is a violation @@ -173,10 +177,14 @@ main() { local chroot='' # Parse command line options ########################################### - while getopts 'n:l:NRh' flag ; do + while getopts 'n:l:wrNRh' flag ; do case "${flag}" in - n) if $INCHROOT; then err_chflag "$flag"; else chroot=$OPTARG; fi;; - l) if $INCHROOT; then err_chflag "$flag"; else copy=$OPTARG; fi;; + n) if $INCHROOT; then err_chflag "$flag"; else + chroot=$OPTARG; fi;; + l) if $INCHROOT; then err_chflag "$flag"; else + copy=$OPTARG; fi;; + w|r) if $INCHROOT; then err_chflag "$flag"; else + librechroot_flags+=(-$flag "$OPTARG"); fi;; N) NONET=false;; R) repack=true; makepkg_args+=(-R);; h) usage; return 0;; @@ -226,7 +234,7 @@ main() { MAKEFLAGS="$(get_var makepkg MAKEFLAGS '')" PACKAGER="$(get_var makepkg PACKAGER '')" - librechroot_flags=( + librechroot_flags+=( -r "$PWD:/startdir_host" -r "$SRCDEST:/srcdest_host" -n "$CHROOT" -- cgit v1.2.3-2-g168b From 83a55baf27a6e6f3fa3e6772a6f1b63f4c5138d7 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 19 Jan 2014 10:00:18 -0500 Subject: libremakepkg: actually support SRCPKGDEST, document LOGDEST support --- src/chroot-tools/libremakepkg | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index dbeeb81..dcc495c 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -33,7 +33,7 @@ umask 0022 readonly _indent="$(librelib chroot/indent)" readonly INCHROOT=$([[ -f /.arch-chroot ]] && echo true || echo false) NONET=true # can be changed with the -N flag -# {SRC,LOG,PKG}DEST set at runtime by makepkg.conf +# {PKG,SRC,SRCPKG,LOG}DEST set at runtime by makepkg.conf # MAKEFLAGS, PACKAGER set at runtime by makepkg.conf # LIBREUSER, LIBREHOME are set by conf.sh librechroot_flags=() @@ -132,7 +132,7 @@ usage() { prose 'If run from outside of a chroot, command will make the following configuration changes in the chroot:' bullet 'whatever changes `librechroot` makes.' - bullet 'set `PKGDEST` and `SRCDEST` in `/etc/makepkg.conf`' + bullet 'set `{PKG,SRC,SRCPKG,LOG}DEST` in `/etc/makepkg.conf`' bullet 'set `PACKAGER` in `/etc/makepkg.conf` to reflect the value outside of the chroot.' bullet '(maybe) delete `/build/.makepkg.conf`' @@ -227,10 +227,11 @@ main() { # Load makepkg configuration ########################################### # Note that all of these are globals - SRCDEST="$(get_var makepkg SRCDEST "$PWD")" PKGDEST="$(get_var makepkg PKGDEST "$PWD")" + SRCDEST="$(get_var makepkg SRCDEST "$PWD")" + SRCPKGDEST="$(get_var makepkg SRCPKGDEST "$PWD")" LOGDEST="$(get_var makepkg LOGDEST "$PWD")" - mkdir -p "$SRCDEST" "$PKGDEST" "$LOGDEST" + mkdir -p -- "$PKGDEST" "$SRCDEST" "$SRCPKGDEST" "$LOGDEST" MAKEFLAGS="$(get_var makepkg MAKEFLAGS '')" PACKAGER="$(get_var makepkg PACKAGER '')" -- cgit v1.2.3-2-g168b From 897a0084bdd96b06198e699f9851ce0b89de409d Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 19 Jan 2014 10:45:19 -0500 Subject: libremakepkg: fix getopts string (I'm a dummy) --- src/chroot-tools/libremakepkg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index dcc495c..f2dc537 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -177,7 +177,7 @@ main() { local chroot='' # Parse command line options ########################################### - while getopts 'n:l:wrNRh' flag ; do + while getopts 'n:l:w:r:NRh' flag ; do case "${flag}" in n) if $INCHROOT; then err_chflag "$flag"; else chroot=$OPTARG; fi;; -- cgit v1.2.3-2-g168b From 8692458d65fc9ce559ad7cd254d7ed3b606da76e Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 19 Jan 2014 14:13:40 -0500 Subject: libremakepkg: (minor) refactor things to places that make a bit more sense --- src/chroot-tools/libremakepkg | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index f2dc537..1db9f08 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -212,6 +212,15 @@ main() { fi unset chroot + # Load makepkg configuration ########################################### + # Note that all of these are globals + PKGDEST="$(get_var makepkg PKGDEST "$PWD")" + SRCDEST="$(get_var makepkg SRCDEST "$PWD")" + SRCPKGDEST="$(get_var makepkg SRCPKGDEST "$PWD")" + LOGDEST="$(get_var makepkg LOGDEST "$PWD")" + MAKEFLAGS="$(get_var makepkg MAKEFLAGS '')" + PACKAGER="$(get_var makepkg PACKAGER '')" + # Quick sanity check ################################################### if (( EUID )); then @@ -225,22 +234,8 @@ main() { exit 1 fi - # Load makepkg configuration ########################################### - # Note that all of these are globals - PKGDEST="$(get_var makepkg PKGDEST "$PWD")" - SRCDEST="$(get_var makepkg SRCDEST "$PWD")" - SRCPKGDEST="$(get_var makepkg SRCPKGDEST "$PWD")" - LOGDEST="$(get_var makepkg LOGDEST "$PWD")" + # Make sure that the various *DEST directories exist mkdir -p -- "$PKGDEST" "$SRCDEST" "$SRCPKGDEST" "$LOGDEST" - MAKEFLAGS="$(get_var makepkg MAKEFLAGS '')" - PACKAGER="$(get_var makepkg PACKAGER '')" - - librechroot_flags+=( - -r "$PWD:/startdir_host" - -r "$SRCDEST:/srcdest_host" - -n "$CHROOT" - -l "$copy" - ) # OK, we are starting now ############################################## @@ -248,6 +243,13 @@ main() { lock 9 "/build/.lock" \ "Waiting for existing lock on build directory to be released" else + librechroot_flags+=( + -r "$PWD:/startdir_host" + -r "$SRCDEST:/srcdest_host" + -n "$CHROOT" + -l "$copy" + ) + # Obtain a lock on the chroot lock 9 "$copydir.lock" \ "Waiting for existing lock on chroot copy to be released: [%s]" "$copy" -- cgit v1.2.3-2-g168b From b6e66bce4dadd1a5b9f74a456de3ef5575e648fa Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 19 Jan 2014 17:19:04 -0500 Subject: libremakepkg: Check the permissions of the bind-mounted directories --- src/chroot-tools/libremakepkg | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index 1db9f08..96f86ab 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -54,6 +54,21 @@ indent() { "$_indent" ' | ' } +# Usage: _check_perms_dir $directory +# Make sure that $directory is readable and executable (searchable) by 'nobody' +check_directory_permissions() ( + local dir=$1 + # `cd` to the directory, then test `.`; that way if parent + # directories aren't readable, we aren't testing for that. We + # only need the last element in `$dir`. + cd "$dir" + if ! sudo -u nobody test -r . -a -x .; then + error "Directory '%s' must be readable by user 'nobody'" "$dir" + return 1 + fi + return 0 +) + # Usage: exit_copy $copydir $src_owner # End immediately, but copy log files out exit_copy() { @@ -236,6 +251,15 @@ main() { # Make sure that the various *DEST directories exist mkdir -p -- "$PKGDEST" "$SRCDEST" "$SRCPKGDEST" "$LOGDEST" + # Check the permissions for $startdir and $SRCDEST + ( + declare -i ret=0 + check_directory_permissions "$PWD" || ret=1 + if ! [[ "$PWD" -ef "$SRCDEST" ]]; then + check_directory_permissions "$SRCDEST" || ret=1 + fi + exit $ret + ) # OK, we are starting now ############################################## -- cgit v1.2.3-2-g168b From ea11eca851e1b54e36d310f4d69e099f169191e8 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 2 Feb 2014 00:05:22 -0500 Subject: I forgot to bump the copyright year on all the files I've touched this year --- src/chroot-tools/libremakepkg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index 96f86ab..c838288 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -4,7 +4,7 @@ set -euE # Copyright 2010-2011 Nicolás Reynolds # Copyright 2011 Joshua Ismael Haase Hernández -# Copyright 2012-2013 Luke Shumaker +# Copyright 2012-2014 Luke Shumaker # # This file is part of Parabola. # -- cgit v1.2.3-2-g168b From c43f0808583070a22e904cd650e8ed17fe781806 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 2 Feb 2014 00:20:19 -0500 Subject: Normalize to use the string "Copyright (C)" --- src/chroot-tools/libremakepkg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index c838288..d6db0fd 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -2,9 +2,9 @@ set -euE # libremakepkg -# Copyright 2010-2011 Nicolás Reynolds -# Copyright 2011 Joshua Ismael Haase Hernández -# Copyright 2012-2014 Luke Shumaker +# Copyright (C) 2010-2011 Nicolás Reynolds +# Copyright (C) 2011 Joshua Ismael Haase Hernández +# Copyright (C) 2012-2014 Luke Shumaker # # This file is part of Parabola. # -- cgit v1.2.3-2-g168b From 9f28b8f1d7ecc211e4df9f4a16a04960ed1bd582 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 2 Feb 2014 22:34:00 -0500 Subject: libremakepkg: fix network handling --- src/chroot-tools/libremakepkg | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index d6db0fd..a459009 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -121,14 +121,14 @@ build() ( local copydir=$1; shift local repack=$1; shift - local netflag='' local run=() if $INCHROOT; then - ! $NONET || netflag='-N' run=(unshare) + if $NONET; then run+=('-n'); fi else - ! $NONET || netflag='-n' - run=(librechroot "${librechroot_flags[@]}" run) + run=(librechroot "${librechroot_flags[@]}") + if $NONET; then run+=('-N'); fi + run+=(run) fi prepare_chroot "$copydir" "$LIBREHOME" "$repack" false -- cgit v1.2.3-2-g168b From c55053b00f34a90e27dff3d92ae6bbcdac0edaf4 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 5 Feb 2014 19:38:24 -0500 Subject: libremakepkg: fix installing dependencies that aren't in the paccache I can't figure out a reliable way to test this, as it depends on the host pacman cache. --- src/chroot-tools/libremakepkg | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index a459009..26080bc 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -121,21 +121,22 @@ build() ( local copydir=$1; shift local repack=$1; shift - local run=() + local run_ynet=() + local run_nnet=() if $INCHROOT; then - run=(unshare) - if $NONET; then run+=('-n'); fi + run_ynet=(unshare) + run_nnet=(unshare -n) else - run=(librechroot "${librechroot_flags[@]}") - if $NONET; then run+=('-N'); fi - run+=(run) + run_ynet=(librechroot "${librechroot_flags[@]}" run) + run_nnet=(librechroot "${librechroot_flags[@]}" -N run) fi + $NONET || run_nnet=("${run_ynet[@]}") prepare_chroot "$copydir" "$LIBREHOME" "$repack" false - "${run[@]}" /chrootprepare "$@" |& indent + "${run_ynet[@]}" /chrootprepare false "$@" |& indent run_hook pre_build "$copydir" trap "run_hook post_build '$copydir'" EXIT - "${run[@]}" /chrootbuild "$@" |& indent + "${run_nnet[@]}" /chrootbuild false "$@" |& indent ) # The main program ############################################################# -- cgit v1.2.3-2-g168b From d25f30f25ce61367c81133c9cd01fe3169d8f6c0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 21 Mar 2014 14:39:06 -0400 Subject: Do an audit of copyright and license claims --- src/chroot-tools/libremakepkg | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index 26080bc..6050174 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -2,9 +2,11 @@ set -euE # libremakepkg -# Copyright (C) 2010-2011 Nicolás Reynolds -# Copyright (C) 2011 Joshua Ismael Haase Hernández -# Copyright (C) 2012-2014 Luke Shumaker +# Copyright (C) 2010-2011 Nicolás Reynolds +# Copyright (C) 2011 Joshua Ismael Haase Hernández (xihh) +# Copyright (C) 2012-2014 Luke Shumaker +# +# License: GNU GPLv3+ # # This file is part of Parabola. # -- cgit v1.2.3-2-g168b From c48ac8c89e596e160505bd5678db2b193607493f Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 22 Mar 2014 22:00:44 -0400 Subject: Audit the authors and copyright years of files against git logs --- src/chroot-tools/libremakepkg | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index 6050174..1ed4eaf 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -2,8 +2,9 @@ set -euE # libremakepkg -# Copyright (C) 2010-2011 Nicolás Reynolds -# Copyright (C) 2011 Joshua Ismael Haase Hernández (xihh) +# Copyright (C) 2010-2012 Nicolás Reynolds +# Copyright (C) 2010-2012 Joshua Ismael Haase Hernández (xihh) +# Copyright (C) 2012 Michał Masłowski # Copyright (C) 2012-2014 Luke Shumaker # # License: GNU GPLv3+ -- cgit v1.2.3-2-g168b From 222856031fbbf314e8e47db414225756a9c6fba2 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 23 Mar 2014 18:09:13 -0400 Subject: Most of my desired re-licensings were authorized on the dev list --- src/chroot-tools/libremakepkg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/chroot-tools/libremakepkg') diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index 1ed4eaf..aad4217 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -7,13 +7,13 @@ set -euE # Copyright (C) 2012 Michał Masłowski # Copyright (C) 2012-2014 Luke Shumaker # -# License: GNU GPLv3+ +# License: GNU GPLv2+ # # This file is part of Parabola. # # Parabola is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or +# the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # Parabola is distributed in the hope that it will be useful, -- cgit v1.2.3-2-g168b