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:
Diffstat (limited to 'scripts/makepkg.sh.in')
-rw-r--r--scripts/makepkg.sh.in94
1 files changed, 66 insertions, 28 deletions
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 30e6b711..d5b41144 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -26,6 +26,11 @@
# USA.
#
+# makepkg uses quite a few external programs during its execution. You
+# need to have at least the following installed for makepkg to function:
+# awk, bsdtar (libarchive), bzip2, coreutils, fakeroot, find (findutils),
+# getopt (util-linux), gettext, grep, gzip, sed
+
# gettext initialization
export TEXTDOMAIN='pacman'
export TEXTDOMAINDIR='@localedir@'
@@ -61,7 +66,7 @@ PACMAN_OPTS=
plain() {
local mesg=$1; shift
- if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
+ if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
printf "\033[1;37m ${mesg}\033[0m\n" "$@" >&2
else
printf " ${mesg}\n" "$@" >&2
@@ -70,7 +75,7 @@ plain() {
msg() {
local mesg=$1; shift
- if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
+ if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
printf "\033[1;32m==>\033[1;37m ${mesg}\033[0m\n" "$@" >&2
else
printf "==> ${mesg}\n" "$@" >&2
@@ -79,7 +84,7 @@ msg() {
msg2() {
local mesg=$1; shift
- if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
+ if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
printf "\033[1;34m ->\033[1;37m ${mesg}\033[0m\n" "$@" >&2
else
printf " -> ${mesg}\n" "$@" >&2
@@ -88,7 +93,7 @@ msg2() {
warning() {
local mesg=$1; shift
- if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
+ if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
printf "\033[1;33m==> $(gettext "WARNING:")\033[1;37m ${mesg}\033[0m\n" "$@" >&2
else
printf "==> $(gettext "WARNING:") ${mesg}\n" "$@" >&2
@@ -97,7 +102,7 @@ warning() {
error() {
local mesg=$1; shift
- if [ ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
+ if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
printf "\033[1;31m==> $(gettext "ERROR:")\033[1;37m ${mesg}\033[0m\n" "$@" >&2
else
printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2
@@ -294,9 +299,9 @@ get_downloadclient() {
check_deps() {
[ $# -gt 0 ] || return
- pmout=$(pacman $PACMAN_OPTS -T $*)
+ pmout=$(pacman $PACMAN_OPTS -T "$@")
ret=$?
- if [ $ret -eq 1 ]; then #unresolved deps
+ if [ $ret -eq 127 ]; then #unresolved deps
echo "$pmout"
elif [ $ret -ne 0 ]; then
error "$(gettext "Pacman returned a fatal error (%i): %s")" "$ret" "$pmout"
@@ -327,9 +332,9 @@ handledeps() {
local ret=0
if [ "$ASROOT" = 0 ]; then
- sudo pacman $PACMAN_OPTS -S $striplist || ret=$?
+ sudo pacman $PACMAN_OPTS -S --asdeps $striplist || ret=$?
else
- pacman $PACMAN_OPTS -S $striplist || ret=$?
+ pacman $PACMAN_OPTS -S --asdeps $striplist || ret=$?
fi
if [ $ret -ne 0 ]; then
@@ -433,16 +438,25 @@ remove_deps() {
download_sources() {
msg "$(gettext "Retrieving Sources...")"
+
+ if [ ! -w "$SRCDEST" ] ; then
+ error "$(gettext "You do not have write permission to store downloads in %s.")" "$SRCDEST"
+ plain "$(gettext "Aborting...")"
+ exit 1
+ fi
+
+ pushd "$SRCDEST" &>/dev/null
+
local netfile
for netfile in ${source[@]}; do
local file=$(strip_url "$netfile")
- if [ -f "../$file" ]; then
+ if [ -f "$startdir/$file" ]; then
msg2 "$(gettext "Found %s in build dir")" "$file"
- cp "../$file" .
+ cp -s --remove-destination "$startdir/$file" "$srcdir/"
continue
elif [ -f "$SRCDEST/$file" ]; then
msg2 "$(gettext "Using cached copy of %s")" "$file"
- cp "$SRCDEST/$file" .
+ cp -s --remove-destination "$SRCDEST/$file" "$srcdir/"
continue
fi
@@ -458,17 +472,10 @@ download_sources() {
plain "$(gettext "Aborting...")"
exit 1
fi
-
- if [ -n "$SRCDEST" ]; then
- mkdir -p "$SRCDEST" && cp "$file" "$SRCDEST" || ret=$?
- if [ $ret -gt 0 ]; then
- warning "$(gettext "You do not have correct permissions to cache source in %s")" "$SRCDEST"
- cp "$file" ..
- fi
- else
- cp "$file" ..
- fi
+ cp -s --remove-destination "$SRCDEST/$file" "$srcdir/"
done
+
+ popd &>/dev/null
}
generate_checksums() {
@@ -504,6 +511,17 @@ generate_checksums() {
local netfile
for netfile in ${source[@]}; do
local file="$(strip_url "$netfile")"
+
+ if [ ! -f "$file" ] ; then
+ if [ ! -f "$SRCDEST/$file" ] ; then
+ error "$(gettext "Unable to find source file %s to generate checksum.")" "$file"
+ plain "$(gettext "Aborting...")"
+ exit 1
+ else
+ file=$SRCDEST/$file
+ fi
+ fi
+
local sum="$(${integ}sum "$file" | cut -d ' ' -f 1)"
[ $ct -gt 0 ] && echo -n "$indent"
echo -n "'$sum'"
@@ -541,6 +559,16 @@ check_checksums() {
file="$(strip_url "$file")"
echo -n " $file ... " >&2
+ if [ ! -f "$file" ] ; then
+ if [ ! -f "$file" ] ; then
+ echo "$(gettext "NOT FOUND")" >&2
+ errors=1
+ continue
+ else
+ file=$SRCDEST/$file
+ fi
+ fi
+
if echo "${integrity_sums[$idx]} $file" | ${integ}sum --status -c - &>/dev/null; then
echo "$(gettext "Passed")" >&2
else
@@ -548,7 +576,7 @@ check_checksums() {
errors=1
fi
- idx=$(($idx+1))
+ idx=$((idx + 1))
done
if [ $errors -gt 0 ]; then
@@ -572,8 +600,18 @@ extract_sources() {
continue
fi
+ if [ ! -f "$file" ] ; then
+ if [ ! -f "$SRCDEST/$file" ] ; then
+ error "$(gettext "Unable to find source file %s for extraction.")" "$file"
+ plain "$(gettext "Aborting...")"
+ exit 1
+ else
+ file=$SRCDEST/$file
+ fi
+ fi
+
# fix flyspray #6246
- local file_type=$(file -biz "$file")
+ local file_type=$(file -bizL "$file")
local cmd=''
case "$file_type" in
*application/x-tar*|*application/x-zip*|*application/x-cpio*)
@@ -631,7 +669,7 @@ run_build() {
umask 0022
# ensure all necessary build variables are exported
- export CFLAGS CXXFLAGS MAKEFLAGS
+ export CFLAGS CXXFLAGS MAKEFLAGS CHOST
local ret=0
if [ "$LOGGING" = "1" ]; then
@@ -1107,13 +1145,13 @@ if [ "$INFAKEROOT" = "0" ]; then
error "$(gettext "The --asroot option is meant for the root user only.")"
plain "$(gettext "Please rerun makepkg without the --asroot flag.")"
exit 1 # $E_USER_ABORT
- elif [ "$(check_buildenv fakeroot)" = "y" ]; 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"
exit 1
fi
- else
+ 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.")"
@@ -1174,7 +1212,7 @@ if [ $(echo "$pkgrel" | grep '-') ]; then
fi
if ! in_array $CARCH ${arch[@]}; then
- if "$IGNOREARCH" = "0" ]; then
+ if [ "$IGNOREARCH" = "0" ]; then
error "$(gettext "%s is not available for the '%s' architecture.")" "$pkgname" "$CARCH"
plain "$(gettext "Note that many packages may need a line added to their %s")" "$BUILDSCRIPT"
plain "$(gettext "such as arch=('%s').")" "$CARCH"