index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | scripts/Makefile.am | 3 | ||||
-rw-r--r-- | scripts/makepkg.sh.in | 123 |
diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 014ae870..6f0f25a2 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -60,6 +60,7 @@ pacman-optimize: $(srcdir)/pacman-optimize.sh.in rankmirrors: $(srcdir)/rankmirrors.py.in repo-add: $(srcdir)/repo-add.sh.in repo-remove: $(srcdir)/repo-add.sh.in - ln -sf repo-add repo-remove + rm -f repo-remove + $(LN_S) repo-add repo-remove # vim:set ts=2 sw=2 noet: diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 94cb942e..38081721 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1052,27 +1052,27 @@ devel_check() { # number to avoid having to determine the version number twice. # Also do a brief check to make sure we have the VCS tool available. oldpkgver=$pkgver - if [ ! -z ${_darcstrunk} ] && [ ! -z ${_darcsmod} ] ; then + if [ -n "${_darcstrunk}" -a -n "${_darcsmod}" ] ; then [ $(type -p darcs) ] || return 0 msg "$(gettext "Determining latest darcs revision...")" newpkgver=$(date +%Y%m%d) - elif [ ! -z ${_cvsroot} ] && [ ! -z ${_cvsmod} ] ; then + elif [ -n "${_cvsroot}" -a -n "${_cvsmod}" ] ; then [ $(type -p cvs) ] || return 0 msg "$(gettext "Determining latest cvs revision...")" newpkgver=$(date +%Y%m%d) - elif [ ! -z ${_gitroot} ] && [ ! -z ${_gitname} ] ; then + elif [ -n "${_gitroot}" -a -n "${_gitname}" ] ; then [ $(type -p git) ] || return 0 msg "$(gettext "Determining latest git revision...")" newpkgver=$(date +%Y%m%d) - elif [ ! -z ${_svntrunk} ] && [ ! -z ${_svnmod} ] ; then + elif [ -n "${_svntrunk}" -a -n "${_svnmod}" ] ; then [ $(type -p svn) ] || return 0 msg "$(gettext "Determining latest svn revision...")" newpkgver=$(LC_ALL=C svn info $_svntrunk | sed -n 's/^Last Changed Rev: \([0-9]*\)$/\1/p') - elif [ ! -z ${_bzrtrunk} ] && [ ! -z ${_bzrmod} ] ; then + elif [ -n "${_bzrtrunk}" -a -n "${_bzrmod}" ] ; then [ $(type -p bzr) ] || return 0 msg "$(gettext "Determining latest bzr revision...")" newpkgver=$(bzr revno ${_bzrtrunk}) - elif [ ! -z ${_hgroot} ] && [ ! -z ${_hgrepo} ] ; then + elif [ -n "${_hgroot}" -a -n "${_hgrepo}" ] ; then [ $(type -p hg) ] || return 0 msg "$(gettext "Determining latest hg revision...")" if [ -d ./src/$_hgrepo ] ; then @@ -1113,14 +1113,101 @@ devel_update() { if [ "$newpkgver" != "" ]; then if [ "$newpkgver" != "$pkgver" ]; then if [ -f "./$BUILDSCRIPT" ]; then - sed -i "s/^pkgver=[^ ]*/pkgver=$newpkgver/" ./$BUILDSCRIPT - sed -i "s/^pkgrel=[^ ]*/pkgrel=1/" ./$BUILDSCRIPT - source $BUILDSCRIPT + sed -i "s/^pkgver=[^ ]*/pkgver=$newpkgver/" "./$BUILDSCRIPT" + sed -i "s/^pkgrel=[^ ]*/pkgrel=1/" "./$BUILDSCRIPT" + source "$BUILDSCRIPT" fi fi fi } +# getopt like parser +parse_options() { + local short_options=$1; shift; + local long_options=$1; shift; + local ret=0; + local unused_options="" + + while [ -n "$1" ]; do + if [ ${1:0:2} = '--' ]; then + if [ -n "${1:2}" ]; then + local match="" + for i in ${long_options//,/ }; do + if [ ${1:2} = ${i//:} ]; then + match=$i + break + fi + done + if [ -n "$match" ]; then + if [ ${1:2} = $match ]; then + printf ' %s' "$1" + else + if [ -n "$2" ]; then + printf ' %s' "$1" + shift + printf " '%s'" "$1" + else + echo "makepkg: option '$1' $(gettext "requires an argument")" >&2 + ret=1 + fi + fi + else + echo "makepkg: $(gettext "unrecognized option") '$1'" >&2 + ret=1 + fi + else + shift + break + fi + elif [ ${1:0:1} = '-' ]; then + for ((i=1; i<${#1}; i++)); do + if [[ "$short_options" =~ "${1:i:1}" ]]; then + if [[ "$short_options" =~ "${1:i:1}:" ]]; then + if [ -n "${1:$i+1}" ]; then + printf ' -%s' "${1:i:1}" + printf " '%s'" "${1:$i+1}" + else + if [ -n "$2" ]; then + printf ' -%s' "${1:i:1}" + shift + printf " '%s'" "${1}" + else + echo "makepkg: option $(gettext "requires an argument") -- '${1:i:1}'" >&2 + ret=1 + fi + fi + break + else + printf ' -%s' "${1:i:1}" + fi + else + echo "makepkg: $(gettext "invalid option") -- '${1:i:1}'" >&2 + ret=1 + fi + done + else + unused_options="${unused_options} '$1'" + fi + shift + done + + printf " --" + if [ -n "$unused_options" ]; then + for i in ${unused_options[@]}; do + printf ' %s' "$i" + done + fi + if [ -n "$1" ]; then + while [ -n "$1" ]; do + printf " '%s'" "${1}" + shift + done + fi + printf "\n" + + return $ret +} + usage() { printf "makepkg (pacman) %s\n" "$myver" echo @@ -1186,8 +1273,8 @@ OPT_LONG="$OPT_LONG,install,log,nocolor,nobuild,rmdeps,repackage,source" 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!')" -if echo "$OPT_TEMP" | grep -q 'GETOPT GO BANG!'; then +OPT_TEMP="$(parse_options $OPT_SHORT $OPT_LONG "$@" || echo 'PARSE_OPTIONS FAILED')" +if echo "$OPT_TEMP" | grep -q 'PARSE_OPTIONS FAILED'; then # This is a small hack to stop the script bailing with 'set -e' echo; usage; exit 1 # E_INVALID_OPTION; fi @@ -1299,7 +1386,7 @@ if [ "$CLEANCACHE" = "1" ]; then fi fi -if [ -z $BUILDSCRIPT ]; then +if [ -z "$BUILDSCRIPT" ]; then error "$(gettext "BUILDSCRIPT is undefined! Ensure you have updated %s.")" "$MAKEPKG_CONF" exit 1 fi @@ -1389,11 +1476,11 @@ if [ -z "$pkgrel" ]; then error "$(gettext "%s is not allowed to be empty.")" "pkgrel" exit 1 fi -if [ $(echo "$pkgver" | grep '-') ]; then +if [ "$pkgver" != "${pkgver//-/}" ]; then error "$(gettext "%s is not allowed to contain hyphens.")" "pkgver" exit 1 fi -if [ $(echo "$pkgrel" | grep '-') ]; then +if [ "$pkgrel" != "${pkgrel//-/}" ]; then error "$(gettext "%s is not allowed to contain hyphens.")" "pkgrel" exit 1 fi @@ -1411,6 +1498,14 @@ if ! in_array $CARCH ${arch[@]}; then fi fi +for provide in ${provides[@]}; do + if [ $provide != ${provide//</} -o $provide != ${provide//>/} ]; then + error "$(gettext "Provides array cannot contain comparison (< or >) operators.")" + exit 1 + fi +done +unset provide + if [ "$install" -a ! -f "$install" ]; then error "$(gettext "Install scriptlet (%s) does not exist.")" "$install" exit 1 |