[arch-projects] [DEVTOOLS][PATCH 1/3] archbuild: only use base-devel to new chroot
Since TODO [1] which state: It would be good for base-devel to install everything needed for a build chroot we can remove base and sudo [1] https://www.archlinux.org/todo/add-more-to-base-devel/ Signed-off-by: Sébastien Luttringer <seblu@seblu.net> --- archbuild.in | 2 +- makechrootpkg.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/archbuild.in b/archbuild.in index 4054de7..9f9633c 100644 --- a/archbuild.in +++ b/archbuild.in @@ -2,7 +2,7 @@ m4_include(lib/common.sh) -base_packages=(base base-devel sudo) +base_packages=(base-devel) makechrootpkg_args=(-c -n) cmd="${0##*/}" diff --git a/makechrootpkg.in b/makechrootpkg.in index 08c76a8..a8e8ed9 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -41,7 +41,7 @@ usage() { echo '' echo 'The chroot "root" directory must be created via the following' echo 'command:' - echo ' mkarchroot <chrootdir>/root base base-devel sudo' + echo ' mkarchroot <chrootdir>/root base-devel' echo '' echo "Default makepkg args: $makepkg_args" echo '' -- Sébastien "Seblu" Luttringer
Add option -T to build in a temporary chroot. This apply to any kind of filesytem and allow to easily parrallelize builds. This patch also simplify how $default_copy and $copy are defined. Signed-off-by: Sébastien Luttringer <seblu@seblu.net> --- makechrootpkg.in | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index a8e8ed9..22e2097 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -19,14 +19,15 @@ clean_first=false install_pkg= add_to_db=false run_namcap=false +temp_chroot=false chrootdir= passeddir= declare -a install_pkgs declare -i ret=0 -default_copy=$USER -[[ -n $SUDO_USER ]] && default_copy=$SUDO_USER -[[ -z $default_copy || $default_copy = root ]] && default_copy=copy +copy=$USER +[[ -n $SUDO_USER ]] && copy=$SUDO_USER +[[ -z "$copy" || $copy = root ]] && copy=copy src_owner=${SUDO_USER:-$USER} usage() { @@ -55,13 +56,14 @@ usage() { echo '-r <dir> The chroot dir to use' echo '-I <pkg> Install a package into the working copy of the chroot' echo '-l <copy> The directory to use as the working copy of the chroot' - echo ' Useful for maintaining multiple copies.' - echo " Default: $default_copy" + echo ' Useful for maintaining multiple copies' + echo " Default: $copy" echo '-n Run namcap on the package' + echo '-T Build in a temporary directory' exit 1 } -while getopts 'hcudr:I:l:n' arg; do +while getopts 'hcudr:I:l:nT' arg; do case "$arg" in h) usage ;; c) clean_first=true ;; @@ -71,6 +73,7 @@ while getopts 'hcudr:I:l:n' arg; do I) install_pkgs+=("$OPTARG") ;; l) copy="$OPTARG" ;; n) run_namcap=true; makepkg_args="$makepkg_args -i" ;; + T) temp_chroot=true; copy+="-$RANDOM" ;; *) makepkg_args="$makepkg_args -$arg $OPTARG" ;; esac done @@ -84,7 +87,6 @@ chroottype=$(stat -f -c %T "$chrootdir") if [[ ${copy:0:1} = / ]]; then copydir=$copy else - [[ -z $copy ]] && copy=$default_copy copydir="$chrootdir/$copy" fi @@ -314,6 +316,21 @@ for f in "$copydir"/srcdest/*; do mv "$f" "$SRCDEST" done -if (( ret != 0 )); then +if $temp_chroot; then + stat_busy "Removing temporary directoy [$copy]" + if [[ "$chroottype" == btrfs ]]; then + btrfs subvolume delete "$copydir" >/dev/null || + die "Unable to delete subvolume $copydir" + else + # avoid change of filesystem in case of an umount failure + rm --recursive --force --one-file-system "$copydir" || + die "Unable to delete $copydir" + fi + # remove lock file + rm --force "$copydir.lock" + stat_done +elif (( ret != 0 )); then die "Build failed, check $copydir/build" +else + true fi -- Sébastien "Seblu" Luttringer
Am 14.03.2013 03:55, schrieb Sébastien Luttringer:
Add option -T to build in a temporary chroot. This apply to any kind of filesytem and allow to easily parrallelize builds.
This patch also simplify how $default_copy and $copy are defined.
Signed-off-by: Sébastien Luttringer <seblu@seblu.net> --- makechrootpkg.in | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-)
+ T) temp_chroot=true; copy+="-$RANDOM" ;;
Maybe use mktemp -d here. Otherwise it's possible to get random number twice. -- Pierre Schmitz, https://pierre-schmitz.com
On Sat, Mar 16, 2013 at 9:45 AM, Pierre Schmitz <pierre@archlinux.de> wrote:
Am 14.03.2013 03:55, schrieb Sébastien Luttringer:
Add option -T to build in a temporary chroot. This apply to any kind of filesytem and allow to easily parrallelize builds.
This patch also simplify how $default_copy and $copy are defined.
Signed-off-by: Sébastien Luttringer <seblu@seblu.net> --- makechrootpkg.in | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-)
+ T) temp_chroot=true; copy+="-$RANDOM" ;;
Maybe use mktemp -d here. Otherwise it's possible to get random number twice.
As Jan suggested, we can use mktemp with -u get the directory name. It's unsafe too, so it's basically the same as using $RANDOM except the fork. The probability of getting the same number twice is so small and even not an issue (as we still have the lock mechanism). The penalty if a user generate twice the same number, is to wait the first build end before the second start. Cheers, -- Sébastien "Seblu" Luttringer https://www.seblu.net GPG: 0x2072D77A
Move detection of chrootdir type after have check if the directory exists. This avoid the following messages when -r is not given stat: cannot read file system information for '': No such file or directory Signed-off-by: Sébastien Luttringer <seblu@seblu.net> --- makechrootpkg.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index 22e2097..a00745c 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -81,9 +81,6 @@ done # Canonicalize chrootdir, getting rid of trailing / chrootdir=$(readlink -e "$passeddir") -# Detect chrootdir filesystem type -chroottype=$(stat -f -c %T "$chrootdir") - if [[ ${copy:0:1} = / ]]; then copydir=$copy else @@ -119,6 +116,9 @@ fi umask 0022 +# Detect chrootdir filesystem type +chroottype=$(stat -f -c %T "$chrootdir") + # Lock the chroot we want to use. We'll keep this lock until we exit. # Note this is the same FD number as in mkarchroot exec 9>"$copydir.lock" -- Sébastien "Seblu" Luttringer
Am 14.03.2013 03:55, schrieb Sébastien Luttringer:
Since TODO [1] which state: It would be good for base-devel to install everything needed for a build chroot we can remove base and sudo
sudo is still required by makepkg. -- Pierre Schmitz, https://pierre-schmitz.com
On Sat, Mar 16, 2013 at 9:37 AM, Pierre Schmitz <pierre@archlinux.de> wrote:
Am 14.03.2013 03:55, schrieb Sébastien Luttringer:
Since TODO [1] which state: It would be good for base-devel to install everything needed for a build chroot we can remove base and sudo
sudo is still required by makepkg.
yes. This patch is linked to this proposal[1] which add sudo in base-devel to be have everything needed to make a build in a chroot. [1] https://mailman.archlinux.org/pipermail/arch-dev-public/2013-March/024618.ht... [2] https://www.archlinux.org/todo/add-more-to-base-devel/ -- Sébastien "Seblu" Luttringer https://www.seblu.net GPG: 0x2072D77A
Am 16.03.2013 13:48, schrieb Sébastien Luttringer:
On Sat, Mar 16, 2013 at 9:37 AM, Pierre Schmitz <pierre@archlinux.de> wrote:
Am 14.03.2013 03:55, schrieb Sébastien Luttringer:
Since TODO [1] which state: It would be good for base-devel to install everything needed for a build chroot we can remove base and sudo
sudo is still required by makepkg.
yes. This patch is linked to this proposal[1] which add sudo in base-devel to be have everything needed to make a build in a chroot.
[1] https://mailman.archlinux.org/pipermail/arch-dev-public/2013-March/024618.ht... [2] https://www.archlinux.org/todo/add-more-to-base-devel/
OK, I did not really see that mail. I have applied this patch and replaced base,sudo in another place you had missed. We still have to wait for sudo entering core though. Greetings, Pierre -- Pierre Schmitz, https://pierre-schmitz.com
participants (2)
-
Pierre Schmitz
-
Sébastien Luttringer