summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/chroot-tools/librechroot14
-rwxr-xr-xsrc/chroot-tools/libremakepkg32
-rwxr-xr-xsrc/chroot-tools/libremakepkg.gpl21
-rwxr-xr-xsrc/chroot-tools/libremkchroot6
-rw-r--r--src/libretools.conf6
5 files changed, 32 insertions, 27 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 b6c84c1..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"
}
@@ -111,20 +111,20 @@ libre_check_pkg() {
# The main program #############################################################
+cmd=${0##*/}
usage() {
- echo 'cd to a dir containing a PKGBUILD and run:'
- echo '$0 [options] [-- makepkg args]'
- echo 'This script will build your package in a chroot.'
+ echo "Usage: $cmd [options] [-- makepkg args]"
+ echo 'This program will build your package.'
echo ''
echo 'OPTIONS:'
- echo " -n <CHROOT> Use this chroot instead of \`$CHROOT'"
- echo ' -l <COPY> Use this chroot copy instead of basing it'
- echo ' on the username'
+ echo " -n <CHROOT> Use this chroot instead of \`$CHROOT'"
+ echo ' -l <COPY> Use this chroot copy instead of basing it'
+ echo ' on the username'
echo ''
- echo " -m <MAKEPKG> Use the command MAKEPKG instead of 'makepkg'"
- echo " -R Repackage"
+ echo " -m <MAKEPKG> Use the command MAKEPKG instead of 'makepkg'"
+ echo " -R Repackage"
echo ''
- echo ' -h Show this message'
+ echo ' -h Show this message'
}
main() {
@@ -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..37453e1 100644
--- a/src/libretools.conf
+++ b/src/libretools.conf
@@ -29,7 +29,7 @@ ARCHES=('i686' 'x86_64' 'mips64el' 'any')
################################################################################
## The directory where the chroots are stored
-CHROOTDIR=/home/chroot
+CHROOTDIR=/var/lib/archbuild
## Extra packages to have installed on the chroot (besides base base-devel and sudo)
CHROOTEXTRAPKG=(distcc ccache tsocks)
## The meaning of this changes based on the version of libretools+devtools
@@ -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