From d338b3981dcfd039a60fae616886707e4d69fceb Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Sun, 3 Jun 2012 19:33:34 +1000 Subject: makepkg: remove VCS package support The current VCS packaging support is really, really, really bad. It is best to strip it out completely before rewriting it. Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 145 +++----------------------------------------------- 1 file changed, 6 insertions(+), 139 deletions(-) (limited to 'scripts') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index b30e9d04..fca1a970 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -70,7 +70,6 @@ REPKG=0 LOGGING=0 SOURCEONLY=0 IGNOREARCH=0 -HOLDVER=0 PREPAREFUNC=0 BUILDFUNC=0 CHECKFUNC=0 @@ -185,12 +184,7 @@ clean_up() { enter_fakeroot() { msg "$(gettext "Entering %s environment...")" "fakeroot" - - if [[ -n $newpkgver ]]; then - fakeroot -- $0 --forcever $newpkgver -F "${ARGLIST[@]}" || exit $? - else - fakeroot -- $0 -F "${ARGLIST[@]}" || exit $? - fi + fakeroot -- $0 -F "${ARGLIST[@]}" || exit $? } @@ -1794,114 +1788,6 @@ check_software() { return $ret } -devel_check() { - newpkgver="" - - # Do not update pkgver if --holdver is set, when building a source package, repackaging, - # reading PKGBUILD from pipe (-f), or if we cannot write to the file (-w) - if (( HOLDVER || SOURCEONLY || REPKG )) || - [[ ! -f $BUILDFILE || ! -w $BUILDFILE || $BUILDFILE = "/dev/stdin" ]]; then - return - fi - - if [[ -z $FORCE_VER ]]; then - # Check if this is a svn/cvs/etc PKGBUILD; set $newpkgver if so. - # This will only be used on the first call to makepkg; subsequent - # calls to makepkg via fakeroot will explicitly pass the version - # number to avoid having to determine the version number twice. - # Also do a check to make sure we have the VCS tool available. - local vcs=() - - [[ -n ${_darcstrunk} && -n ${_darcsmod} ]] && vcs+=("darcs") - [[ -n ${_cvsroot} && -n ${_cvsmod} ]] && vcs+=("cvs") - [[ -n ${_gitroot} && -n ${_gitname} ]] && vcs+=("git") - [[ -n ${_svntrunk} && -n ${_svnmod} ]] && vcs+=("svn") - [[ -n ${_bzrtrunk} && -n ${_bzrmod} ]] && vcs+=("bzr") - [[ -n ${_hgroot} && -n ${_hgrepo} ]] && vcs+=("hg") - - if (( ${#vcs[@]} == 0 )); then - return - elif (( ${#vcs[@]} > 1 )); then - warning "$(gettext "Ambiguous VCS package. Cannot pick from: %s.")" "${vcs[*]}" - return 0 - fi - - if ! type -p "$vcs" >/dev/null; then - warning "$(gettext "Cannot find the %s binary required to determine latest %s revision.")" "$vcs" "$vcs" - return 0 - fi - - msg "$(gettext "Determining latest %s revision...")" "$vcs" - - case "$vcs" in - darcs) - newpkgver=$(date +%Y%m%d) - ;; - cvs) - newpkgver=$(date +%Y%m%d) - ;; - git) - newpkgver=$(date +%Y%m%d) - ;; - svn) - newpkgver=$(LC_ALL=C svn info $_svntrunk | sed -n 's/^Last Changed Rev: \([0-9]*\)$/\1/p') - ;; - bzr) - newpkgver=$(bzr revno ${_bzrtrunk}) - ;; - hg) - if pushd "./src/$_hgrepo" > /dev/null; then - local ret=0 - hg pull || ret=$? - if (( ! ret )); then - hg update - elif (( ret != 1 )); then - return 1 - fi - else - [[ ! -d ./src/ ]] && mkdir ./src/ - hg clone "$_hgroot/$_hgrepo" "./src/$_hgrepo" - if ! pushd "./src/$_hgrepo" > /dev/null; then - warning "$(gettext "An error occured while determining the hg version number.")" - return 0 - fi - fi - newpkgver=$(hg tip --template "{rev}") - popd > /dev/null - ;; - esac - - if [[ -n $newpkgver ]]; then - msg2 "$(gettext "Version found: %s")" "$newpkgver" - fi - - else - # Version number retrieved from fakeroot->makepkg argument - newpkgver=$FORCE_VER - fi -} - -devel_update() { - # This is lame, but if we're wanting to use an updated pkgver for - # retrieving svn/cvs/etc sources, we'll update the PKGBUILD with - # the new pkgver and then re-source it. This is the most robust - # method for dealing with PKGBUILDs that use, e.g.: - # - # pkgver=23 - # ... - # _foo=pkgver - # - if [[ -n $newpkgver && $newpkgver != "$pkgver" ]]; then - if [[ -f $BUILDFILE && -w $BUILDFILE ]]; then - @SEDINPLACE@ "s/^pkgver=[^ ]*/pkgver=$newpkgver/" "$BUILDFILE" - @SEDINPLACE@ "s/^pkgrel=[^ ]*/pkgrel=1/" "$BUILDFILE" - source "$BUILDFILE" - else - warning "$(gettext "%s is not writeable -- pkgver will not be updated")" "$BUILDFILE" - fi - fi -} - backup_package_variables() { local var for var in ${splitpkg_overrides[@]}; do @@ -1980,7 +1866,6 @@ usage() { printf -- "$(gettext " --asroot Allow %s to run as root user")\n" "makepkg" printf -- "$(gettext " --check Run the %s function in the %s")\n" "check()" "$BUILDSCRIPT" printf -- "$(gettext " --config Use an alternate config file (instead of '%s')")\n" "$confdir/makepkg.conf" - printf -- "$(gettext " --holdver Prevent automatic version bumping for development %ss")\n" "$BUILDSCRIPT" printf -- "$(gettext " --key Specify a key to use for %s signing instead of the default")\n" "gpg" printf -- "$(gettext " --nocheck Do not run the %s function in the %s")\n" "check()" "$BUILDSCRIPT" printf -- "$(gettext " --nosign Do not create a signature for the package")\n" @@ -2022,11 +1907,11 @@ ARGLIST=("$@") # Parse Command Line Options. OPT_SHORT="AcdefFghiLmop:rRsSV" -OPT_LONG=('allsource' 'asroot' 'ignorearch' 'check' 'clean' 'nodeps' - 'noextract' 'force' 'forcever:' 'geninteg' 'help' 'holdver' 'skippgpcheck' - 'install' 'key:' 'log' 'nocolor' 'nobuild' 'nocheck' 'nosign' 'pkg:' 'rmdeps' - 'repackage' 'skipchecksums' 'skipinteg' 'skippgpcheck' 'sign' 'source' 'syncdeps' - 'version' 'config:') +OPT_LONG=('allsource' 'asroot' 'check' 'clean' 'config:' 'force' 'geninteg' + 'help' 'ignorearch' 'install' 'key:' 'log' 'nobuild' 'nocolor' + 'nocheck' 'nodeps' 'noextract' 'nosign' 'pkg:' 'repackage' 'rmdeps' + 'skipchecksums' 'skipinteg' 'skippgpcheck' 'skippgpcheck' 'sign' + 'source' 'syncdeps' 'version') # Pacman Options OPT_LONG+=('asdeps' 'noconfirm' 'noprogressbar') @@ -2054,11 +1939,8 @@ while true; do -d|--nodeps) NODEPS=1 ;; -e|--noextract) NOEXTRACT=1 ;; -f|--force) FORCE=1 ;; - #hidden opt used by fakeroot call for svn/cvs/etc PKGBUILDs to set pkgver - --forcever) shift; FORCE_VER=$1;; -F) INFAKEROOT=1 ;; -g|--geninteg) GENINTEG=1 ;; - --holdver) HOLDVER=1 ;; -i|--install) INSTALL=1 ;; --key) shift; GPGKEY=$1 ;; -L|--log) LOGGING=1 ;; @@ -2192,12 +2074,6 @@ SRCEXT=${_SRCEXT:-$SRCEXT} GPGKEY=${_GPGKEY:-$GPGKEY} PACKAGER=${_PACKAGER:-$PACKAGER} -if (( HOLDVER )) && [[ -n $FORCE_VER ]]; then - # The '\\0' is here to prevent gettext from thinking --holdver is an option - error "$(gettext "\\0%s and %s cannot both be specified" )" "--holdver" "--forcever" - exit 1 -fi - if (( ! INFAKEROOT )); then if (( EUID == 0 && ! ASROOT )); then # Warn those who like to live dangerously. @@ -2277,13 +2153,6 @@ check_sanity || exit 1 # check we have the software required to process the PKGBUILD check_software || exit 1 -# We need to run devel_update regardless of whether we are in the fakeroot -# build process so that if the user runs makepkg --forcever manually, we -# 1) output the correct pkgver, and 2) use the correct filename when -# checking if the package file already exists - fixes FS #9194 -devel_check -devel_update - if (( ${#pkgname[@]} > 1 )); then SPLITPKG=1 fi @@ -2524,7 +2393,6 @@ else # if we are root or if fakeroot is not enabled, then we don't use it if ! check_buildenv "fakeroot" "y" || (( EUID == 0 )); then if (( ! REPKG )); then - devel_update (( BUILDFUNC )) && run_build (( CHECKFUNC )) && run_check fi @@ -2546,7 +2414,6 @@ else fi else if (( ! REPKG && ( PKGFUNC || SPLITPKG ) )); then - devel_update (( BUILDFUNC )) && run_build (( CHECKFUNC )) && run_check cd_safe "$startdir" -- cgit v1.2.3-70-g09d2 From e8064144072e03ea1690c5aa97e863f14096a771 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Sun, 3 Jun 2012 22:08:25 +1000 Subject: makepkg: reorder source handling functions There is no actual code change here, but these related functions were all over the place which makes this code difficult to adjust. Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 240 +++++++++++++++++++++++++------------------------- 1 file changed, 120 insertions(+), 120 deletions(-) (limited to 'scripts') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index fca1a970..4cafa945 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -210,13 +210,6 @@ get_filepath() { printf "%s\n" "$file" } -# Print 'source not found' error message and exit makepkg -missing_source_file() { - error "$(gettext "Unable to find source file %s.")" "$(get_filename "$1")" - plain "$(gettext "Aborting...")" - exit 1 # $E_MISSING_FILE -} - # extract the filename from a source entry get_filename() { # if a filename is specified, use it @@ -231,6 +224,126 @@ get_url() { printf "%s\n" "${1#*::}" } +get_downloadclient() { + # $1 = URL with valid protocol prefix + local url=$1 + local proto="${url%%://*}" + + # loop through DOWNLOAD_AGENTS variable looking for protocol + local i + for i in "${DLAGENTS[@]}"; do + local handler="${i%%::*}" + if [[ $proto = "$handler" ]]; then + local agent="${i##*::}" + break + fi + done + + # 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" "$MAKEPKG_CONF" + plain "$(gettext "Aborting...")" + exit 1 # $E_CONFIG_ERROR + fi + + # ensure specified program is installed + local program="${agent%% *}" + if [[ ! -x $program ]]; then + local baseprog="${program##*/}" + error "$(gettext "The download program %s is not installed.")" "$baseprog" + plain "$(gettext "Aborting...")" + exit 1 # $E_MISSING_PROGRAM + fi + + printf "%s\n" "$agent" +} + +download_file() { + # download command + local dlcmd=$1 + # URL of the file + local url=$2 + # destination file + local file=$3 + # temporary download file, default to last component of the URL + local dlfile="${url##*/}" + + # replace %o by the temporary dlfile if it exists + if [[ $dlcmd = *%o* ]]; then + dlcmd=${dlcmd//\%o/\"$file.part\"} + dlfile="$file.part" + fi + # add the URL, either in place of %u or at the end + if [[ $dlcmd = *%u* ]]; then + dlcmd=${dlcmd//\%u/\"$url\"} + else + dlcmd="$dlcmd \"$url\"" + fi + + local ret=0 + eval "$dlcmd || ret=\$?" + if (( ret )); then + [[ ! -s $dlfile ]] && rm -f -- "$dlfile" + return $ret + fi + + # rename the temporary download file to the final destination + if [[ $dlfile != "$file" ]]; then + mv -f "$SRCDEST/$dlfile" "$SRCDEST/$file" + fi +} + +download_sources() { + msg "$(gettext "Retrieving Sources...")" + + pushd "$SRCDEST" &>/dev/null + + local netfile + for netfile in "${source[@]}"; do + local file=$(get_filepath "$netfile" || true) + if [[ -n "$file" ]]; then + msg2 "$(gettext "Found %s")" "${file##*/}" + rm -f "$srcdir/${file##*/}" + ln -s "$file" "$srcdir/" + continue + fi + + file=$(get_filename "$netfile") + local url=$(get_url "$netfile") + + # if we get here, check to make sure it was a URL, else fail + if [[ $file = "$url" ]]; then + error "$(gettext "%s was not found in the build directory and is not a URL.")" "$file" + exit 1 # $E_MISSING_FILE + fi + + # find the client we should use for this URL + local dlclient + dlclient=$(get_downloadclient "$url") || exit $? + + msg2 "$(gettext "Downloading %s...")" "$file" + # fix flyspray bug #3289 + local ret=0 + download_file "$dlclient" "$url" "$file" || ret=$? + if (( ret )); then + error "$(gettext "Failure while downloading %s")" "$file" + plain "$(gettext "Aborting...")" + exit 1 + fi + rm -f "$srcdir/$file" + ln -s "$SRCDEST/$file" "$srcdir/" + done + + popd &>/dev/null +} + +# Print 'source not found' error message and exit makepkg +missing_source_file() { + error "$(gettext "Unable to find source file %s.")" "$(get_filename "$1")" + plain "$(gettext "Aborting...")" + exit 1 # $E_MISSING_FILE +} + ## # usage : get_full_version( [$pkgname] ) # return : full version spec, including epoch (if necessary), pkgver, pkgrel @@ -388,75 +501,6 @@ source_has_signatures() { return 1 } -get_downloadclient() { - # $1 = URL with valid protocol prefix - local url=$1 - local proto="${url%%://*}" - - # loop through DOWNLOAD_AGENTS variable looking for protocol - local i - for i in "${DLAGENTS[@]}"; do - local handler="${i%%::*}" - if [[ $proto = "$handler" ]]; then - local agent="${i##*::}" - break - fi - done - - # 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" "$MAKEPKG_CONF" - plain "$(gettext "Aborting...")" - exit 1 # $E_CONFIG_ERROR - fi - - # ensure specified program is installed - local program="${agent%% *}" - if [[ ! -x $program ]]; then - local baseprog="${program##*/}" - error "$(gettext "The download program %s is not installed.")" "$baseprog" - plain "$(gettext "Aborting...")" - exit 1 # $E_MISSING_PROGRAM - fi - - printf "%s\n" "$agent" -} - -download_file() { - # download command - local dlcmd=$1 - # URL of the file - local url=$2 - # destination file - local file=$3 - # temporary download file, default to last component of the URL - local dlfile="${url##*/}" - - # replace %o by the temporary dlfile if it exists - if [[ $dlcmd = *%o* ]]; then - dlcmd=${dlcmd//\%o/\"$file.part\"} - dlfile="$file.part" - fi - # add the URL, either in place of %u or at the end - if [[ $dlcmd = *%u* ]]; then - dlcmd=${dlcmd//\%u/\"$url\"} - else - dlcmd="$dlcmd \"$url\"" - fi - - local ret=0 - eval "$dlcmd || ret=\$?" - if (( ret )); then - [[ ! -s $dlfile ]] && rm -f -- "$dlfile" - return $ret - fi - - # rename the temporary download file to the final destination - if [[ $dlfile != "$file" ]]; then - mv -f "$SRCDEST/$dlfile" "$SRCDEST/$file" - fi -} - run_pacman() { local cmd if [[ ! $1 = -@(T|Qq) ]]; then @@ -573,50 +617,6 @@ remove_deps() { fi } -download_sources() { - msg "$(gettext "Retrieving Sources...")" - - pushd "$SRCDEST" &>/dev/null - - local netfile - for netfile in "${source[@]}"; do - local file=$(get_filepath "$netfile" || true) - if [[ -n "$file" ]]; then - msg2 "$(gettext "Found %s")" "${file##*/}" - rm -f "$srcdir/${file##*/}" - ln -s "$file" "$srcdir/" - continue - fi - - file=$(get_filename "$netfile") - local url=$(get_url "$netfile") - - # if we get here, check to make sure it was a URL, else fail - if [[ $file = "$url" ]]; then - error "$(gettext "%s was not found in the build directory and is not a URL.")" "$file" - exit 1 # $E_MISSING_FILE - fi - - # find the client we should use for this URL - local dlclient - dlclient=$(get_downloadclient "$url") || exit $? - - msg2 "$(gettext "Downloading %s...")" "$file" - # fix flyspray bug #3289 - local ret=0 - download_file "$dlclient" "$url" "$file" || ret=$? - if (( ret )); then - error "$(gettext "Failure while downloading %s")" "$file" - plain "$(gettext "Aborting...")" - exit 1 - fi - rm -f "$srcdir/$file" - ln -s "$SRCDEST/$file" "$srcdir/" - done - - popd &>/dev/null -} - get_integlist() { local integ local integlist=() -- cgit v1.2.3-70-g09d2 From a922d1805696b6614649a8d3588297d44f4e1192 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Mon, 4 Jun 2012 09:02:03 +1000 Subject: makepkg: add function to return download protocol Extract the download protocol from a source entry. Returns "local" for local source files. Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'scripts') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 4cafa945..fe0c0684 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -224,6 +224,17 @@ get_url() { printf "%s\n" "${1#*::}" } +# extract the protocol from a source entry - return "local" for local sources +get_protocol() { + if [[ $1 = *://* ]]; then + # strip leading filename + local proto="${1##*::}" + printf "%s\n" "${proto%%://*}" + else + printf "%s\n" local + fi +} + get_downloadclient() { # $1 = URL with valid protocol prefix local url=$1 -- cgit v1.2.3-70-g09d2 From 1a04e2e11a012162b7b3b91e4c7a8c82dd113a94 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Sun, 3 Jun 2012 22:57:35 +1000 Subject: makepkg: generalize download_sources In order to treat all VCS sources as URLs, we need to be able to deal with more protocols. Rewrite download_sources to use a case statement so additional protocols are easily added. Also fix the use of scp to not pass the protocol in the URL (noticed by William J. Bowman ) Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 112 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 67 insertions(+), 45 deletions(-) (limited to 'scripts') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index fe0c0684..6bf95ff0 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -236,9 +236,7 @@ get_protocol() { } get_downloadclient() { - # $1 = URL with valid protocol prefix - local url=$1 - local proto="${url%%://*}" + local proto=$1 # loop through DOWNLOAD_AGENTS variable looking for protocol local i @@ -269,20 +267,56 @@ get_downloadclient() { printf "%s\n" "$agent" } +download_local() { + local netfile=$1 + local filepath=$(get_filepath "$netfile") + + if [[ -n "$filepath" ]]; then + msg2 "$(gettext "Found %s")" "${filepath##*/}" + rm -f "$srcdir/${filepath##*/}" + ln -s "$filepath" "$srcdir/" + continue + else + local filename=$(get_filename "$netfile") + error "$(gettext "%s was not found in the build directory and is not a URL.")" "$filename" + exit 1 # $E_MISSING_FILE + fi +} + download_file() { - # download command - local dlcmd=$1 - # URL of the file - local url=$2 - # destination file - local file=$3 + local netfile=$1 + + local filepath=$(get_filepath "$netfile") + if [[ -n "$filepath" ]]; then + msg2 "$(gettext "Found %s")" "${filepath##*/}" + rm -f "$srcdir/${filepath##*/}" + ln -s "$filepath" "$srcdir/" + return + fi + + local proto=$(get_protocol "$netfile") + + # find the client we should use for this URL + local dlcmd + dlcmd=$(get_downloadclient "$proto") || exit $? + + local filename=$(get_filename "$netfile") + local url=$(get_url "$netfile") + + if [[ $proto = "scp" ]]; then + # scp downloads should not pass the protocol in the url + url="${url##*://}" + fi + + msg2 "$(gettext "Downloading %s...")" "$filename" + # temporary download file, default to last component of the URL local dlfile="${url##*/}" # replace %o by the temporary dlfile if it exists if [[ $dlcmd = *%o* ]]; then - dlcmd=${dlcmd//\%o/\"$file.part\"} - dlfile="$file.part" + dlcmd=${dlcmd//\%o/\"$filename.part\"} + dlfile="$filename.part" fi # add the URL, either in place of %u or at the end if [[ $dlcmd = *%u* ]]; then @@ -295,13 +329,18 @@ download_file() { eval "$dlcmd || ret=\$?" if (( ret )); then [[ ! -s $dlfile ]] && rm -f -- "$dlfile" - return $ret + error "$(gettext "Failure while downloading %s")" "$filename" + plain "$(gettext "Aborting...")" + exit 1 fi # rename the temporary download file to the final destination - if [[ $dlfile != "$file" ]]; then - mv -f "$SRCDEST/$dlfile" "$SRCDEST/$file" + if [[ $dlfile != "$filename" ]]; then + mv -f "$SRCDEST/$dlfile" "$SRCDEST/$filename" fi + + rm -f "$srcdir/$filename" + ln -s "$SRCDEST/$filename" "$srcdir/" } download_sources() { @@ -311,38 +350,21 @@ download_sources() { local netfile for netfile in "${source[@]}"; do - local file=$(get_filepath "$netfile" || true) - if [[ -n "$file" ]]; then - msg2 "$(gettext "Found %s")" "${file##*/}" - rm -f "$srcdir/${file##*/}" - ln -s "$file" "$srcdir/" - continue - fi - - file=$(get_filename "$netfile") - local url=$(get_url "$netfile") - - # if we get here, check to make sure it was a URL, else fail - if [[ $file = "$url" ]]; then - error "$(gettext "%s was not found in the build directory and is not a URL.")" "$file" - exit 1 # $E_MISSING_FILE - fi + local proto=$(get_protocol "$netfile") - # find the client we should use for this URL - local dlclient - dlclient=$(get_downloadclient "$url") || exit $? - - msg2 "$(gettext "Downloading %s...")" "$file" - # fix flyspray bug #3289 - local ret=0 - download_file "$dlclient" "$url" "$file" || ret=$? - if (( ret )); then - error "$(gettext "Failure while downloading %s")" "$file" - plain "$(gettext "Aborting...")" - exit 1 - fi - rm -f "$srcdir/$file" - ln -s "$SRCDEST/$file" "$srcdir/" + case "$proto" in + local) + download_local "$netfile" + ;; + ftp|http|https|rsync|scp) + download_file "$netfile" + ;; + *) + error "$(gettext "Unknown download protocol: %s")" "$proto" + plain "$(gettext "Aborting...")" + exit 1 + ;; + esac done popd &>/dev/null -- cgit v1.2.3-70-g09d2 From 57e06394dd19191f36880aa8d1d4522a458922ca Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Mon, 4 Jun 2012 10:33:52 +1000 Subject: makepkg: skip integrity checking early If "SKIP" is provided for an integrity check, abort checking as soon as possible. Also swap fork to tr for bash4 conversion. Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'scripts') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 6bf95ff0..26466ab4 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -737,6 +737,12 @@ check_checksums() { file="$(get_filename "$file")" printf "%s" " $file ... " >&2 + if [[ ${integrity_sums[$idx]} = 'SKIP' ]]; then + echo "$(gettext "Skipped")" >&2 + idx=$((idx + 1)) + continue + fi + if ! file="$(get_filepath "$file")"; then printf -- "$(gettext "NOT FOUND")\n" >&2 errors=1 @@ -744,18 +750,14 @@ check_checksums() { fi if (( $found )) ; then - if [[ ${integrity_sums[$idx]} = 'SKIP' ]]; then - echo "$(gettext "Skipped")" >&2 + local expectedsum="${integrity_sums[idx],,}" + local realsum="$(openssl dgst -${integ} "$file")" + realsum="${realsum##* }" + if [[ $expectedsum = "$realsum" ]]; then + printf -- "$(gettext "Passed")\n" >&2 else - local expectedsum=$(tr '[:upper:]' '[:lower:]' <<< "${integrity_sums[$idx]}") - local realsum="$(openssl dgst -${integ} "$file")" - realsum="${realsum##* }" - if [[ $expectedsum = "$realsum" ]]; then - printf -- "$(gettext "Passed")\n" >&2 - else - printf -- "$(gettext "FAILED")\n" >&2 - errors=1 - fi + printf -- "$(gettext "FAILED")\n" >&2 + errors=1 fi fi -- cgit v1.2.3-70-g09d2 From 91d119af1c97c7f2d78bbd98c73c737bf6f7247d Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Mon, 4 Jun 2012 10:37:35 +1000 Subject: makepkg: allow using GIT source URLs Allow specifing GIT sources using the following syntax source=('::#') This will download the git repo into (into $SRCDIR if set, otherwise $startdir). must start with "git", but non-git protocols are handled using (e.g.) "git+http://...". The can be used to specify a branch, tag, or commit to build from. e.g. branch=maint. Checksum entries for git sources should be "SKIP". Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) (limited to 'scripts') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 26466ab4..e7e22765 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -343,6 +343,88 @@ download_file() { ln -s "$SRCDEST/$filename" "$srcdir/" } +download_git() { + local netfile=$1 + + local fragment=${netfile##*#} + if [[ $fragment = "$netfile" ]]; then + unset fragment + fi + + local dir=${netfile%%::*} + local repo=${netfile##*/} + repo=${repo%%#*} + repo=${repo%%.git*} + + if [[ $dir = "$netfile" ]]; then + dir="${repo}" + fi + + if [[ ! -d "$startdir"/$dir ]]; then + dir="$SRCDEST"/$dir + else + dir="$startdir"/$dir + fi + + local url=$(get_url "$netfile") + url=${url##*git+} + url=${url%%#*} + + if [[ ! -d "$dir" ]]; then + msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "git" + if ! git clone --mirror "$url" "$dir"; then + error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "git" + plain "$(gettext "Aborting...")" + exit 1 + fi + else + msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "git" + cd_safe "$dir" + if ! git fetch --all -p; then + # only warn on failure to allow offline builds + warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "git" + fi + fi + + msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "git" + pushd "$srcdir" &>/dev/null + rm -rf "${dir##*/}" + + if ! git clone "$dir"; then + error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git" + plain "$(gettext "Aborting...")" + exit 1 + fi + + cd_safe "${dir##*/}" + + local ref + if [[ -n $fragment ]]; then + case ${fragment%%=*} in + commit|tag) + ref=${fragment##*=} + ;; + branch) + ref=origin/${fragment##*=} + ;; + *) + error "$(gettext "Unrecognized reference: %s")" "${fragment}" + plain "$(gettext "Aborting...")" + exit 1 + esac + fi + + if [[ -n $ref ]]; then + if ! git checkout -b makepkg $ref; then + error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git" + plain "$(gettext "Aborting...")" + exit 1 + fi + fi + + popd &>/dev/null +} + download_sources() { msg "$(gettext "Retrieving Sources...")" @@ -359,6 +441,9 @@ download_sources() { ftp|http|https|rsync|scp) download_file "$netfile" ;; + git*) + download_git "$netfile" + ;; *) error "$(gettext "Unknown download protocol: %s")" "$proto" plain "$(gettext "Aborting...")" -- cgit v1.2.3-70-g09d2 From 682c9af846718cd387da058c39967550b7eeb01f Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Mon, 4 Jun 2012 11:24:52 +1000 Subject: makepkg: fix checksum generation with VCS sources VCS sources should have "SKIP" for their checksum value Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index e7e22765..55ec353d 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -789,10 +789,21 @@ generate_checksums() { local netfile for netfile in "${source[@]}"; do - local file - file="$(get_filepath "$netfile")" || missing_source_file "$netfile" - local sum="$(openssl dgst -${integ} "$file")" - sum=${sum##* } + local proto sum + proto="$(get_protocol "$netfile")" + + case $proto in + git*) + sum="SKIP" + ;; + *) + local file + file="$(get_filepath "$netfile")" || missing_source_file "$netfile" + sum="$(openssl dgst -${integ} "$file")" + sum=${sum##* } + ;; + esac + (( ct )) && printf "%s" "$indent" printf "%s" "'$sum'" ct=$(($ct+1)) -- cgit v1.2.3-70-g09d2 From aa6fe1160b39cd364a6595b7c9f56acb1cea3432 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Mon, 4 Jun 2012 11:39:15 +1000 Subject: makepkg: modify get_filename to handle VCS sources Modify get_filename to return the name of the folder with VCS sources. This fixes output issues in checksum checking. Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'scripts') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 55ec353d..8f163d32 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -212,10 +212,28 @@ get_filepath() { # extract the filename from a source entry get_filename() { + local netfile=$1 + # if a filename is specified, use it - local filename="${1%%::*}" - # if it is just an URL, we only keep the last component - printf "%s\n" "${filename##*/}" + if [[ $netfile = *::* ]]; then + printf "%s\n" ${netfile%%::*} + return + fi + + local proto=$(get_protocol "$netfile") + + case $proto in + git*) + filename=${netfile##*/} + filename=${filename%%#*} + filename=${filename%%.git*} + ;; + *) + # if it is just an URL, we only keep the last component + filename="${netfile##*/}" + ;; + esac + printf "%s\n" "${filename}" } # extract the URL from a source entry @@ -351,15 +369,12 @@ download_git() { unset fragment fi - local dir=${netfile%%::*} + local dir=$(get_filename "$netfile") + local repo=${netfile##*/} repo=${repo%%#*} repo=${repo%%.git*} - if [[ $dir = "$netfile" ]]; then - dir="${repo}" - fi - if [[ ! -d "$startdir"/$dir ]]; then dir="$SRCDEST"/$dir else -- cgit v1.2.3-70-g09d2 From cca9849fc25012845b08ce877f9450e45c9d207d Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Mon, 4 Jun 2012 12:02:36 +1000 Subject: makepkg: modify get_filepath to handle VCS sources With VCS sources, get_filepath should return the directory of the checkout. This allows backing up of the VCS checkout when using --allsource. Fixes FS#21098. Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'scripts') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 8f163d32..d6f314ac 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -193,19 +193,30 @@ enter_fakeroot() { # 2) "http://path/to/file" # Return the absolute filename of a source entry -# -# This function accepts a source entry or the already extracted filename of a -# source entry as input get_filepath() { local file="$(get_filename "$1")" + local proto="$(get_protocol "$1")" - if [[ -f "$startdir/$file" ]]; then - file="$startdir/$file" - elif [[ -f "$SRCDEST/$file" ]]; then - file="$SRCDEST/$file" - else - return 1 - fi + case $proto in + git*) + if [[ -d "$startdir/$file" ]]; then + file="$startdir/$file" + elif [[ -d "$SRCDEST/$file" ]]; then + file="$SRCDEST/$file" + else + return 1 + fi + ;; + *) + if [[ -f "$startdir/$file" ]]; then + file="$startdir/$file" + elif [[ -f "$SRCDEST/$file" ]]; then + file="$SRCDEST/$file" + else + return 1 + fi + ;; + esac printf "%s\n" "$file" } @@ -369,18 +380,13 @@ download_git() { unset fragment fi - local dir=$(get_filename "$netfile") + local dir=$(get_filepath "$netfile") + [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")" local repo=${netfile##*/} repo=${repo%%#*} repo=${repo%%.git*} - if [[ ! -d "$startdir"/$dir ]]; then - dir="$SRCDEST"/$dir - else - dir="$startdir"/$dir - fi - local url=$(get_url "$netfile") url=${url##*git+} url=${url%%#*} -- cgit v1.2.3-70-g09d2 From 888020de9068218fafe820e631222bc85c47b453 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Tue, 5 Jun 2012 13:30:08 +1000 Subject: makepkg: provide mechanism for auto-updating pkgver Now that VCS repos are provided in the source array, it becomes too complicated to have automatic updating pkgver as was the case with the old VCS PKGBUILDs (there can be multiple repos of different types in the source array, the VCS repo may not be the package primary source, etc). Instead provide an optional way for a PKGBUILD to update the pkgver value through the specifing of a pkgver() function that returns the new version string. This is run after all source files are downloaded so can access the VCS repo if needed. Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'scripts') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index d6f314ac..5ff4bb6d 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -473,9 +473,30 @@ download_sources() { esac done + if declare -f pkgver >/dev/null; then + update_pkgver + fi + popd &>/dev/null } +# Automatically update pkgver variable if a pkgver() function is provided +# Re-sources the PKGBUILD afterwards to allow for other variables that use $pkgver +update_pkgver() { + newpkgver=$(run_function_safe pkgver) + + if [[ -n $newpkgver && $newpkgver != "$pkgver" ]]; then + if [[ -f $BUILDFILE && -w $BUILDFILE ]]; then + @SEDINPLACE@ "s/^pkgver=[^ ]*/pkgver=$newpkgver/" "$BUILDFILE" + @SEDINPLACE@ "s/^pkgrel=[^ ]*/pkgrel=1/" "$BUILDFILE" + source "$BUILDFILE" + else + warning "$(gettext "%s is not writeable -- pkgver will not be updated")" \ + "$BUILDFILE" + fi + fi +} + # Print 'source not found' error message and exit makepkg missing_source_file() { error "$(gettext "Unable to find source file %s.")" "$(get_filename "$1")" -- cgit v1.2.3-70-g09d2 From 2042b79bcc7904afc195103dfa1fc6b3978d60f7 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Thu, 7 Jun 2012 18:12:31 +1000 Subject: makepkg: add support for SVN urls Allow SVN repo sources in the form: source=("::#") where must start with svn (e.g svn+http://) and a can specify a revision (e.g. revision=22). Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 73 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 70 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 5ff4bb6d..749492cb 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -198,7 +198,7 @@ get_filepath() { local proto="$(get_protocol "$1")" case $proto in - git*) + git*|svn*) if [[ -d "$startdir/$file" ]]; then file="$startdir/$file" elif [[ -d "$SRCDEST/$file" ]]; then @@ -234,9 +234,12 @@ get_filename() { local proto=$(get_protocol "$netfile") case $proto in - git*) + git*|svn*) filename=${netfile##*/} filename=${filename%%#*} + # fall-through + ;;& + git*) filename=${filename%%.git*} ;; *) @@ -446,6 +449,67 @@ download_git() { popd &>/dev/null } +download_svn() { + local netfile=$1 + + local fragment=${netfile##*#} + if [[ $fragment = "$netfile" ]]; then + unset fragment + fi + + local dir=$(get_filepath "$netfile") + [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")" + + local repo=${netfile##*/} + repo=${repo%%#*} + + local url=$(get_url "$netfile") + if [[ $url != svn+ssh* ]]; then + url=${url##*svn+} + fi + url=${url%%#*} + + if [[ ! -d "$dir" ]]; then + msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "svn" + if ! svn checkout --config-dir "$dir" "$url" "$dir"; then + error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "svn" + plain "$(gettext "Aborting...")" + exit 1 + fi + else + msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "svn" + cd_safe "$dir" + if ! svn update; then + # only warn on failure to allow offline builds + warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "svn" + fi + fi + + msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "svn" + pushd "$srcdir" &>/dev/null + rm -rf "${dir##*/}" + + local ref + if [[ -n $fragment ]]; then + case ${fragment%%=*} in + revision) + ref=('-r' "${fragment##*=}") + ;; + *) + error "$(gettext "Unrecognized reference: %s")" "${fragment}" + plain "$(gettext "Aborting...")" + exit 1 + esac + fi + + if ! svn export $(ref[@]) "$dir"; then + error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "svn" + plain "$(gettext "Aborting...")" + fi + + popd &>/dev/null +} + download_sources() { msg "$(gettext "Retrieving Sources...")" @@ -465,6 +529,9 @@ download_sources() { git*) download_git "$netfile" ;; + svn*) + download_svn "$netfile" + ;; *) error "$(gettext "Unknown download protocol: %s")" "$proto" plain "$(gettext "Aborting...")" @@ -835,7 +902,7 @@ generate_checksums() { proto="$(get_protocol "$netfile")" case $proto in - git*) + git*|svn*) sum="SKIP" ;; *) -- cgit v1.2.3-70-g09d2 From b3e82ec59e31e904b96a0d0c504af1549c8b2115 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Sun, 15 Jul 2012 15:46:29 +1000 Subject: makepkg: rename myver myver is a bit generic for an internal variable name. Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 749492cb..aa234577 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -39,7 +39,7 @@ export COMMAND_MODE='legacy' # Ensure CDPATH doesn't screw with our cd calls unset CDPATH -declare -r myver='@PACKAGE_VERSION@' +declare -r makepkg_version='@PACKAGE_VERSION@' declare -r confdir='@sysconfdir@' declare -r BUILDSCRIPT='@BUILDSCRIPT@' declare -r startdir="$PWD" @@ -1503,7 +1503,7 @@ write_pkginfo() { size="$(( ${size%%[^0-9]*} * 1024 ))" msg2 "$(gettext "Generating %s file...")" ".PKGINFO" - echo "# Generated by makepkg $myver" + echo "# Generated by makepkg $makepkg_version" if (( INFAKEROOT )); then echo "# using $(fakeroot -v)" fi @@ -2081,7 +2081,7 @@ canonicalize_path() { m4_include(library/parseopts.sh) usage() { - printf "makepkg (pacman) %s\n" "$myver" + printf "makepkg (pacman) %s\n" "$makepkg_version" echo printf -- "$(gettext "Usage: %s [options]")\n" "$0" echo @@ -2126,7 +2126,7 @@ usage() { } version() { - printf "makepkg (pacman) %s\n" "$myver" + printf "makepkg (pacman) %s\n" "$makepkg_version" printf -- "$(gettext "\ Copyright (c) 2006-2012 Pacman Development Team .\n\ Copyright (C) 2002-2006 Judd Vinet .\n\n\ -- cgit v1.2.3-70-g09d2 From 7fd56118d0a751f0e488ada38101390e840bd311 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Sun, 15 Jul 2012 23:57:25 +1000 Subject: makepkg: do not download VCS sources unless needed VCS sources are not needed for --geninteg or --source operations. This also prevents VCS downloads outputting to stdout, which prevented piping -g output to the PKGBUILD. Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index aa234577..aec44876 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -513,6 +513,11 @@ download_svn() { download_sources() { msg "$(gettext "Retrieving Sources...")" + local GET_VCS=1 + if [[ $1 == "fast" ]]; then + GET_VCS=0 + fi + pushd "$SRCDEST" &>/dev/null local netfile @@ -527,10 +532,10 @@ download_sources() { download_file "$netfile" ;; git*) - download_git "$netfile" + (( GET_VCS )) && download_git "$netfile" ;; svn*) - download_svn "$netfile" + (( GET_VCS )) && download_svn "$netfile" ;; *) error "$(gettext "Unknown download protocol: %s")" "$proto" @@ -2382,7 +2387,7 @@ if (( GENINTEG )); then mkdir -p "$srcdir" chmod a-s "$srcdir" cd_safe "$srcdir" - download_sources + download_sources fast generate_checksums exit 0 # $E_OK fi @@ -2527,10 +2532,11 @@ if (( SOURCEONLY )); then mkdir -p "$srcdir" chmod a-s "$srcdir" cd_safe "$srcdir" - if ( (( ! SKIPCHECKSUMS )) || \ - ( (( ! SKIPPGPCHECK )) && source_has_signatures ) ) || \ - (( SOURCEONLY == 2 )); then + if (( SOURCEONLY == 2 )); then download_sources + elif ( (( ! SKIPCHECKSUMS )) || \ + ( (( ! SKIPPGPCHECK )) && source_has_signatures ) ); then + download_sources fast fi check_source_integrity cd_safe "$startdir" -- cgit v1.2.3-70-g09d2 From 6c8def6ae0f7b99c68da8a7a4bd943746d234754 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Mon, 16 Jul 2012 00:16:25 +1000 Subject: makepkg: add --holdver to control VCS source updating Do not update VCS sources if --holdver is used. If the VCS checkout is not present, it will still be downloaded. Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index aec44876..da7bde55 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -59,6 +59,7 @@ DEP_BIN=0 FORCE=0 INFAKEROOT=0 GENINTEG=0 +HOLDVER=0 SKIPCHECKSUMS=0 SKIPPGPCHECK=0 INSTALL=0 @@ -401,7 +402,7 @@ download_git() { plain "$(gettext "Aborting...")" exit 1 fi - else + elif (( ! HOLDVER )); then msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "git" cd_safe "$dir" if ! git fetch --all -p; then @@ -476,7 +477,7 @@ download_svn() { plain "$(gettext "Aborting...")" exit 1 fi - else + elif (( ! HOLDVER )); then msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "svn" cd_safe "$dir" if ! svn update; then @@ -2111,6 +2112,7 @@ usage() { printf -- "$(gettext " --asroot Allow %s to run as root user")\n" "makepkg" printf -- "$(gettext " --check Run the %s function in the %s")\n" "check()" "$BUILDSCRIPT" printf -- "$(gettext " --config Use an alternate config file (instead of '%s')")\n" "$confdir/makepkg.conf" + printf -- "$(gettext " --holdver Do not update VCS sources")\n" printf -- "$(gettext " --key Specify a key to use for %s signing instead of the default")\n" "gpg" printf -- "$(gettext " --nocheck Do not run the %s function in the %s")\n" "check()" "$BUILDSCRIPT" printf -- "$(gettext " --nosign Do not create a signature for the package")\n" @@ -2153,7 +2155,7 @@ ARGLIST=("$@") # Parse Command Line Options. OPT_SHORT="AcdefFghiLmop:rRsSV" OPT_LONG=('allsource' 'asroot' 'check' 'clean' 'config:' 'force' 'geninteg' - 'help' 'ignorearch' 'install' 'key:' 'log' 'nobuild' 'nocolor' + 'help' 'holdver' 'ignorearch' 'install' 'key:' 'log' 'nobuild' 'nocolor' 'nocheck' 'nodeps' 'noextract' 'nosign' 'pkg:' 'repackage' 'rmdeps' 'skipchecksums' 'skipinteg' 'skippgpcheck' 'skippgpcheck' 'sign' 'source' 'syncdeps' 'version') @@ -2186,6 +2188,7 @@ while true; do -f|--force) FORCE=1 ;; -F) INFAKEROOT=1 ;; -g|--geninteg) GENINTEG=1 ;; + --holdver) HOLDVER=1 ;; -i|--install) INSTALL=1 ;; --key) shift; GPGKEY=$1 ;; -L|--log) LOGGING=1 ;; -- cgit v1.2.3-70-g09d2 From b1e75d7dd663a72d90195e4907ee8fa145461fc2 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Mon, 16 Jul 2012 00:24:34 +1000 Subject: makepkg: only update pkgver when all sources are available Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index da7bde55..0d23f749 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -546,7 +546,7 @@ download_sources() { esac done - if declare -f pkgver >/dev/null; then + if declare -f pkgver >/dev/null && (( GET_VCS )); then update_pkgver fi -- cgit v1.2.3-70-g09d2 From 4b129d484394ce6090a9ed21782fe1df2227ad18 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Mon, 16 Jul 2012 21:56:32 +1000 Subject: makepkg: check pkgver validity after updating If a PKGBUILD has a pkgver() function, skip checking the pkgver validity until it has been updated. Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'scripts') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 0d23f749..3157a9ce 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -548,6 +548,7 @@ download_sources() { if declare -f pkgver >/dev/null && (( GET_VCS )); then update_pkgver + check_pkgver || exit 1 fi popd &>/dev/null @@ -1787,7 +1788,7 @@ check_sanity() { # check for no-no's in the build script local i local ret=0 - for i in 'pkgname' 'pkgrel' 'pkgver'; do + for i in 'pkgname' 'pkgrel'; do if [[ -z ${!i} ]]; then error "$(gettext "%s is not allowed to be empty.")" "$i" ret=1 @@ -1811,14 +1812,9 @@ check_sanity() { ret=1 fi - awk -F'=' '$1 ~ /^[[:space:]]*pkgver$/' "$BUILDFILE" | sed "s/[[:space:]]*#.*//" | - while IFS='=' read -r _ i; do - eval i=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "${i%%+([[:space:]])}")\" - if [[ $i = *[[:space:]:-]* ]]; then - error "$(gettext "%s is not allowed to contain colons, hyphens or whitespace.")" "pkgver" - return 1 - fi - done || ret=1 + if ! declare -f pkgver >/dev/null; then + check_pkgver || ret=1 + fi awk -F'=' '$1 ~ /^[[:space:]]*pkgrel$/' "$BUILDFILE" | sed "s/[[:space:]]*#.*//" | while IFS='=' read -r _ i; do @@ -1948,6 +1944,26 @@ check_sanity() { return $ret } +check_pkgver() { + local ret=0 + + if [[ -z ${pkgver} ]]; then + error "$(gettext "%s is not allowed to be empty.")" "pkgver" + ret=1 + fi + + awk -F'=' '$1 ~ /^[[:space:]]*pkgver$/' "$BUILDFILE" | sed "s/[[:space:]]*#.*//" | + while IFS='=' read -r _ i; do + eval i=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "${i%%+([[:space:]])}")\" + if [[ $i = *[[:space:]:-]* ]]; then + error "$(gettext "%s is not allowed to contain colons, hyphens or whitespace.")" "pkgver" + return 1 + fi + done || ret=1 + + return $ret +} + check_software() { # check for needed software local ret=0 -- cgit v1.2.3-70-g09d2 From 7e4aa9e52492450db1705f1057e82934b1187e0e Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Mon, 23 Jul 2012 20:01:35 +1000 Subject: makepkg: add hg url support Supported fragments are branch, revision and tag. Signed-off-by: Allan McRae --- doc/PKGBUILD.5.txt | 7 ++++-- scripts/makepkg.sh.in | 69 ++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 71 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt index 3d04b604..47f9e884 100644 --- a/doc/PKGBUILD.5.txt +++ b/doc/PKGBUILD.5.txt @@ -405,8 +405,8 @@ Using VCS Sources[[VCS]] ------------------------ Building a developmental version of a package using sources from a version control system (VCS) is enabled by specifying the source in the form -`source=('folder::url#fragment')`. Currently makepkg supports the `git` and `svn` -protocols. +`source=('folder::url#fragment')`. Currently makepkg supports the `git`, `hg` and +`svn` protocols. The source URL is divided into three components: @@ -430,6 +430,9 @@ The source URL is divided into three components: *git*;; branch, commit, tag + *hg*;; + branch, revision, tag + *svn*;; revision diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 3157a9ce..ec78970c 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -199,7 +199,7 @@ get_filepath() { local proto="$(get_protocol "$1")" case $proto in - git*|svn*) + git*|hg*|svn*) if [[ -d "$startdir/$file" ]]; then file="$startdir/$file" elif [[ -d "$SRCDEST/$file" ]]; then @@ -235,7 +235,7 @@ get_filename() { local proto=$(get_protocol "$netfile") case $proto in - git*|svn*) + git*|hg*|svn*) filename=${netfile##*/} filename=${filename%%#*} # fall-through @@ -450,6 +450,66 @@ download_git() { popd &>/dev/null } +download_hg() { + local netfile=$1 + + local fragment=${netfile##*#} + if [[ $fragment = "$netfile" ]]; then + unset fragment + fi + + local dir=$(get_filepath "$netfile") + [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")" + + local repo=${netfile##*/} + repo=${repo%%#*} + + local url=$(get_url "$netfile") + url=${url##*hg+} + url=${url%%#*} + + if [[ ! -d "$dir" ]]; then + msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "hg" + if ! hg clone "$url" "$dir"; then + error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "hg" + plain "$(gettext "Aborting...")" + exit 1 + fi + elif (( ! HOLDVER )); then + msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "hg" + cd_safe "$dir" + if ! hg pull -u; then + # only warn on failure to allow offline builds + warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "hg" + fi + fi + + msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "hg" + pushd "$srcdir" &>/dev/null + rm -rf "${dir##*/}" + + local ref + if [[ -n $fragment ]]; then + case ${fragment%%=*} in + branch|revision|tag) + ref=('-u' "${fragment##*=}") + ;; + *) + error "$(gettext "Unrecognized reference: %s")" "${fragment}" + plain "$(gettext "Aborting...")" + exit 1 + esac + fi + + if ! hg clone "${ref[@]}" "$dir" "${dir##*/}"; then + error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "hg" + plain "$(gettext "Aborting...")" + exit 1 + fi + + popd &>/dev/null +} + download_svn() { local netfile=$1 @@ -535,6 +595,9 @@ download_sources() { git*) (( GET_VCS )) && download_git "$netfile" ;; + hg*) + (( GET_VCS )) && download_hg "$netfile" + ;; svn*) (( GET_VCS )) && download_svn "$netfile" ;; @@ -909,7 +972,7 @@ generate_checksums() { proto="$(get_protocol "$netfile")" case $proto in - git*|svn*) + git*|hg*|svn*) sum="SKIP" ;; *) -- cgit v1.2.3-70-g09d2 From a818766c6e693fcc5781574d05ee02ac4b6a8dcd Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Mon, 16 Jul 2012 22:25:24 +1000 Subject: makepkg: delay checking for build package with pkgver() If a pkgver() function is specified, delay checking the package is built until the pkgver is updated.. Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 103 ++++++++++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 46 deletions(-) (limited to 'scripts') diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index ec78970c..dd4066bf 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -75,6 +75,7 @@ PREPAREFUNC=0 BUILDFUNC=0 CHECKFUNC=0 PKGFUNC=0 +PKGVERFUNC=0 SPLITPKG=0 PKGLIST=() SIGNPKG='' @@ -609,9 +610,10 @@ download_sources() { esac done - if declare -f pkgver >/dev/null && (( GET_VCS )); then + if (( PKGVERFUNC && GET_VCS )); then update_pkgver check_pkgver || exit 1 + check_build_status fi popd &>/dev/null @@ -1875,7 +1877,7 @@ check_sanity() { ret=1 fi - if ! declare -f pkgver >/dev/null; then + if (( ! PKGVERFUNC )) ; then check_pkgver || ret=1 fi @@ -2113,6 +2115,53 @@ check_software() { return $ret } +check_build_status() { + if (( ! SPLITPKG )); then + fullver=$(get_full_version) + pkgarch=$(get_pkg_arch) + if [[ -f $PKGDEST/${pkgname}-${fullver}-${pkgarch}${PKGEXT} ]] \ + && ! (( FORCE || SOURCEONLY || NOBUILD )); then + if (( INSTALL )); then + warning "$(gettext "A package has already been built, installing existing package...")" + install_package + exit $? + else + error "$(gettext "A package has already been built. (use %s to overwrite)")" "-f" + exit 1 + fi + fi + else + allpkgbuilt=1 + somepkgbuilt=0 + for pkg in ${pkgname[@]}; do + fullver=$(get_full_version $pkg) + pkgarch=$(get_pkg_arch $pkg) + if [[ -f $PKGDEST/${pkg}-${fullver}-${pkgarch}${PKGEXT} ]]; then + somepkgbuilt=1 + else + allpkgbuilt=0 + fi + done + if ! (( FORCE || SOURCEONLY || NOBUILD )); then + if (( allpkgbuilt )); then + if (( INSTALL )); then + warning "$(gettext "The package group has already been built, installing existing packages...")" + install_package + exit $? + else + error "$(gettext "The package group has already been built. (use %s to overwrite)")" "-f" + exit 1 + fi + fi + if (( somepkgbuilt && ! PKGVERFUNC )); then + error "$(gettext "Part of the package group has already been built. (use %s to overwrite)")" "-f" + exit 1 + fi + fi + unset allpkgbuilt somepkgbuilt + fi +} + backup_package_variables() { local var for var in ${splitpkg_overrides[@]}; do @@ -2474,6 +2523,10 @@ if (( GENINTEG )); then exit 0 # $E_OK fi +if declare -f pkgver >/dev/null; then + PKGVERFUNC=1 +fi + # check the PKGBUILD for some basic requirements check_sanity || exit 1 @@ -2520,50 +2573,8 @@ if { [[ -z $SIGNPKG ]] && check_buildenv "sign" "y"; } || [[ $SIGNPKG == 'y' ]]; fi fi - -if (( ! SPLITPKG )); then - fullver=$(get_full_version) - pkgarch=$(get_pkg_arch) - if [[ -f $PKGDEST/${pkgname}-${fullver}-${pkgarch}${PKGEXT} ]] \ - && ! (( FORCE || SOURCEONLY || NOBUILD )); then - if (( INSTALL )); then - warning "$(gettext "A package has already been built, installing existing package...")" - install_package - exit $? - else - error "$(gettext "A package has already been built. (use %s to overwrite)")" "-f" - exit 1 - fi - fi -else - allpkgbuilt=1 - somepkgbuilt=0 - for pkg in ${pkgname[@]}; do - fullver=$(get_full_version $pkg) - pkgarch=$(get_pkg_arch $pkg) - if [[ -f $PKGDEST/${pkg}-${fullver}-${pkgarch}${PKGEXT} ]]; then - somepkgbuilt=1 - else - allpkgbuilt=0 - fi - done - if ! (( FORCE || SOURCEONLY || NOBUILD )); then - if (( allpkgbuilt )); then - if (( INSTALL )); then - warning "$(gettext "The package group has already been built, installing existing packages...")" - install_package - exit $? - else - error "$(gettext "The package group has already been built. (use %s to overwrite)")" "-f" - exit 1 - fi - fi - if (( somepkgbuilt )); then - error "$(gettext "Part of the package group has already been built. (use %s to overwrite)")" "-f" - exit 1 - fi - fi - unset allpkgbuilt somepkgbuilt +if (( ! PKGVERFUNC )); then + check_build_status fi # Run the bare minimum in fakeroot -- cgit v1.2.3-70-g09d2