Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/scripts/makepkg.sh.in
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2018-02-07 23:56:01 -0500
committerAllan McRae <allan@archlinux.org>2018-03-14 17:47:51 +1000
commitd8717a6a9666ec80c8645d190d6f9c7ab73084ac (patch)
tree9bf11011019478fa1d1bd85677be0f493197f91b /scripts/makepkg.sh.in
parent0565cebfc387be67e0daac73a4d0a312965ca1d3 (diff)
makepkg: refactor checking for write permissions into a utility function
Additionally provide a separate error for failure to create the directory vs lack of write permissions on a pre-existing directory. This also means we now consistently try to create any nonexistent *DEST directories as needed before aborting with E_FS_PERMISSIONS. Previously only $BUILDDIR received that kindness. Fixes FS#43537 Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'scripts/makepkg.sh.in')
-rw-r--r--scripts/makepkg.sh.in25
1 files changed, 7 insertions, 18 deletions
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index adfb3604..4f803bc2 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1365,35 +1365,25 @@ else
fi
-if [[ ! -d $BUILDDIR ]]; then
- if ! mkdir -p "$BUILDDIR"; then
- error "$(gettext "You do not have write permission to create packages in %s.")" "$BUILDDIR"
- plain "$(gettext "Aborting...")"
- exit $E_FS_PERMISSIONS
- fi
- chmod a-s "$BUILDDIR"
-fi
-if [[ ! -w $BUILDDIR ]]; then
- error "$(gettext "You do not have write permission to create packages in %s.")" "$BUILDDIR"
+# check that all settings directories are user-writable
+if ! ensure_writable_dir "BUILDDIR" "$BUILDDIR"; then
plain "$(gettext "Aborting...")"
exit $E_FS_PERMISSIONS
fi
+chmod a-s "$BUILDDIR"
-if (( ! (NOBUILD || GENINTEG) )) && [[ ! -w $PKGDEST ]]; then
- error "$(gettext "You do not have write permission to store packages in %s.")" "$PKGDEST"
+if (( ! (NOBUILD || GENINTEG) )) && ! ensure_writable_dir "PKGDEST" "$PKGDEST"; then
plain "$(gettext "Aborting...")"
exit $E_FS_PERMISSIONS
fi
-if [[ ! -w $SRCDEST ]] ; then
- error "$(gettext "You do not have write permission to store downloads in %s.")" "$SRCDEST"
+if ! ensure_writable_dir "SRCDEST" "$SRCDEST" ; then
plain "$(gettext "Aborting...")"
exit $E_FS_PERMISSIONS
fi
if (( SOURCEONLY )); then
- if [[ ! -w $SRCPKGDEST ]]; then
- error "$(gettext "You do not have write permission to store source tarballs in %s.")" "$SRCPKGDEST"
+ if ! ensure_writable_dir "SRCPKGDEST" "$SRCPKGDEST"; then
plain "$(gettext "Aborting...")"
exit $E_FS_PERMISSIONS
fi
@@ -1403,8 +1393,7 @@ if (( SOURCEONLY )); then
IGNOREARCH=1
fi
-if (( LOGGING )) && [[ ! -w $LOGDEST ]]; then
- error "$(gettext "You do not have write permission to store logs in %s.")" "$LOGDEST"
+if (( LOGGING )) && ! ensure_writable_dir "LOGDEST" "$LOGDEST"; then
plain "$(gettext "Aborting...")"
exit $E_FS_PERMISSIONS
fi