[pacman-dev] [PATCH 00/11] Support VCS URLs.
At the request of Dave, here are the updated versions of patches sent to the list earlier. Support for the following needs readded: CVS, Mercurial, Darcs and Bazaar Known issue: the pkgver check needs adjusted when using an auto-updating pkgver Allan McRae (11): makepkg: remove VCS package support makepkg: reorder source handling functions makepkg: add function to return download protocol makepkg: generalize download_sources makepkg: skip integrity checking early makepkg: allow using GIT source URLs makepkg: fix checksum generation with VCS sources makepkg: modify get_filename to handle VCS sources makepkg: modify get_filepath to handle VCS sources makepkg: provide mechanism for auto-updating pkgver makepkg: add support for SVN urls doc/PKGBUILD.5.txt | 64 ----- doc/makepkg.8.txt | 10 - scripts/makepkg.sh.in | 682 +++++++++++++++++++++++++++++--------------------- 3 files changed, 394 insertions(+), 362 deletions(-) -- 1.7.11.1
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 <allan@archlinux.org> --- doc/PKGBUILD.5.txt | 64 ---------------------- doc/makepkg.8.txt | 10 ---- scripts/makepkg.sh.in | 145 +++----------------------------------------------- 3 files changed, 6 insertions(+), 213 deletions(-) diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt index 404a55c..956179a 100644 --- a/doc/PKGBUILD.5.txt +++ b/doc/PKGBUILD.5.txt @@ -383,70 +383,6 @@ The install script does not need to be specified in the source array. A template install file is available in '{pkgdatadir}' as 'proto.install' for reference with all of the available functions defined. - -Development Directives ----------------------- -makepkg supports building development versions of packages without having to -manually update the pkgver in the PKGBUILD. This was formerly done using the -separate utility 'versionpkg'. In order to utilize this functionality, your -PKGBUILD must use correct variable names depending on the SCM being fetched -from (e.g., 'makepkg-git', 'mplayer-svn'). - -*CVS*:: - The generated pkgver will be the date the package is built. - - *_cvsroot*;; - The root of the CVS repository. - - *_cvsmod*;; - The CVS module to fetch. - -*SVN*:: - The generated pkgver will be the latest SVN revision number. - - *_svntrunk*;; - The trunk of the SVN repository. - - *_svnmod*;; - The SVN module to fetch. - -*Git*:: - The generated pkgver will be the date the package is built. - - *_gitroot*;; - The URL (all protocols supported) to the GIT repository. - - *_gitname*;; - GIT tag or branch to use. - -*Mercurial*:: - The generated pkgver will be the hg tip revision number. - - *_hgroot*;; - The URL of the mercurial repository. - - *_hgrepo*;; - The repository to follow. - -*Darcs*:: - The generated pkgver will be the date the package is built. - - *_darcstrunk*;; - URL to the repository trunk. - - *_darcsmod*;; - Darcs module to use. - -*Bazaar*:: - The generated pkgver will be the latest Bazaar revision number (revno). - - *_bzrtrunk*;; - URL to the bazaar repository. - - *_bzrmod*;; - Bazaar module to use. - - Example ------- The following is an example PKGBUILD for the 'patch' package. For more diff --git a/doc/makepkg.8.txt b/doc/makepkg.8.txt index 27875a3..5b1b9e2 100644 --- a/doc/makepkg.8.txt +++ b/doc/makepkg.8.txt @@ -71,11 +71,6 @@ Options default to the current directory. This allows the built package to be overwritten. -*--forcever*:: - This is a hidden option that should *not* be used unless you really know - what you are doing. makepkg uses this internally when calling itself to - set the new development pkgver of the package. - *-g, \--geninteg*:: For each source file in the source array of PKGBUILD, download the file if required and generate integrity checks. The integrity checks generated @@ -96,11 +91,6 @@ Options *-h, \--help*:: Output syntax and command line options. -*\--holdver*:: - Useful when building development versions of packages. Prevents makepkg - from automatically bumping the pkgver to the latest revision number in - the package's development tree. - *-i, \--install*:: Install or upgrade the package after a successful build using linkman:pacman[8]. diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index abfabdf..0d63352 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -69,7 +69,6 @@ REPKG=0 LOGGING=0 SOURCEONLY=0 IGNOREARCH=0 -HOLDVER=0 BUILDFUNC=0 CHECKFUNC=0 PKGFUNC=0 @@ -183,12 +182,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 $? } @@ -1787,114 +1781,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 @@ -1973,7 +1859,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 <file> 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 <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" @@ -2014,11 +1899,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+=('noconfirm' 'noprogressbar') @@ -2045,11 +1930,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 ;; @@ -2183,12 +2065,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. @@ -2268,13 +2144,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 @@ -2509,7 +2378,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 @@ -2531,7 +2399,6 @@ else fi else if (( ! REPKG && ( PKGFUNC || SPLITPKG ) )); then - devel_update (( BUILDFUNC )) && run_build (( CHECKFUNC )) && run_check cd_safe "$startdir" -- 1.7.11.1
On Tue, Jun 26, 2012 at 5:58 PM, Allan McRae <allan@archlinux.org> wrote:
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 <allan@archlinux.org> --- doc/PKGBUILD.5.txt | 64 ---------------------- doc/makepkg.8.txt | 10 ---- scripts/makepkg.sh.in | 145 +++----------------------------------------------- 3 files changed, 6 insertions(+), 213 deletions(-) +1 as far as this approach goes.
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 <allan@archlinux.org> --- scripts/makepkg.sh.in | 240 +++++++++++++++++++++++++------------------------- 1 file changed, 120 insertions(+), 120 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 0d63352..4299816 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -208,13 +208,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 @@ -229,6 +222,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 @@ -386,75 +499,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 @@ -571,50 +615,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=() -- 1.7.11.1
Extract the download protocol from a source entry. Returns "local" for local source files. Signed-off-by: Allan McRae <allan@archlinux.org> --- scripts/makepkg.sh.in | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 4299816..0d87cba 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -222,6 +222,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 -- 1.7.11.1
On Wed, Jun 27, 2012 at 08:58:09AM +1000, Allan McRae wrote:
Extract the download protocol from a source entry. Returns "local" for local source files.
Signed-off-by: Allan McRae <allan@archlinux.org> --- scripts/makepkg.sh.in | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 4299816..0d87cba 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -222,6 +222,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%%://*}"
While we're here, should we catch file:// protos and return 'local' as well? It would save the end user from having to define file:// as a DLAGENT.
+ else + printf "%s\n" local + fi +} + get_downloadclient() { # $1 = URL with valid protocol prefix local url=$1 -- 1.7.11.1
On Tue, Jun 26, 2012 at 6:51 PM, Dave Reisner <d@falconindy.com> wrote:
On Wed, Jun 27, 2012 at 08:58:09AM +1000, Allan McRae wrote:
Extract the download protocol from a source entry. Returns "local" for local source files.
Signed-off-by: Allan McRae <allan@archlinux.org> --- scripts/makepkg.sh.in | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 4299816..0d87cba 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -222,6 +222,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%%://*}"
While we're here, should we catch file:// protos and return 'local' as well? It would save the end user from having to define file:// as a DLAGENT.
Shouldn't we just return "file" instead of make up a "local" protocol, while we're on this train of thought? -Dan
On 27/06/12 11:14, Dan McGee wrote:
On Tue, Jun 26, 2012 at 6:51 PM, Dave Reisner <d@falconindy.com> wrote:
On Wed, Jun 27, 2012 at 08:58:09AM +1000, Allan McRae wrote:
Extract the download protocol from a source entry. Returns "local" for local source files.
Signed-off-by: Allan McRae <allan@archlinux.org> --- scripts/makepkg.sh.in | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 4299816..0d87cba 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -222,6 +222,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%%://*}"
While we're here, should we catch file:// protos and return 'local' as well? It would save the end user from having to define file:// as a DLAGENT.
Shouldn't we just return "file" instead of make up a "local" protocol, while we're on this train of thought?
Hmm.... this could be interesting... local assumes that the file is in $startdir. I guess file:// could be used to specify files anywhere on your system, but that really does not make a portable PKGBUILD. I'm tempted to say all local files must be in $startdir and so no support of file:// is needed. Allan
Am 27.06.2012 04:18, schrieb Allan McRae:
Hmm.... this could be interesting...
local assumes that the file is in $startdir. I guess file:// could be used to specify files anywhere on your system, but that really does not make a portable PKGBUILD.
I'm tempted to say all local files must be in $startdir and so no support of file:// is needed.
Imagine you have a bunch of PKGBUILDs with mirror=... in them and use $mirror a lot in source=(). Then you get a local mirror and mass-replace mirror= with a file:// URL in all of them. I say this is useful.
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 <wjb@williamjbowman.com>) Signed-off-by: Allan McRae <allan@archlinux.org> --- scripts/makepkg.sh.in | 112 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 67 insertions(+), 45 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 0d87cba..2a8866f 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -234,9 +234,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 @@ -267,20 +265,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 @@ -293,13 +327,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() { @@ -309,38 +348,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 -- 1.7.11.1
If "SKIP" is provided for an integrity check, abort checking as soon as possible. Signed-off-by: Allan McRae <allan@archlinux.org> --- scripts/makepkg.sh.in | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 2a8866f..985bbbd 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -736,6 +736,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 @@ -743,18 +749,14 @@ check_checksums() { fi if (( $found )) ; then - if [[ ${integrity_sums[$idx]} = 'SKIP' ]]; then - echo "$(gettext "Skipped")" >&2 + 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 - 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 -- 1.7.11.1
On Wed, Jun 27, 2012 at 08:58:11AM +1000, Allan McRae wrote:
If "SKIP" is provided for an integrity check, abort checking as soon as possible.
Signed-off-by: Allan McRae <allan@archlinux.org> --- scripts/makepkg.sh.in | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 2a8866f..985bbbd 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -736,6 +736,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 @@ -743,18 +749,14 @@ check_checksums() { fi
if (( $found )) ; then - if [[ ${integrity_sums[$idx]} = 'SKIP' ]]; then - echo "$(gettext "Skipped")" >&2 + local expectedsum=$(tr '[:upper:]' '[:lower:]' <<< "${integrity_sums[$idx]}")
While you're touching this, we're bash4 capable now, so we could skip the fork and use a PE instead: "${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
-- 1.7.11.1
Allow specifing GIT sources using the following syntax source=('<folder>::<repo>#<fragment>') This will download the git repo <repo> into <folder> (into $SRCDIR if set, otherwise $startdir). <repo> must start with "git", but non-git protocols are handled using (e.g.) "git+http://...". The <fragment> 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 <allan@archlinux.org> --- scripts/makepkg.sh.in | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 985bbbd..2b29759 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -341,6 +341,88 @@ download_file() { ln -s "$SRCDEST/$filename" "$srcdir/" } +download_git() { + local netfile=$1 + + local fragment=${netfile##*#} + if [[ $fragment = "$netfile" ]]; then + unset fragment + fi + + local folder=${netfile%%::*} + local repo=${netfile##*/} + repo=${repo%%#*} + repo=${repo%%.git*} + + if [[ $folder = "$netfile" ]]; then + folder="${repo}" + fi + + if [[ ! -d "$startdir"/$folder && -d "$SRCDEST"/$folder ]]; then + folder="$SRCDEST"/$folder + else + folder="$startdir"/$folder + fi + + local url=$(get_url "$netfile") + url=${url##*git+} + url=${url%%#*} + + if [[ ! -d $folder ]]; then + msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "git" + if ! git clone --mirror "$url" "$folder"; 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 "$folder" + 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 ${folder##*/} + + if ! git clone $folder; then + error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git" + plain "$(gettext "Aborting...")" + exit 1 + fi + + cd_safe ${folder##*/} + + 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...")" @@ -357,6 +439,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...")" -- 1.7.11.1
On Wed, Jun 27, 2012 at 08:58:12AM +1000, Allan McRae wrote:
Allow specifing GIT sources using the following syntax
source=('<folder>::<repo>#<fragment>')
This will download the git repo <repo> into <folder> (into $SRCDIR if set, otherwise $startdir). <repo> must start with "git", but non-git protocols are handled using (e.g.) "git+http://...".
The <fragment> 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 <allan@archlinux.org> --- scripts/makepkg.sh.in | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 985bbbd..2b29759 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -341,6 +341,88 @@ download_file() { ln -s "$SRCDEST/$filename" "$srcdir/" }
+download_git() { + local netfile=$1 + + local fragment=${netfile##*#} + if [[ $fragment = "$netfile" ]]; then + unset fragment + fi + + local folder=${netfile%%::*}
This makes my OCD twitch -- dir instead of folder?
+ local repo=${netfile##*/} + repo=${repo%%#*} + repo=${repo%%.git*} + + if [[ $folder = "$netfile" ]]; then + folder="${repo}" + fi + + if [[ ! -d "$startdir"/$folder && -d "$SRCDEST"/$folder ]]; then + folder="$SRCDEST"/$folder + else + folder="$startdir"/$folder + fi
None of the quoting in this block is strictly necessary.
+ + local url=$(get_url "$netfile") + url=${url##*git+} + url=${url%%#*} + + if [[ ! -d $folder ]]; then + msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "git" + if ! git clone --mirror "$url" "$folder"; 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 "$folder" + 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 ${folder##*/} + + if ! git clone $folder; then
Your spare quotes from above can go here.
+ error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git" + plain "$(gettext "Aborting...")" + exit 1 + fi + + cd_safe ${folder##*/}
Quotes here too, please.
+ + local ref + if [[ -n $fragment ]]; then + case $fragment in + commit=*|tag*)
tag=* rather than tag* ? You might want to trim $fragment right in the switch to avoid all the glob matching, i.e. case ${fragmen%%=*} in commit|tag) .... branch) ....
+ 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
Is that branch name really intentional here? Why not name it the same as $ref?
+ 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...")"
@@ -357,6 +439,9 @@ download_sources() { ftp|http|https|rsync|scp) download_file "$nethe tfile" ;; + git*) + download_git "$netfile" + ;; *) error "$(gettext "Unknown download protocol: %s")" "$proto" plain "$(gettext "Aborting...")" -- 1.7.11.1
Am 27.06.2012 00:58, schrieb Allan McRae:
+ if [[ ! -d "$startdir"/$folder && -d "$SRCDEST"/$folder ]]; then + folder="$SRCDEST"/$folder + else + folder="$startdir"/$folder + fi
I don't understand this logic: Does this mean that you put the git clone to $startdir/$folder by default? If $SRCDEST is set, I would always expect it to go to $SRCDEST.
On 27/06/12 18:54, Thomas Bächler wrote:
Am 27.06.2012 00:58, schrieb Allan McRae:
+ if [[ ! -d "$startdir"/$folder && -d "$SRCDEST"/$folder ]]; then + folder="$SRCDEST"/$folder + else + folder="$startdir"/$folder + fi
I don't understand this logic: Does this mean that you put the git clone to $startdir/$folder by default? If $SRCDEST is set, I would always expect it to go to $SRCDEST.
Yeah, that was an oversight there - and probably completely broken. But it is entirely fixed in patch 09/11. Allan
Am 27.06.2012 11:14, schrieb Allan McRae:
On 27/06/12 18:54, Thomas Bächler wrote:
Am 27.06.2012 00:58, schrieb Allan McRae:
+ if [[ ! -d "$startdir"/$folder && -d "$SRCDEST"/$folder ]]; then + folder="$SRCDEST"/$folder + else + folder="$startdir"/$folder + fi
I don't understand this logic: Does this mean that you put the git clone to $startdir/$folder by default? If $SRCDEST is set, I would always expect it to go to $SRCDEST.
Yeah, that was an oversight there - and probably completely broken. But it is entirely fixed in patch 09/11.
Didn't see that, but yeah, seems to make more sense there.
VCS sources should have "SKIP" for their checksum value Signed-off-by: Allan McRae <allan@archlinux.org> --- scripts/makepkg.sh.in | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 2b29759..f8d46f1 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -788,10 +788,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)) -- 1.7.11.1
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 <allan@archlinux.org> --- scripts/makepkg.sh.in | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index f8d46f1..6884272 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -210,10 +210,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 @@ -349,15 +367,12 @@ download_git() { unset fragment fi - local folder=${netfile%%::*} + local folder=$(get_filename "$netfile") + local repo=${netfile##*/} repo=${repo%%#*} repo=${repo%%.git*} - if [[ $folder = "$netfile" ]]; then - folder="${repo}" - fi - if [[ ! -d "$startdir"/$folder && -d "$SRCDEST"/$folder ]]; then folder="$SRCDEST"/$folder else -- 1.7.11.1
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 <allan@archlinux.org> --- scripts/makepkg.sh.in | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 6884272..0b282a5 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -191,19 +191,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" } @@ -367,18 +378,13 @@ download_git() { unset fragment fi - local folder=$(get_filename "$netfile") + local folder=$(get_filepath "$netfile") + [[ -z "$folder" ]] && folder="$SRCDEST/$(get_filename "$netfile")" local repo=${netfile##*/} repo=${repo%%#*} repo=${repo%%.git*} - if [[ ! -d "$startdir"/$folder && -d "$SRCDEST"/$folder ]]; then - folder="$SRCDEST"/$folder - else - folder="$startdir"/$folder - fi - local url=$(get_url "$netfile") url=${url##*git+} url=${url%%#*} -- 1.7.11.1
Am 27.06.2012 00:58, schrieb Allan McRae:
At the request of Dave, here are the updated versions of patches sent to the list earlier.
Support for the following needs readded: CVS, Mercurial, Darcs and Bazaar
Known issue: the pkgver check needs adjusted when using an auto-updating pkgver
I've used the code from your vcs branch for a bit and it worked quite well for me with git sources. It is also incredibly useful compared to the old implementation. One weird bug: I used a pkgver function like this: pkgver() { local myver ... } This failed on the 'myver' variable name, although it is local.
On Thu, Jul 12, 2012 at 05:04:52PM +0200, Thomas Bächler wrote:
Am 27.06.2012 00:58, schrieb Allan McRae:
At the request of Dave, here are the updated versions of patches sent to the list earlier.
Support for the following needs readded: CVS, Mercurial, Darcs and Bazaar
Known issue: the pkgver check needs adjusted when using an auto-updating pkgver
I've used the code from your vcs branch for a bit and it worked quite well for me with git sources. It is also incredibly useful compared to the old implementation.
One weird bug: I used a pkgver function like this:
pkgver() { local myver
... }
This failed on the 'myver' variable name, although it is local.
Just as I told you in IRC, the debug log showed that you're trying to stomp on a read-only var. bash will not let you do this even if its scoped to a function. We could probably change the name of this var, e.g. to "makepkg_version", instead of something so foolishly generic. d
Am 12.07.2012 17:15, schrieb Dave Reisner:
Just as I told you in IRC, the debug log showed that you're trying to stomp on a read-only var. bash will not let you do this even if its scoped to a function.
Which is stupid and defies the purpose of scoping.
We could probably change the name of this var, e.g. to "makepkg_version", instead of something so foolishly generic.
Exactly. Why not give ALL variables in makepkg an ugly prefix, so nobody accidently uses them. This wouldn't hurt the eyes too much when editing makepkg.in.
participants (4)
-
Allan McRae
-
Dan McGee
-
Dave Reisner
-
Thomas Bächler