summaryrefslogtreecommitdiff
path: root/src/chroot-tools/libremakepkg
diff options
context:
space:
mode:
Diffstat (limited to 'src/chroot-tools/libremakepkg')
-rwxr-xr-xsrc/chroot-tools/libremakepkg23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg
index a526ca2..d3dd160 100755
--- a/src/chroot-tools/libremakepkg
+++ b/src/chroot-tools/libremakepkg
@@ -5,7 +5,8 @@ set -euE
# Copyright (C) 2010-2012 Nicolás Reynolds <fauno@parabola.nu>
# Copyright (C) 2010-2012 Joshua Ismael Haase Hernández (xihh) <hahj87@gmail.com>
# Copyright (C) 2012 Michał Masłowski <mtjm@mtjm.eu>
-# Copyright (C) 2012-2015, 2017-2018 Luke Shumaker <lukeshu@parabola.nu>
+# Copyright (C) 2012-2015, 2017-2018, 2024 Luke Shumaker <lukeshu@parabola.nu>
+# Copyright (C) 2019, 2024 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
#
# License: GNU GPLv2+
#
@@ -36,6 +37,7 @@ umask 0022
readonly _indent="$(librelib chroot/indent)"
readonly INCHROOT=$([[ -f /.arch-chroot ]] && echo true || echo false)
NONET=true # can be changed with the -N flag
+ROSTARTDIR=true # can be changed with the -W flag
# {PKG,SRC,SRCPKG,LOG}DEST set at runtime by makepkg.conf
# MAKEFLAGS, PACKAGER set at runtime by makepkg.conf
# LIBREUSER, LIBREHOME are set by conf.sh
@@ -124,11 +126,19 @@ build() (
local run_ynet=()
local run_nnet=()
if $INCHROOT; then
- local _run=(sh -c "cd ${startdir@Q} && \$@" --)
+ if $ROSTARTDIR; then
+ local _run=(sh -c "mount --bind -o ro -- ${startdir@Q} ${startdir@Q} && cd ${startdir@Q} && \$@" --)
+ else
+ local _run=(sh -c "cd ${startdir@Q} && \$@" --)
+ fi
run_ynet=(unshare --mount -- "${_run[@]}")
run_nnet=(unshare --mount --net -- "${_run[@]}")
else
- librechroot_flags+=(-w "$startdir:/startdir")
+ if $ROSTARTDIR; then
+ librechroot_flags+=(-r "$startdir:/startdir")
+ else
+ librechroot_flags+=(-w "$startdir:/startdir")
+ fi
run_ynet=(librechroot "${librechroot_flags[@]}" run)
run_nnet=(librechroot "${librechroot_flags[@]}" -N run)
fi
@@ -181,6 +191,10 @@ usage() {
build(), and package(). PLEASE don't use
this unless you have a special reason, its
use is a violation of Parabola policy." \
+ '-W' "Don't make the startdir read-only. PLEASE
+ don't use this unless you have a special
+ reason, its use is a violation of Parabola
+ policy." \
'-R' 'Repackage contents of the package without
rebuilding' \
"-S <$(_ SRCPKGFILE)>" 'Use an existing --allsource source-package' \
@@ -203,7 +217,7 @@ main() {
local srcpkg=''
# Parse command line options ###########################################
- while getopts 'n:l:w:r:NRS:h' flag ; do
+ while getopts 'n:l:w:r:NWRS:h' flag ; do
case "${flag}" in
n) if $INCHROOT; then err_chflag "$flag"; else
chroot=$OPTARG; fi;;
@@ -212,6 +226,7 @@ main() {
w|r) if $INCHROOT; then err_chflag "$flag"; else
librechroot_flags+=(-$flag "$OPTARG"); fi;;
N) NONET=false;;
+ W) ROSTARTDIR=false;;
R) repack=true; makepkg_args+=(-R);;
S) srcpkg=$OPTARG;;
h) usage; exit $EXIT_SUCCESS;;