Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=d1242909c33c8d7955b4d8fed2f8c94724ba940f

commit d1242909c33c8d7955b4d8fed2f8c94724ba940f
Author: Michel Hermier <[email protected]>
Date:   Wed Nov 28 16:27:56 2012 +0100

scripts/makepkg

* Create new buildscript command.
* Move buildscript_load near the buildscript command.

diff --git a/scripts/makepkg b/scripts/makepkg
index 60b85c4..9a6a769 100755
--- a/scripts/makepkg
+++ b/scripts/makepkg
@@ -588,186 +588,6 @@ buildscript_download() {
done
}

-buildscript_load() {
-       if [ ! -f "$BUILDSCRIPT" ]; then
-               error "$BUILDSCRIPT does not exist."
-               exit 1
-       fi
-
-       local i
-
-       unset pkgname pkgver pkgrel pkgdesc url license groups provides force
-       unset replaces depends removes conflicts backup source install 
makedepends
-       unset rodepends options pkdesc_localized
-       for i in `set|grep ^_F_|sed 's/\(=.*\| ()\)//'`; do unset $i; done
-
-       # You have to declare associative array before using them :/
-       declare -Ag \
-               _P_package_descriptions \
-               _P_package_licenses \
-               _P_package_replaces \
-               _P_package_groups \
-               _P_package_depends \
-               _P_package_rodepends \
-               _P_package_removes \
-               _P_package_conflicts \
-               _P_package_provides \
-               _P_package_backups \
-               _P_package_installs \
-               _P_package_options \
-               _P_package_archs \
-               _P_package_archives
-
-       source ./$BUILDSCRIPT
-
-       if [ "`type -p fblint`" ]; then
-               if ! fblint -p "$BUILDSCRIPT" &>/dev/null; then
-                       warning "fblint says some needed variables are missing 
or incomplete."
-                       plain "Abort the build unless you know what you are 
doing."
-               fi
-       fi
-
-       if [ -z "$pkgver" ]; then
-               error "pkgver is not allowed to be empty."
-               exit 1
-       fi
-       if [ -z "$pkgrel" ]; then
-               error "pkgrel is not allowed to be empty."
-               exit 1
-       fi
-       if [ `$ECHO $pkgver | grep '-'` ]; then
-               error "pkgver is not allowed to contain hyphens."
-               exit 1
-       fi
-       if [ `$ECHO $pkgrel | grep '-'` ]; then
-               error "pkgrel is not allowed to contain hyphens."
-               exit 1
-       fi
-       if ! in_array $CARCH ${archs[@]}; then
-               error "$pkgname is not available on $CARCH."
-               exit 1
-       fi
-
-       if [ ! -z "$subpkgs" ]; then
-               goodsubpkgs=1
-               if [ "${#subdescs[@]}" != 0 ] && [ "${#subdescs[@]}" != 
"${#subpkgs[@]}" ]; then
-                       goodsubpkgs=0
-               fi
-               if [ "${#subdescs_localized[@]}" != 0 ] && [ 
"${#subdescs_localized[@]}" != "${#subpkgs[@]}" ]; then
-                       goodsubpkgs=0
-               fi
-               if [ "${#sublicense[@]}" != 0 ] && [ "${#sublicense[@]}" != 
"${#subpkgs[@]}" ]; then
-                       goodsubpkgs=0
-               fi
-               if [ "${#subreplaces[@]}" != 0 ] && [ "${#subreplaces[@]}" != 
"${#subpkgs[@]}" ]; then
-                       goodsubpkgs=0
-               fi
-               if [ "${#subgroups[@]}" != 0 ] && [ "${#subgroups[@]}" != 
"${#subpkgs[@]}" ]; then
-                       goodsubpkgs=0
-               fi
-               if [ "${#subdepends[@]}" != 0 ] && [ "${#subdepends[@]}" != 
"${#subpkgs[@]}" ]; then
-                       goodsubpkgs=0
-               fi
-               if [ "${#subrodepends[@]}" != 0 ] && [ "${#subrodepends[@]}" != 
"${#subpkgs[@]}" ]; then
-                       goodsubpkgs=0
-               fi
-               if [ "${#subremoves[@]}" != 0 ] && [ "${#subremoves[@]}" != 
"${#subpkgs[@]}" ]; then
-                       goodsubpkgs=0
-               fi
-               if [ "${#subconflicts[@]}" != 0 ] && [ "${#subconflicts[@]}" != 
"${#subpkgs[@]}" ]; then
-                       goodsubpkgs=0
-               fi
-               if [ "${#subprovides[@]}" != 0 ] && [ "${#subprovides[@]}" != 
"${#subpkgs[@]}" ]; then
-                       goodsubpkgs=0
-               fi
-               if [ "${#subbackup[@]}" != 0 ] && [ "${#subbackup[@]}" != 
"${#subpkgs[@]}" ]; then
-                       goodsubpkgs=0
-               fi
-               if [ "${#subinstall[@]}" != 0 ] && [ "${#subinstall[@]}" != 
"${#subpkgs[@]}" ]; then
-                       goodsubpkgs=0
-               fi
-               if [ "${#suboptions[@]}" != 0 ] && [ "${#suboptions[@]}" != 
"${#subpkgs[@]}" ]; then
-                       goodsubpkgs=0
-               fi
-               if [ "${#subarchs[@]}" != 0 ] && [ "${#subarchs[@]}" != 
"${#subpkgs[@]}" ]; then
-                       goodsubpkgs=0
-               fi
-               if [ $goodsubpkgs -ne 1 ]; then
-                       error "Subpackage infos are incomplete. Cannot create 
subpackages."
-                       exit 1
-               fi
-       fi
-
-       # Compatibility adaptation
-       if [ "${#_P_package_names[@]}" -eq 0 ]; then
-               _P_options="${options[*]}"
-
-               _P_package_names=("${pkgname}" "${subpkgs[@]}")
-               _P_package_descriptions["${pkgname}"]="${pkgdesc}"
-               for i in "${pkgdesc_localized[@]}"; do
-                       _P_package_descriptions["${pkgname}"]+="$($ECHO -en 
"\n$i")"
-               done
-               _P_package_licenses["${pkgname}"]="${license[*]}"
-               _P_package_replaces["${pkgname}"]="${replaces[*]}"
-               _P_package_groups["${pkgname}"]="${groups[*]}"
-               _P_package_depends["${pkgname}"]="${depends[*]}"
-               _P_package_rodepends["${pkgname}"]="${rodepends[*]}"
-               _P_package_removes["${pkgname}"]="${removes[*]}"
-               _P_package_conflicts["${pkgname}"]="${conflicts[*]}"
-               _P_package_provides["${pkgname}"]="${provides[*]}"
-               _P_package_backups["${pkgname}"]="${backup[*]}"
-               _P_package_installs["${pkgname}"]="${install}"
-               _P_package_options["${pkgname}"]="${options[*]}"
-               _P_package_archs["${pkgname}"]="${archs[*]}"
-
-               i=0
-               for subpkg in "${subpkgs[@]}"; do
-                       _P_package_descriptions["${subpkg}"]="$($ECHO -en 
"${subdescs[$i]}\n${subdescs_localized[$i]}")"
-                       _P_package_licenses["${subpkg}"]="${sublicense[$i]}"
-                       _P_package_replaces["${subpkg}"]="${subreplaces[$i]}"
-                       _P_package_groups["${subpkg}"]="${subgroups[$i]}"
-                       _P_package_depends["${subpkg}"]="${subdepends[$i]}"
-                       _P_package_rodepends["${subpkg}"]="${subrodepends[$i]}"
-                       _P_package_removes["${subpkg}"]="${subremoves[$i]}"
-                       _P_package_conflicts["${subpkg}"]="${subconflicts[$i]}"
-                       _P_package_provides["${subpkg}"]="${subprovides[$i]}"
-                       _P_package_backups["${subpkg}"]="${subbackup[$i]}"
-                       _P_package_installs["${subpkg}"]="${subinstall[$i]}"
-                       _P_package_options["${subpkg}"]="${suboptions[$i]}"
-                       _P_package_archs["${subpkg}"]="${subarchs[$i]}"
-                       i=$(($i+1))
-               done
-       fi
-
-       # Check _P_package_names on your arch
-       i=0
-       while [ $i -lt ${#_P_package_names[@]} ]; do
-               if in_array $CARCH 
${_P_package_archs["${_P_package_names["$i"]}"]}; then
-                       
_P_package_archives["${_P_package_names["$i"]}"]="${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKG_EXT}"
-                       i=$(($i+1))
-               else
-                       warning "Package ${_P_package_names["$i"]} is not 
available on your ARCH, dropping it!"
-                       unset _P_package_names["$i"]
-               fi
-       done
-
-       local pkgname
-       for pkgname in "${_P_package_names[@]}"; do
-               if [ -n "$_P_package_installs["$pkgname"]" ]; then
-                       # FIXME we should allways be in startdir here
-                       if [ ! -e "$install" -a ! -e "$startdir/$install" ] && 
! check_option GENSCRIPTLET; then
-                               error "Missing install scriptlet. If this is 
intentional, add 'genscriptlet' to options()."
-                               exit 1
-                       fi
-               else
-                       if [ -e "${pkgname}.install" ]; then
-                               warning "Automagically found install script for 
$pkgname"
-                               
_P_package_installs["$pkgname"]="${pkgname}.install"
-                       fi
-               fi
-       done
-}
-
buildscript_up2date() {
if [ "$NOUP2DATE" -eq 1 ]; then
return 0
@@ -1480,7 +1300,7 @@ repoman_loadconfig() {
[ -n "$bases" ] && TREE="$TREE,$bases"
fi

-       if [-z "$CACHEURL" ]; then
+       if [ -z "$CACHEURL" ]; then
eval "serverlist=${TREE}_servers"
if [ "$F_makepkg_scm" = "git" -a ! "`check_option NOVERSRC`" ]; then
_serverlist=`GIT_DIR=$fst_root/${TREE}/.git git config --get remote.origin.url 
2>/dev/null`
@@ -1701,6 +1521,7 @@ makepkg_parseargs() {
if [ "$NOBUILD" -eq 1 ]; then
CHROOT="${CHROOT:-0}"
NODEPS="${NODEPS:-1}"
+               RMDEPS="${RMDEPS:-0}"
fi

CACHEURL="${CACHEURL:-}"
@@ -1907,7 +1728,7 @@ makepkg_build_cmd() {

buildscript_download

-       buildscript_load
+       makepkg_buildscript "$BUILDSCRIPT"

if [ -f "$PKGDEST/${_P_package_archives["${pkgname}"]}" -a "$FORCE" = "0" -a 
"$GENSHA1" = "0" ]; then
if [ "$INSTALL" = "1" ]; then
@@ -1955,6 +1776,239 @@ makepkg_build_cmd() {
install_pkg
}

+_makepkg_buildscript_load() {
+       local i
+
+       unset pkgname pkgver pkgrel pkgdesc url license groups provides force
+       unset replaces depends removes conflicts backup source install 
makedepends
+       unset rodepends options pkdesc_localized
+       for i in `set|grep ^_F_|sed 's/\(=.*\| ()\)//'`; do unset $i; done
+
+       # You have to declare associative array before using them :/
+       declare -Ag \
+               _P_package_descriptions \
+               _P_package_licenses \
+               _P_package_replaces \
+               _P_package_groups \
+               _P_package_depends \
+               _P_package_rodepends \
+               _P_package_removes \
+               _P_package_conflicts \
+               _P_package_provides \
+               _P_package_backups \
+               _P_package_installs \
+               _P_package_options \
+               _P_package_archs \
+               _P_package_archives
+
+       if source "./$1"; then
+               true
+       else
+               return $?
+       fi
+
+       if [ "`type -p fblint`" ]; then
+               if ! fblint -p "$1" &>/dev/null; then
+                       warning "fblint says some needed variables are missing 
or incomplete."
+                       plain "Abort the build unless you know what you are 
doing."
+               fi
+       fi
+
+       if [ -z "$pkgver" ]; then
+               error "pkgver is not allowed to be empty."
+               exit 1
+       fi
+       if [ -z "$pkgrel" ]; then
+               error "pkgrel is not allowed to be empty."
+               exit 1
+       fi
+       if [ `$ECHO $pkgver | grep '-'` ]; then
+               error "pkgver is not allowed to contain hyphens."
+               exit 1
+       fi
+       if [ `$ECHO $pkgrel | grep '-'` ]; then
+               error "pkgrel is not allowed to contain hyphens."
+               exit 1
+       fi
+       if ! in_array $CARCH ${archs[@]}; then
+               error "$pkgname is not available on $CARCH."
+               exit 1
+       fi
+
+       if [ ! -z "$subpkgs" ]; then
+               goodsubpkgs=1
+               if [ "${#subdescs[@]}" != 0 ] && [ "${#subdescs[@]}" != 
"${#subpkgs[@]}" ]; then
+                       goodsubpkgs=0
+               fi
+               if [ "${#subdescs_localized[@]}" != 0 ] && [ 
"${#subdescs_localized[@]}" != "${#subpkgs[@]}" ]; then
+                       goodsubpkgs=0
+               fi
+               if [ "${#sublicense[@]}" != 0 ] && [ "${#sublicense[@]}" != 
"${#subpkgs[@]}" ]; then
+                       goodsubpkgs=0
+               fi
+               if [ "${#subreplaces[@]}" != 0 ] && [ "${#subreplaces[@]}" != 
"${#subpkgs[@]}" ]; then
+                       goodsubpkgs=0
+               fi
+               if [ "${#subgroups[@]}" != 0 ] && [ "${#subgroups[@]}" != 
"${#subpkgs[@]}" ]; then
+                       goodsubpkgs=0
+               fi
+               if [ "${#subdepends[@]}" != 0 ] && [ "${#subdepends[@]}" != 
"${#subpkgs[@]}" ]; then
+                       goodsubpkgs=0
+               fi
+               if [ "${#subrodepends[@]}" != 0 ] && [ "${#subrodepends[@]}" != 
"${#subpkgs[@]}" ]; then
+                       goodsubpkgs=0
+               fi
+               if [ "${#subremoves[@]}" != 0 ] && [ "${#subremoves[@]}" != 
"${#subpkgs[@]}" ]; then
+                       goodsubpkgs=0
+               fi
+               if [ "${#subconflicts[@]}" != 0 ] && [ "${#subconflicts[@]}" != 
"${#subpkgs[@]}" ]; then
+                       goodsubpkgs=0
+               fi
+               if [ "${#subprovides[@]}" != 0 ] && [ "${#subprovides[@]}" != 
"${#subpkgs[@]}" ]; then
+                       goodsubpkgs=0
+               fi
+               if [ "${#subbackup[@]}" != 0 ] && [ "${#subbackup[@]}" != 
"${#subpkgs[@]}" ]; then
+                       goodsubpkgs=0
+               fi
+               if [ "${#subinstall[@]}" != 0 ] && [ "${#subinstall[@]}" != 
"${#subpkgs[@]}" ]; then
+                       goodsubpkgs=0
+               fi
+               if [ "${#suboptions[@]}" != 0 ] && [ "${#suboptions[@]}" != 
"${#subpkgs[@]}" ]; then
+                       goodsubpkgs=0
+               fi
+               if [ "${#subarchs[@]}" != 0 ] && [ "${#subarchs[@]}" != 
"${#subpkgs[@]}" ]; then
+                       goodsubpkgs=0
+               fi
+               if [ $goodsubpkgs -ne 1 ]; then
+                       error "Subpackage infos are incomplete. Cannot create 
subpackages."
+                       exit 1
+               fi
+       fi
+
+       # Compatibility adaptation
+       if [ "${#_P_package_names[@]}" -eq 0 ]; then
+               _P_options="${options[*]}"
+
+               _P_package_names=("${pkgname}" "${subpkgs[@]}")
+               _P_package_descriptions["${pkgname}"]="${pkgdesc}"
+               for i in "${pkgdesc_localized[@]}"; do
+                       _P_package_descriptions["${pkgname}"]+="$($ECHO -en 
"\n$i")"
+               done
+               _P_package_licenses["${pkgname}"]="${license[*]}"
+               _P_package_replaces["${pkgname}"]="${replaces[*]}"
+               _P_package_groups["${pkgname}"]="${groups[*]}"
+               _P_package_depends["${pkgname}"]="${depends[*]}"
+               _P_package_rodepends["${pkgname}"]="${rodepends[*]}"
+               _P_package_removes["${pkgname}"]="${removes[*]}"
+               _P_package_conflicts["${pkgname}"]="${conflicts[*]}"
+               _P_package_provides["${pkgname}"]="${provides[*]}"
+               _P_package_backups["${pkgname}"]="${backup[*]}"
+               _P_package_installs["${pkgname}"]="${install}"
+               _P_package_options["${pkgname}"]="${options[*]}"
+               _P_package_archs["${pkgname}"]="${archs[*]}"
+
+               i=0
+               for subpkg in "${subpkgs[@]}"; do
+                       _P_package_descriptions["${subpkg}"]="$($ECHO -en 
"${subdescs[$i]}\n${subdescs_localized[$i]}")"
+                       _P_package_licenses["${subpkg}"]="${sublicense[$i]}"
+                       _P_package_replaces["${subpkg}"]="${subreplaces[$i]}"
+                       _P_package_groups["${subpkg}"]="${subgroups[$i]}"
+                       _P_package_depends["${subpkg}"]="${subdepends[$i]}"
+                       _P_package_rodepends["${subpkg}"]="${subrodepends[$i]}"
+                       _P_package_removes["${subpkg}"]="${subremoves[$i]}"
+                       _P_package_conflicts["${subpkg}"]="${subconflicts[$i]}"
+                       _P_package_provides["${subpkg}"]="${subprovides[$i]}"
+                       _P_package_backups["${subpkg}"]="${subbackup[$i]}"
+                       _P_package_installs["${subpkg}"]="${subinstall[$i]}"
+                       _P_package_options["${subpkg}"]="${suboptions[$i]}"
+                       _P_package_archs["${subpkg}"]="${subarchs[$i]}"
+                       i=$(($i+1))
+               done
+       fi
+
+       # Check _P_package_names on your arch
+       i=0
+       while [ $i -lt ${#_P_package_names[@]} ]; do
+               if in_array $CARCH 
${_P_package_archs["${_P_package_names["$i"]}"]}; then
+                       
_P_package_archives["${_P_package_names["$i"]}"]="${pkgname}-${pkgver}-${pkgrel}-${CARCH}.${PKG_EXT}"
+                       i=$(($i+1))
+               else
+                       warning "Package ${_P_package_names["$i"]} is not 
available on your ARCH, dropping it!"
+                       unset _P_package_names["$i"]
+               fi
+       done
+
+       local pkgname
+       for pkgname in "${_P_package_names[@]}"; do
+               if [ -n "$_P_package_installs["$pkgname"]" ]; then
+                       # FIXME we should allways be in startdir here
+                       if [ ! -e "$install" -a ! -e "$startdir/$install" ] && 
! check_option GENSCRIPTLET; then
+                               error "Missing install scriptlet. If this is 
intentional, add 'genscriptlet' to options()."
+                               exit 1
+                       fi
+               else
+                       if [ -e "${pkgname}.install" ]; then
+                               warning "Automagically found install script for 
$pkgname"
+                               
_P_package_installs["$pkgname"]="${pkgname}.install"
+                       fi
+               fi
+       done
+}
+
+makepkg_buildscript_usage() {
+       $ECHO "makepkg"
+       $ECHO
+       $ECHO "Usage: $0 buildscript [buildfile] [options] [--] [command 
[args]...]"
+       $ECHO
+       $ECHO "Options for sources command:"
+       $ECHO "  -h, --help             This help"
+}
+
+makepkg_buildscript() {
+       local consumed buildfile
+
+       if [ -e "$1" ]; then
+               buildfile="$1"
+               shift
+       else
+               buildfile="$BUILDSCRIPT_DEFAULT"
+       fi
+
+       while [ $# -gt 0 ]; do
+               consumed=1
+               case "$1" in
+               -h|--help)              makepkg_buildscript_usage; return 0 ;;
+# special options
+               --)                     shift; break;; # End of options
+               --*|-?)                 makepkg_buildscript_usage; return 1 ;;
+               -*)                     # Combined short options
+                                       split="$1"
+                                       shift
+                                       set -- \
+                                               "$(echo "$split}" | cut -c -2)" 
\
+                                               "-$(echo "${split}" | cut -c 
3-)" \
+                                               "$@"
+                                       continue ;;
+               *)                      break ;; # End of options
+               esac
+               if ! shift "$consumed"; then
+                       consumed=$(($consumed - 1))
+                       error "Option $1 expects $consumed argument(s)"
+                       return 1
+               fi
+       done
+
+       if [ ! -f "$buildfile" ]; then
+               error "$buildfile does not exist."
+               return 1
+       fi
+
+       if ! _makepkg_buildscript_load "$buildfile"; then
+#              error "$buildfile while errors loading file."
+               return 1
+       fi
+}
+
makepkg_ccache_usage() {
$ECHO "makepkg"
$ECHO
@@ -2156,8 +2210,9 @@ makepkg_main() {
ccache)         shift; makepkg_ccache "$@" ;;
chroot)         shift; makepkg_chroot "$@" ;;
fakeroot)       shift; makepkg_fakeroot "$@" ;;
-       *)              makepkg_build_cmd ;;
+       *)              makepkg_build_cmd "$@" ;;
esac
+       return $?
}

#
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to