summaryrefslogtreecommitdiffstats
path: root/scripts/makepkg.sh.in
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/makepkg.sh.in')
-rw-r--r--scripts/makepkg.sh.in136
1 files changed, 78 insertions, 58 deletions
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 1d70f39b..ff05e481 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -278,7 +278,7 @@ get_downloadclient() {
# if we didn't find an agent, return an error
if [ -z "$agent" ]; then
- error "$(gettext "There is no agent set up to handle %s URLs. Check %s.")" "$proto" "$confdir/makepkg.conf"
+ error "$(gettext "There is no agent set up to handle %s URLs. Check %s.")" "$proto" "$MAKEPKG_CONF"
plain "$(gettext "Aborting...")"
exit 1 # $E_CONFIG_ERROR
fi
@@ -488,6 +488,11 @@ generate_checksums() {
msg "$(gettext "Generating checksums for source files...")"
plain ""
+ if [ ! $(type -p openssl) ]; then
+ error "$(gettext "Cannot find openssl.")"
+ exit 1 # $E_MISSING_PROGRAM
+ fi
+
local integ
for integ in ${INTEGRITY_CHECK[@]}; do
integ="$(echo $integ | tr '[:upper:]' '[:lower:]')"
@@ -498,11 +503,6 @@ generate_checksums() {
exit 1;; # $E_CONFIG_ERROR
esac
- if [ ! $(type -p openssl) ]; then
- error "$(gettext "Cannot find openssl.")"
- exit 1 # $E_MISSING_PROGRAM
- fi
-
local ct=0
local numsrc=${#source[@]}
echo -n "${integ}sums=("
@@ -540,21 +540,13 @@ generate_checksums() {
}
check_checksums() {
- local integ
- for integ in ${INTEGRITY_CHECK[@]}; do
- integ="$(echo $integ | tr '[:upper:]' '[:lower:]')"
- case "$integ" in
- md5|sha1|sha256|sha384|sha512) : ;;
- *)
- error "$(gettext "Invalid integrity algorithm '%s' specified")" "$integ"
- exit 1;; # $E_CONFIG_ERROR
- esac
-
- if [ ! $(type -p openssl) ]; then
- error "$(gettext "Cannot find openssl.")"
- exit 1 # $E_MISSING_PROGRAM
- fi
+ if [ ! $(type -p openssl) ]; then
+ error "$(gettext "Cannot find openssl.")"
+ exit 1 # $E_MISSING_PROGRAM
+ fi
+ local integ required
+ for integ in md5 sha1 sha256 sha384 sha512; do
local integrity_sums=($(eval echo "\${${integ}sums[@]}"))
if [ ${#integrity_sums[@]} -eq ${#source[@]} ]; then
msg "$(gettext "Validating source files with %s...")" "${integ}sums"
@@ -592,7 +584,13 @@ check_checksums() {
exit 1 # TODO: error code
fi
else
- warning "$(gettext "Integrity checks (%s) are missing or incomplete.")" "$integ"
+ for required in ${INTEGRITY_CHECK[@]}; do
+ required="$(echo $required | tr '[:upper:]' '[:lower:]')"
+ if [ "$integ" = "$required" ]; then
+ warning "$(gettext "Integrity checks (%s) are missing or incomplete.")" "$integ"
+ break
+ fi
+ done
fi
done
}
@@ -709,16 +707,16 @@ tidy_install() {
msg "$(gettext "Tidying install...")"
if [ "$(check_option docs)" = "n" ]; then
- msg2 "$(gettext "Removing info/doc files...")"
+ msg2 "$(gettext "Removing doc files...")"
#fix flyspray bug #5021
rm -rf ${DOC_DIRS[@]}
fi
if [ "$(check_option zipman)" = "y" ]; then
- msg2 "$(gettext "Compressing man pages...")"
+ msg2 "$(gettext "Compressing man and info pages...")"
local manpage mandirs ext file link hardlinks hl
- mandirs="usr/man usr/share/man usr/local/man usr/local/share/man opt/*/man"
- find ${mandirs} -type f 2>/dev/null |
+ mandirs=({usr{,/local}{,/share},opt/*}/{man,info})
+ find ${mandirs[@]} -type f 2>/dev/null |
while read manpage ; do
# check file still exists (potentially compressed with hard link)
if [ -f ${manpage} ]; then
@@ -726,7 +724,7 @@ tidy_install() {
file="${manpage##*/}"
if [ "$ext" != "gz" -a "$ext" != "bz2" ]; then
# update symlinks to this manpage
- find ${mandirs} -lname "$file" 2>/dev/null |
+ find ${mandirs[@]} -lname "$file" 2>/dev/null |
while read link ; do
rm -f "$link"
ln -sf "${file}.gz" "${link}.gz"
@@ -734,7 +732,7 @@ tidy_install() {
# find hard links and remove them
# the '|| true' part keeps the script from bailing if find returned an
# error, such as when one of the man directories doesn't exist
- hardlinks="$(find ${mandirs} \! -name "$file" -samefile "$manpage" 2>/dev/null)" || true
+ hardlinks="$(find ${mandirs[@]} \! -name "$file" -samefile "$manpage" 2>/dev/null)" || true
for hl in ${hardlinks}; do
rm -f "${hl}";
done
@@ -873,13 +871,21 @@ create_package() {
# tar it up
msg2 "$(gettext "Compressing package...")"
+ local TAR_OPT
+ case "$PKGEXT" in
+ *tar.gz) TAR_OPT="z" ;;
+ *tar.bz2) TAR_OPT="j" ;;
+ *) warning "$(gettext "'%s' is not a valid archive extension.")" \
+ "$PKGEXT" ;;
+ esac
+
local pkg_file="$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}"
# when fileglobbing, we want * in an empty directory to expand to
# the null string rather than itself
shopt -s nullglob
- if ! bsdtar -czf "$pkg_file" $comp_files *; then
+ if ! bsdtar -c${TAR_OPT}f "$pkg_file" $comp_files *; then
error "$(gettext "Failed to create package file.")"
exit 1 # TODO: error code
fi
@@ -994,12 +1000,20 @@ create_srcpackage() {
fi
done
+ local TAR_OPT
+ case "$SRCEXT" in
+ *tar.gz) TAR_OPT="z" ;;
+ *tar.bz2) TAR_OPT="j" ;;
+ *) warning "$(gettext "'%s' is not a valid archive extension.")" \
+ "$SRCEXT" ;;
+ esac
+
local pkg_file="$PKGDEST/${pkgname}-${pkgver}-${pkgrel}${SRCEXT}"
# tar it up
msg2 "$(gettext "Compressing source package...")"
cd "${srclinks}"
- if ! bsdtar -czLf "$pkg_file" ${pkgname}; then
+ if ! bsdtar -c${TAR_OPT}Lf "$pkg_file" ${pkgname}; then
error "$(gettext "Failed to create source package file.")"
exit 1 # TODO: error code
fi
@@ -1104,6 +1118,7 @@ usage() {
printf "$(gettext " -A, --ignorearch Ignore incomplete arch field in %s")\n" "$BUILDSCRIPT"
echo "$(gettext " -c, --clean Clean up work files after build")"
echo "$(gettext " -C, --cleancache Clean up source files from the cache")"
+ printf "$(gettext " --config <config> Use an alternate config file (instead of '%s')")\n" "$confdir/makepkg.conf"
echo "$(gettext " -d, --nodeps Skip all dependency checks")"
echo "$(gettext " -e, --noextract Do not extract source files (use existing src/ dir)")"
echo "$(gettext " -f, --force Overwrite existing package")"
@@ -1151,36 +1166,12 @@ fi
ARGLIST=$@
-#preserve environment variables
-_PKGDEST=${PKGDEST}
-_SRCDEST=${SRCDEST}
-
-# Source makepkg.conf; fail if it is not found
-if [ -r "$confdir/makepkg.conf" ]; then
- source "$confdir/makepkg.conf"
-else
- error "$(gettext "%s not found.")" "$confdir/makepkg.conf"
- plain "$(gettext "Aborting...")"
- exit 1 # $E_CONFIG_ERROR
-fi
-
-# Source user-specific makepkg.conf overrides
-if [ -r ~/.makepkg.conf ]; then
- source ~/.makepkg.conf
-fi
-
-# override settings with an environment variable for batch processing
-PKGDEST=${_PKGDEST:-$PKGDEST}
-PKGDEST=${PKGDEST:-$startdir} #default to $startdir if undefined
-SRCDEST=${_SRCDEST:-$SRCDEST}
-SRCDEST=${SRCDEST:-$startdir} #default to $startdir if undefined
-
# Parse Command Line Options.
OPT_SHORT="AbcCdefFghiLmop:rRsV"
OPT_LONG="allsource,asroot,ignorearch,builddeps,clean,cleancache,nodeps"
OPT_LONG="$OPT_LONG,noextract,force,forcever:,geninteg,help,holdver"
OPT_LONG="$OPT_LONG,install,log,nocolor,nobuild,rmdeps,repackage,source"
-OPT_LONG="$OPT_LONG,syncdeps,version"
+OPT_LONG="$OPT_LONG,syncdeps,version,config:"
# Pacman Options
OPT_LONG="$OPT_LONG,noconfirm,noprogressbar"
OPT_TEMP="$(getopt -o "$OPT_SHORT" -l "$OPT_LONG" -n "$(basename "$0")" -- "$@" || echo 'GETOPT GO BANG!')"
@@ -1203,6 +1194,7 @@ while true; do
-A|--ignorearch) IGNOREARCH=1 ;;
-c|--clean) CLEANUP=1 ;;
-C|--cleancache) CLEANCACHE=1 ;;
+ --config) shift; MAKEPKG_CONF=$1 ;;
-d|--nodeps) NODEPS=1 ;;
-e|--noextract) NOEXTRACT=1 ;;
-f|--force) FORCE=1 ;;
@@ -1230,6 +1222,34 @@ while true; do
shift
done
+#preserve environment variables
+_PKGDEST=${PKGDEST}
+_SRCDEST=${SRCDEST}
+
+# default config is makepkg.conf
+MAKEPKG_CONF=${MAKEPKG_CONF:-$confdir/makepkg.conf}
+
+# Source the config file; fail if it is not found
+if [ -r "$MAKEPKG_CONF" ]; then
+ source "$MAKEPKG_CONF"
+else
+ error "$(gettext "%s not found.")" "$MAKEPKG_CONF"
+ plain "$(gettext "Aborting...")"
+ exit 1 # $E_CONFIG_ERROR
+fi
+
+# Source user-specific makepkg.conf overrides
+if [ -r ~/.makepkg.conf ]; then
+ source ~/.makepkg.conf
+fi
+
+# override settings with an environment variable for batch processing
+PKGDEST=${_PKGDEST:-$PKGDEST}
+PKGDEST=${PKGDEST:-$startdir} #default to $startdir if undefined
+SRCDEST=${_SRCDEST:-$SRCDEST}
+SRCDEST=${SRCDEST:-$startdir} #default to $startdir if undefined
+
+
if [ "$HOLDVER" = "1" -a "$FORCE_VER" != "" ]; then
# The '\\0' is here to prevent gettext from thinking --holdver is an option
error "$(gettext "\\0--holdver and --forcever cannot both be specified" )"
@@ -1261,14 +1281,14 @@ if [ "$CLEANCACHE" = "1" ]; then
fi
else
# $SRCDEST is $startdir, two possibilities
- error "$(gettext "Source destination must be defined in makepkg.conf.")"
+ error "$(gettext "Source destination must be defined in %s.")" "$MAKEPKG_CONF"
plain "$(gettext "In addition, please run makepkg -C outside of your cache directory.")"
exit 1
fi
fi
if [ -z $BUILDSCRIPT ]; then
- error "$(gettext "BUILDSCRIPT is undefined! Ensure you have updated %s.")" "$confdir/makepkg.conf"
+ error "$(gettext "BUILDSCRIPT is undefined! Ensure you have updated %s.")" "$MAKEPKG_CONF"
exit 1
fi
@@ -1287,13 +1307,13 @@ if [ "$INFAKEROOT" = "0" ]; then
elif [ "$(check_buildenv fakeroot)" = "y" -a $EUID -gt 0 ]; then
if [ ! $(type -p fakeroot) ]; then
error "$(gettext "Fakeroot must be installed if using the 'fakeroot' option")"
- plain "$(gettext "in the BUILDENV array in %s.")" "$confdir/makepkg.conf"
+ plain "$(gettext "in the BUILDENV array in %s.")" "$MAKEPKG_CONF"
exit 1
fi
elif [ $EUID -gt 0 ]; then
warning "$(gettext "Running makepkg as an unprivileged user will result in non-root")"
plain "$(gettext "ownership of the packaged files. Try using the fakeroot environment by")"
- plain "$(gettext "placing 'fakeroot' in the BUILDENV array in makepkg.conf.")"
+ plain "$(gettext "placing 'fakeroot' in the BUILDENV array in %s.")" "$MAKEPKG_CONF"
sleep 1
fi
else