Compare commits

..

3 Commits

Author SHA1 Message Date
Pierre Schmitz
6e086f0e70 Prepare release 2013-04-08 18:09:19 +02:00
Sébastien Luttringer
93d735981b makechrootpkg: Add option to build in temp chroot
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>
Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
2013-04-08 14:30:45 +02:00
Pierre Schmitz
97a2d2414a mkarchroot: Fix creation of btrfs snapshot and remove force option 2013-04-07 16:05:21 +02:00
5 changed files with 34 additions and 24 deletions

View File

@@ -1,4 +1,4 @@
V=20130406 V=20130408
PREFIX = /usr/local PREFIX = /usr/local

View File

@@ -53,7 +53,7 @@ _mkarchroot() {
case $cur in case $cur in
-*) -*)
COMPREPLY=( $( compgen -W '-C -M -c -f -h -n -r -u' -- "$cur" ) ) COMPREPLY=( $( compgen -W '-C -M -c -h -n -r -u' -- "$cur" ) )
;; ;;
*) *)
_filedir _filedir

View File

@@ -19,14 +19,15 @@ clean_first=false
install_pkg= install_pkg=
add_to_db=false add_to_db=false
run_namcap=false run_namcap=false
temp_chroot=false
chrootdir= chrootdir=
passeddir= passeddir=
declare -a install_pkgs declare -a install_pkgs
declare -i ret=0 declare -i ret=0
default_copy=$USER copy=$USER
[[ -n $SUDO_USER ]] && default_copy=$SUDO_USER [[ -n $SUDO_USER ]] && copy=$SUDO_USER
[[ -z $default_copy || $default_copy = root ]] && default_copy=copy [[ -z "$copy" || $copy = root ]] && copy=copy
src_owner=${SUDO_USER:-$USER} src_owner=${SUDO_USER:-$USER}
usage() { usage() {
@@ -55,13 +56,14 @@ usage() {
echo '-r <dir> The chroot dir to use' echo '-r <dir> The chroot dir to use'
echo '-I <pkg> Install a package into the working copy of the chroot' 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 '-l <copy> The directory to use as the working copy of the chroot'
echo ' Useful for maintaining multiple copies.' echo ' Useful for maintaining multiple copies'
echo " Default: $default_copy" echo " Default: $copy"
echo '-n Run namcap on the package' echo '-n Run namcap on the package'
echo '-T Build in a temporary directory'
exit 1 exit 1
} }
while getopts 'hcudr:I:l:n' arg; do while getopts 'hcudr:I:l:nT' arg; do
case "$arg" in case "$arg" in
h) usage ;; h) usage ;;
c) clean_first=true ;; c) clean_first=true ;;
@@ -71,6 +73,7 @@ while getopts 'hcudr:I:l:n' arg; do
I) install_pkgs+=("$OPTARG") ;; I) install_pkgs+=("$OPTARG") ;;
l) copy="$OPTARG" ;; l) copy="$OPTARG" ;;
n) run_namcap=true; makepkg_args="$makepkg_args -i" ;; n) run_namcap=true; makepkg_args="$makepkg_args -i" ;;
T) temp_chroot=true; copy+="-$RANDOM" ;;
*) makepkg_args="$makepkg_args -$arg $OPTARG" ;; *) makepkg_args="$makepkg_args -$arg $OPTARG" ;;
esac esac
done done
@@ -81,7 +84,6 @@ chrootdir=$(readlink -e "$passeddir")
if [[ ${copy:0:1} = / ]]; then if [[ ${copy:0:1} = / ]]; then
copydir=$copy copydir=$copy
else else
[[ -z $copy ]] && copy=$default_copy
copydir="$chrootdir/$copy" copydir="$chrootdir/$copy"
fi fi
@@ -314,6 +316,21 @@ for f in "$copydir"/srcdest/*; do
mv "$f" "$SRCDEST" mv "$f" "$SRCDEST"
done 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" die "Build failed, check $copydir/build"
else
true
fi fi

View File

@@ -12,7 +12,6 @@ m4_include(lib/common.sh)
CHROOT_VERSION='v3' CHROOT_VERSION='v3'
FORCE='n'
RUN='' RUN=''
NOCOPY='n' NOCOPY='n'
@@ -26,7 +25,6 @@ usage() {
echo ' options:' echo ' options:'
echo ' -r <app> Run "app" within the context of the chroot' echo ' -r <app> Run "app" within the context of the chroot'
echo ' -u Update the chroot via pacman' echo ' -u Update the chroot via pacman'
echo ' -f Force overwrite of files in the working-dir'
echo ' -C <file> Location of a pacman config file' echo ' -C <file> Location of a pacman config file'
echo ' -M <file> Location of a makepkg config file' echo ' -M <file> Location of a makepkg config file'
echo ' -n Do not copy config files into the chroot' echo ' -n Do not copy config files into the chroot'
@@ -39,7 +37,6 @@ while getopts 'r:ufnhC:M:c:' arg; do
case "${arg}" in case "${arg}" in
r) RUN="$OPTARG" ;; r) RUN="$OPTARG" ;;
u) RUN='pacman -Syu --noconfirm' ;; u) RUN='pacman -Syu --noconfirm' ;;
f) FORCE='y' ;;
C) pac_conf="$OPTARG" ;; C) pac_conf="$OPTARG" ;;
M) makepkg_conf="$OPTARG" ;; M) makepkg_conf="$OPTARG" ;;
n) NOCOPY='y' ;; n) NOCOPY='y' ;;
@@ -152,18 +149,18 @@ if [[ -n $RUN ]]; then
# }}} # }}}
else else
# {{{ build chroot # {{{ build chroot
if [[ -e $working_dir && $FORCE = 'n' ]]; then if [[ -e $working_dir ]]; then
die "Working directory '${working_dir}' already exists - try using -f" die "Working directory '${working_dir}' already exists"
fi fi
if [[ ! -d "${working_dir}" ]]; then mkdir -p "${working_dir}"
mkdir -p "${working_dir}"
fi
if [[ "$(stat -f -c %T "${working_dir}")" == btrfs ]]; then if [[ "$(stat -f -c %T "${working_dir}")" == btrfs ]]; then
if { type -P btrfs && btrfs subvolume create "${working_dir}"; } &>/dev/null; then rmdir "${working_dir}"
chmod 0755 "${working_dir}" if ! btrfs subvolume create "${working_dir}"; then
die "Couldn't create subvolume for '${working_dir}'"
fi fi
chmod 0755 "${working_dir}"
fi fi
chroot_lock chroot_lock
@@ -173,9 +170,6 @@ else
pacargs+=("--config=${pac_conf}") pacargs+=("--config=${pac_conf}")
fi fi
if [[ $FORCE = 'y' ]]; then
pacargs+=("--force")
fi
if ! pacstrap -GMcd "${working_dir}" "${pacargs[@]}" "$@"; then if ! pacstrap -GMcd "${working_dir}" "${pacargs[@]}" "$@"; then
die 'Failed to install all packages' die 'Failed to install all packages'
fi fi

View File

@@ -42,7 +42,6 @@ _makechrootpkg_args=(
_mkarchroot_args=( _mkarchroot_args=(
'-r[Run a program within the context of the chroot]:app' '-r[Run a program within the context of the chroot]:app'
'-u[Update the chroot via pacman]' '-u[Update the chroot via pacman]'
'-f[Force overwrite of files in the working-dir]'
'-C[Location of a pacman config file]:pacman_config:_files' '-C[Location of a pacman config file]:pacman_config:_files'
'-M[Location of a makepkg config file]:makepkg_config:_files' '-M[Location of a makepkg config file]:makepkg_config:_files'
'-n[Do not copy config files into the chroot]' '-n[Do not copy config files into the chroot]'