summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/chroot-tools/librechroot14
-rwxr-xr-xsrc/chroot-tools/libremakepkg14
-rwxr-xr-xsrc/chroot-tools/libremakepkg.gpl21
-rwxr-xr-xsrc/chroot-tools/libremkchroot6
-rw-r--r--src/libretools.conf4
5 files changed, 22 insertions, 17 deletions
diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot
index e39b105..d43ea2f 100755
--- a/src/chroot-tools/librechroot
+++ b/src/chroot-tools/librechroot
@@ -51,6 +51,7 @@ sync() {
lock_close 8
}
+cmd=${0##*/}
usage() {
echo "Usage: $cmd [OPTIONS] [CHROOT] "
echo 'Interacts with a chroot.'
@@ -80,7 +81,7 @@ main() {
[[ $CHROOTCOPY != root ]] || CHROOTCOPY=copy
local mode=enter
- local archroot_args=()
+ local archroot_args=(-f)
local ARG=''
while getopts 'l:NCcI:i:nrsuh' arg; do
case $arg in
@@ -90,7 +91,7 @@ main() {
C) mode=clean_repo;;
c) mode=clean_pacman;;
I) mode=install_file; ARG=$OPTARG;;
- I) mode=install_pkg; ARG=$OPTARG;;
+ i) mode=install_pkg; ARG=$OPTARG;;
n) mode=noop;;
r) mode=run; ARG=$OPTARG;;
s) mode=sync;;
@@ -118,7 +119,7 @@ main() {
# Keep this lock as long as we are running
# Note that '9' is the same FD number as in (mk)archroot
- lock_open_write 9 "$copydir" "Locking chroot copy '$copy'"
+ lock_open_write 9 "$copydir" "Locking chroot copy '$CHROOTCOPY'"
if [[ ! -d $rootdir ]]; then
libremkchroot "$CHROOT"
@@ -139,8 +140,11 @@ main() {
clean_pacman)
msg "Intelligently cleaning packages"
cp -a "$(dirname $0)/chcleanup" "${copydir}/clean"
- mkdir -p "$copydir/build"
- archroot "${archroot_args[@]}" "${copydir}" -r "cd /build; /clean"
+ echo '#!/bin/bash' > "${copydir}/cleanstrap"
+ echo 'mkdir /build' >> "${copydir}/cleanstrap"
+ echo 'cd /build; /clean' >> "${copydir}/cleanstrap"
+ chmod 755 "${copydir}/cleanstrap"
+ archroot "${archroot_args[@]}" "${copydir}" -r /cleanstrap
;;
install_file)
msg "Installing package file: $ARG"
diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg
index b9107d8..f06bb17 100755
--- a/src/chroot-tools/libremakepkg
+++ b/src/chroot-tools/libremakepkg
@@ -62,10 +62,10 @@ makepkg_conf_get() {
if [[ -f $LIBREHOME/.makepkg.conf ]]; then
eval $(grep "^$setting=" "$LIBREHOME/.makepkg.conf")
fi
- if [[ -z ${!setting} ]]; then
+ if [[ -z ${!setting:-} ]]; then
eval $(grep "^$setting=" "/etc/makepkg.conf")
fi
- if [[ -z ${!setting} && -n ${2} ]]; then
+ if [[ -z ${!setting:-} && -n ${2} ]]; then
eval "$setting='$2'"
fi
}
@@ -78,7 +78,7 @@ chroot_makepkg_conf_get() {
chroot_makepkg_conf_set() {
local key=$1
local val=$2
- sed -i "/^$KEY=/d" "$copydir/etc/makepkg.conf"
+ sed -i "/^$key=/d" "$copydir/etc/makepkg.conf"
echo "$key='$val'" >> "$copydir/etc/makepkg.conf"
}
@@ -133,7 +133,7 @@ main() {
CHROOTCOPY=$LIBREUSER
[[ $CHROOTCOPY != root ]] || CHROOTCOPY=copy
- makepkg_args=(-s --noconfirm -L)
+ makepkg_args='-s --noconfirm -L '
REPACKAGE=false
MAKEPKG=makepkg
@@ -142,14 +142,14 @@ main() {
n) CHROOT=$OPTARG;;
l) CHROOTCOPY=$OPTARG;;
m) MAKEPKG=$OPTARG;;
- R) REPACKAGE=true; makepkg_args+=(-R);;
+ R) REPACKAGE=true; makepkg_args+=' -R ';;
h) usage; exit 0;;
*) usage; exit 1;;
esac
done
shift $(($OPTIND - 1))
# Pass all arguments after -- right to makepkg
- makepkg_args+=("$@")
+ makepkg_args+=" $*"
rootdir="${CHROOTDIR}/${CHROOT}/root"
copydir="${CHROOTDIR}/${CHROOT}/${CHROOTCOPY}"
@@ -176,7 +176,7 @@ main() {
# OK, we're starting now ###############################################
- lock_open_write 9 "$copydir.lock" "Locking chroot '$copy'"
+ lock_open_write 9 "$copydir" "Locking chroot '$CHROOTCOPY'"
# Set target CARCH as it might be used within the PKGBUILD to select correct sources
chroot_makepkg_conf_get CARCH
diff --git a/src/chroot-tools/libremakepkg.gpl2 b/src/chroot-tools/libremakepkg.gpl2
index 1f2d185..cd279b8 100755
--- a/src/chroot-tools/libremakepkg.gpl2
+++ b/src/chroot-tools/libremakepkg.gpl2
@@ -37,6 +37,7 @@ chroot_extract() {
rm -rf "$copydir"/build/*
cp PKGBUILD "$copydir/build/"
(
+ set +euE
source PKGBUILD
# Copy source files
diff --git a/src/chroot-tools/libremkchroot b/src/chroot-tools/libremkchroot
index 992c6e5..d3652a5 100755
--- a/src/chroot-tools/libremkchroot
+++ b/src/chroot-tools/libremkchroot
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/bash -euE
# libremkchroot
# Copyright 2011, 2012 Luke Shumaker
@@ -37,7 +37,7 @@ usage() {
}
main() {
- archroot_args=();
+ archroot_args=(-f);
while getopts 'hC:M:' arg; do
case "$arg" in
C|M) archroot_args+=("-$arg" "$OPTARG");;
@@ -59,7 +59,7 @@ main() {
fi
mkdir -p "${CHROOTDIR}/${CHROOT}"
- archroot "${chroot_args[@]}" "${CHROOTDIR}/${CHROOT}/root" -i base base-devel sudo "${CHROOTEXTRAPKG[@]}"
+ archroot "${archroot_args[@]}" "${CHROOTDIR}/${CHROOT}/root" -i base base-devel sudo "${CHROOTEXTRAPKG[@]}"
}
main "$@"
diff --git a/src/libretools.conf b/src/libretools.conf
index 20c7d90..91ec452 100644
--- a/src/libretools.conf
+++ b/src/libretools.conf
@@ -108,8 +108,8 @@ TORUPATH=/var/lib/libretools/toru
################################################################################
LIBREUSER="${SUDO_USER:-$USER}"
-LIBREHOME="$(eval echo ~$SUDO_USER)"
-if [[ -z $XDG_CONFIG_HOME ]]; then
+LIBREHOME="$(eval echo ~$LIBREUSER)"
+if [[ -z ${XDG_CONFIG_HOME:-} ]]; then
export XDG_CONFIG_HOME="${LIBREHOME}/.config"
fi
if [[ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]]; then