summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/chroot-tools/chroot.conf7
-rwxr-xr-xsrc/chroot-tools/librechroot5
-rwxr-xr-xsrc/chroot-tools/libremakepkg45
-rwxr-xr-xsrc/chroot-tools/libremakepkg.gpl24
-rwxr-xr-xsrc/chroot-tools/libremkchroot5
-rw-r--r--src/lib/Makefile2
-rw-r--r--src/lib/conf.sh115
-rw-r--r--src/libretools.conf23
8 files changed, 150 insertions, 56 deletions
diff --git a/src/chroot-tools/chroot.conf b/src/chroot-tools/chroot.conf
new file mode 100644
index 0000000..cd5c71d
--- /dev/null
+++ b/src/chroot-tools/chroot.conf
@@ -0,0 +1,7 @@
+## The directory where the chroots are stored
+CHROOTDIR=/var/lib/archbuild
+## Extra packages to have installed on the chroot (besides base base-devel and sudo)
+CHROOTEXTRAPKG=(distcc ccache tsocks libretools)
+## The meaning of this changes based on the version of libretools+devtools
+## do NOT set it to 'root'
+CHROOT=default
diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot
index 52a3bdf..0770ad6 100755
--- a/src/chroot-tools/librechroot
+++ b/src/chroot-tools/librechroot
@@ -20,7 +20,10 @@
# You should have received a copy of the GNU General Public License
# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
-. /etc/libretools.conf
+. /usr/share/libretools/conf.sh
+load_conf_libretools_chroot
+
+. "$(which libremessages)"
# This file (librechroot) is GPLv3+, but I would like to use some code
# modified from devtools' "makechrootpkg", which is GPLv2.
diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg
index ec7adbd..c66f5cc 100755
--- a/src/chroot-tools/libremakepkg
+++ b/src/chroot-tools/libremakepkg
@@ -20,7 +20,10 @@
# You should have received a copy of the GNU General Public License
# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
-. /etc/libretools.conf
+. /usr/share/libretools/conf.sh
+load_conf_libretools_chroot
+
+. "$(which libremessages)"
shopt -s nullglob
@@ -54,34 +57,6 @@ trap_exit() {
exit 1
}
-##
-# Usage: makepkg_conf_get SETTING [DEFAULT]
-##
-makepkg_conf_get() {
- local setting=$1
- if [[ -f $LIBREHOME/.makepkg.conf ]]; then
- eval $(grep "^$setting=" "$LIBREHOME/.makepkg.conf")
- fi
- if [[ -z ${!setting:-} ]]; then
- eval $(grep "^$setting=" "/etc/makepkg.conf")
- fi
- if [[ -z ${!setting:-} && -n ${2:-} ]]; then
- eval "$setting='$2'"
- fi
-}
-
-chroot_makepkg_conf_get() {
- local setting=$1
- eval $(grep "^$setting=" "$copydir/etc/makepkg.conf")
-}
-
-chroot_makepkg_conf_set() {
- local key=$1
- local val=$2
- sed -i "/^$key=/d" "$copydir/etc/makepkg.conf"
- echo "$key='$val'" >> "$copydir/etc/makepkg.conf"
-}
-
# Functions that check for issues with the build ###############################
libre_check_pkgbuild() {
@@ -172,16 +147,18 @@ main() {
trap 'trap_exit "(libremakepkg): Aborted by user! Exiting..."' INT
trap 'trap_exit "(libremakepkg): An unknown error has occurred. Exiting..."' ERR
- makepkg_conf_get SRCDEST .
- makepkg_conf_get PKGDEST .
+ SRCDEST="$(get_conf_makepkg SRCDEST .)"
+ PKGDEST="$(get_conf_makepkg PKGDEST .)"
# OK, we're starting now ###############################################
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
- export CARCH
+ # Set target CARCH as it might be used within the PKGBUILD to select
+ # correct sources
+ MAKEPKG_CONF=$copydir/etc/makepkg.conf
+ export CARCH="$(get_conf_makepkg CARCH)"
+ unset MAKEPKG_CONF
$NOCHROOT || chroot_init
diff --git a/src/chroot-tools/libremakepkg.gpl2 b/src/chroot-tools/libremakepkg.gpl2
index 3f66589..50bb48e 100755
--- a/src/chroot-tools/libremakepkg.gpl2
+++ b/src/chroot-tools/libremakepkg.gpl2
@@ -25,8 +25,8 @@ chroot_init() {
mkdir -p "$copydir/srcdest"
mkdir -p "$copydir/build"
- chroot_makepkg_conf_set PKGDEST /pkgdest
- chroot_makepkg_conf_set SRCDEST /srcdest
+ MAKEPKG_CONF=$copydir/etc/makepkg.conf set_conf_makepkg PKGDEST /pkgdest
+ MAKEPKG_CONF=$copydir/etc/makepkg.conf set_conf_makepkg SRCDEST /srcdest
cat > "$copydir/etc/sudoers.d/nobody-pacman" <<EOF
Defaults env_keep += "HOME"
diff --git a/src/chroot-tools/libremkchroot b/src/chroot-tools/libremkchroot
index d3652a5..6a13792 100755
--- a/src/chroot-tools/libremkchroot
+++ b/src/chroot-tools/libremkchroot
@@ -18,7 +18,10 @@
# You should have received a copy of the GNU General Public License
# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
-. /etc/libretools.conf
+. /usr/share/libretools/conf.sh
+load_conf_libretools_chroot
+
+. "$(which libremessages)"
cmd=${0##*/}
diff --git a/src/lib/Makefile b/src/lib/Makefile
new file mode 100644
index 0000000..0c69ba3
--- /dev/null
+++ b/src/lib/Makefile
@@ -0,0 +1,2 @@
+libre_datadir=$(datadir)/libretools
+include ../../common.mk
diff --git a/src/lib/conf.sh b/src/lib/conf.sh
new file mode 100644
index 0000000..7693ee5
--- /dev/null
+++ b/src/lib/conf.sh
@@ -0,0 +1,115 @@
+#!/bin/bash
+
+INCLUDE_CONF_SH=conf.sh
+
+LIBREUSER="${SUDO_USER:-$USER}"
+LIBREHOME="$(eval echo ~$LIBREUSER)"
+if [[ -z ${XDG_CONFIG_HOME:-} ]]; then
+ export XDG_CONFIG_HOME="${LIBREHOME}/.config"
+fi
+
+# Generic functions ############################################################
+
+get_files() {
+ local slug=$1
+ case $slug in
+ makepkg.conf)
+ if [[ $MAKEPKG_CONF != /etc/$slug && -r $MAKEPKG_CONF ]]; then
+ echo "$MAKEPKG_CONF"
+ else
+ echo /etc/$slug
+ echo "$LIBREHOME/.$slug"
+ fi
+ ;;
+ libretools.conf)
+ echo /etc/$slug
+ echo "$XDG_CONFIG_HOME/libretools/$slug"
+ ;;
+ *.conf)
+ echo /etc/libretools.d/$slug
+ echo "$XDG_CONFIG_HOME/libretools/$slug"
+ ;;
+ esac
+}
+
+load_files() {
+ for file in $(get_files $1.conf); do
+ if [[ -r $file ]]; then
+ . "$file"
+ fi
+ done
+}
+
+check_vars() {
+ local slug=$1
+ shift
+ local ret=0
+ for VAR in "$@"; do
+ if [[ -z ${!VAR} ]]; then
+ if [[ $(get_files $slug|wc -l) > 1 ]]; then
+ echo "Configure '$VAR' in one of:"
+ get_files $slug | sed 's/./ -> &/'
+ else
+ echo "Configure '$VAR' in $(get_files $slug)"
+ fi
+ ret=1
+ fi >>/dev/stderr
+ done
+ if [[ $ret != 0 ]]; then
+ return 1
+ fi
+}
+
+# makepkg configuration ########################################################
+
+[[ -n ${MAKEPKG_CONF:-} ]] || MAKEPKG_CONF=/etc/makepkg.conf
+
+load_conf_makepkg() {
+ load_files makepkg
+}
+
+get_conf_makepkg() (
+ set +euE
+ local setting=$1
+ local default=$2
+ load_conf_makepkg
+ printf '%s\n' "${!setting:-${default}}"
+)
+
+set_conf_makepkg() {
+ local key=$1
+ local val=$2
+ for file in `get_files makepkg.conf|tac`; do
+ if [[ -w $file ]]; then
+ sed -i "/^\s*$key=/d" "$file"
+ echo "$key='$val'" >> "$file"
+ return 0
+ fi
+ done
+ return 1
+}
+
+
+# libretools configuration #####################################################
+
+load_conf_libretools() {
+ load_files libretools
+ # TODO: checks
+}
+
+load_conf_libretools_chroot() {
+ load_files chroot
+ if [[ -f /.arch-chroot ]]; then
+ # check_vars chroot CHROOTEXTRAPKG
+ :
+ else
+ # check_vars chroot CHROOTDIR CHROOT CHROOTEXTRAPKG
+ local ret=0
+ check_vars chroot CHROOTDIR CHROOT || ret=$?
+ if [[ $CHROOT == root ]]; then
+ echo "Configured var CHROOT cannot equal 'root'"
+ ret=1
+ fi
+ return $ret;
+ fi
+}
diff --git a/src/libretools.conf b/src/libretools.conf
index 5e45350..9e17871 100644
--- a/src/libretools.conf
+++ b/src/libretools.conf
@@ -25,18 +25,6 @@ REPOS=('core' 'libre' 'extra' 'community' 'libre-testing' 'social' 'sugar' 'pcr'
ARCHES=('i686' 'x86_64' 'mips64el' 'any')
################################################################################
-# chroot #
-################################################################################
-
-## The directory where the chroots are stored
-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
-## do NOT set it to 'root'
-CHROOT=default
-
-################################################################################
# abslibre #
################################################################################
@@ -106,6 +94,8 @@ TORUPATH=/var/lib/libretools/toru
# This probably shouldn't be in a .conf file... #
################################################################################
+if [[ -n ${INCLUDE_CONF_SH:-} ]]; then
+
LIBREUSER="${SUDO_USER:-$USER}"
LIBREHOME="$(eval echo ~$LIBREUSER)"
if [[ -z ${XDG_CONFIG_HOME:-} ]]; then
@@ -116,22 +106,19 @@ if [[ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]]; then
fi
ret=0
-for VAR in CHROOTDIR CHROOT PARABOLAHOST LIBREDESTDIR \
+for VAR in PARABOLAHOST LIBREDESTDIR \
BLACKLIST WORKDIR REPOS ARCHES ABSLIBREGIT \
COMMITCMD DIFFTOOL FULLBUILDCMD SIGEXT SIGID; do
-
if [[ -z ${!VAR} ]]; then
echo "Configure $VAR var in /etc/libretools.conf"
ret=1
fi
done
-if [[ $CHROOT == root ]]; then
- echo "Configured var CHROOT cannot equal 'root'"
- ret=1
-fi
if [[ $ret != 0 ]]; then
exit 1
fi
unset ret
. /usr/bin/libremessages
+
+fi