summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-04-24 12:29:09 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-04-24 12:29:09 -0400
commitea39ed2b8f3aeafcb6ec8650af0aa703f41925e8 (patch)
tree4164fb595d5c1e820d98962f890f01044a3bd976
parentfd0109ecd077f53d0fdf3746bc5d2a8c8f1e82e7 (diff)
parent6e086f0e703194fcefe0040e2b5e967fa5ab307f (diff)
downloaddevtools-ea39ed2b8f3aeafcb6ec8650af0aa703f41925e8.tar.xz
Merge tag '20130408' into complete
tagging Conflicts: mkarchroot.in
-rw-r--r--Makefile2
-rw-r--r--bash_completion.in2
-rw-r--r--makechrootpkg.in33
-rw-r--r--mkarchroot.in22
-rw-r--r--zsh_completion.in1
5 files changed, 35 insertions, 25 deletions
diff --git a/Makefile b/Makefile
index acae452..3bb6464 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-V=20130406
+V=20130408
PREFIX = /usr/local
diff --git a/bash_completion.in b/bash_completion.in
index cd959fc..9395d3a 100644
--- a/bash_completion.in
+++ b/bash_completion.in
@@ -53,7 +53,7 @@ _mkarchroot() {
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
diff --git a/makechrootpkg.in b/makechrootpkg.in
index 717e02f..10956c9 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
@@ -81,7 +84,6 @@ chrootdir=$(readlink -e "$passeddir")
if [[ ${copy:0:1} = / ]]; then
copydir=$copy
else
- [[ -z $copy ]] && copy=$default_copy
copydir="$chrootdir/$copy"
fi
@@ -303,6 +305,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
diff --git a/mkarchroot.in b/mkarchroot.in
index cff046f..a33ba59 100644
--- a/mkarchroot.in
+++ b/mkarchroot.in
@@ -12,7 +12,6 @@ m4_include(lib/common.sh)
CHROOT_VERSION='v3'
-FORCE='n'
MODE='i'
NOCOPY='n'
NONETWORK='n'
@@ -25,7 +24,6 @@ APPNAME=$(basename "${0}")
usage() {
echo "Usage: ${APPNAME} [options] working-dir [exta-arguments]"
echo ' options:'
- echo ' -f Force overwrite of files in the working-dir'
echo ' -C <file> Location of a pacman config file'
echo ' -M <file> Location of a makepkg config file'
echo ' -n Do not copy config files into the chroot'
@@ -44,9 +42,8 @@ usage() {
################################################################################
-while getopts 'fC:M:nc:Niruh' arg; do
+while getopts 'C:M:nc:Niruh' arg; do
case "${arg}" in
- f) FORCE='y' ;;
C) pac_conf="$OPTARG" ;;
M) makepkg_conf="$OPTARG" ;;
n) NOCOPY='y' ;;
@@ -179,18 +176,18 @@ if [[ $MODE == r ]]; then
# }}}
elif [[ $MODE == i ]]; then
# {{{ build chroot
- if [[ -e $working_dir && $FORCE = 'n' ]]; then
- die "Working directory '${working_dir}' already exists - try using -f"
+ if [[ -e $working_dir ]]; then
+ die "Working directory '${working_dir}' already exists"
fi
- if [[ ! -d "${working_dir}" ]]; then
- mkdir -p "${working_dir}"
- fi
+ mkdir -p "${working_dir}"
if [[ "$(stat -f -c %T "${working_dir}")" == btrfs ]]; then
- if { type -P btrfs && btrfs subvolume create "${working_dir}"; } &>/dev/null; then
- chmod 0755 "${working_dir}"
+ rmdir "${working_dir}"
+ if ! btrfs subvolume create "${working_dir}"; then
+ die "Couldn't create subvolume for '${working_dir}'"
fi
+ chmod 0755 "${working_dir}"
fi
chroot_lock
@@ -200,9 +197,6 @@ elif [[ $MODE == i ]]; then
pacargs+=("--config=${pac_conf}")
fi
- if [[ $FORCE = 'y' ]]; then
- pacargs+=("--force")
- fi
if ! pacstrap -GMcd "${working_dir}" "${pacargs[@]}" "$@"; then
die 'Failed to install all packages'
fi
diff --git a/zsh_completion.in b/zsh_completion.in
index 727112a..c3abdfd 100644
--- a/zsh_completion.in
+++ b/zsh_completion.in
@@ -42,7 +42,6 @@ _makechrootpkg_args=(
_mkarchroot_args=(
'-r[Run a program within the context of the chroot]:app'
'-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'
'-M[Location of a makepkg config file]:makepkg_config:_files'
'-n[Do not copy config files into the chroot]'