[FWL] [RFC|PATCH] Add support for source control management systems to download function
Marc Andre Tanner
mat at brain-dump.org
Mon Oct 5 11:38:58 PDT 2009
Hi,
I saw your mail about the road map and would like to add another
feature to the whishlist.
I try to build a kind of mini distribution on top of the firmware
linux infrastructure (yes I have read about the distribution trap,
but mine is a special purpose one with a fixed set of about ~18
packages which then boots a fullblown system).
Anyway I needed a way to get a specfied revision out of a svn
repository and thought that feature could be useful for mainline FWL
too. It's more flexible than the unstable mechanism which FWL currently
uses but obviously depends on external scm tools which may not be there
if run natively or under emulation.
Here is what I came up with so far, there are some new variables in
download.sh:
SHA1= SCM_REV=77 \
URL=svn://svn.berlios.de/tslib/trunk/tslib \
download || dienow
SHA1= SCM=svn SCM_REV=42803 \
URL=http://svn.enlightenment.org/svn/e/trunk/TMP/st/elementary \
download || dienow
And the coresponding code in functions.sh which checks out the
requested revision (or the latest and greatest if no revision
was specified) and then creates a tarball with the revision in
it's filename.
What do you think about such functionality in general?
diff -r 47f699f5f143 sources/functions.sh
--- a/sources/functions.sh Sat Oct 03 17:26:47 2009 -0500
+++ b/sources/functions.sh Mon Oct 05 20:14:07 2009 +0200
@@ -310,10 +310,64 @@
try_checksum
}
+function try_download_scm()
+{
+ SCM_TYPE=$SCM
+ [ -z "$SCM" ] && SCM_TYPE=`echo "$URL" | sed 's ://.* '`
+
+ # In a first step get a tarball filename for the requested revison
+
+ [ -z "$SCM_REV" ] && SCM_REV="HEAD"
+
+ case "$SCM_TYPE" in
+ git)
+ echo git support not yet implemented
+ return 1;
+ ;;
+ hg)
+ echo hg support not yet implemented
+ return 1;
+ ;;
+ svn)
+ PACKAGE=`echo "$URL" | sed 's .*/ '`
+ DIRNAME=$PACKAGE-r$SCM_REV
+ FILENAME=$PACKAGE-r$SCM_REV.tar.bz2
+ ;;
+ *) return 1
+ esac
+
+ # Update timestamp so cleanup_oldfiles doesn't delete it
+ touch -c "$SRCDIR/$FILENAME" 2>/dev/null
+
+ # Return success if we have a valid copy of the file
+ try_checksum && return 0
+
+ echo Checking out $PACKAGE revision $SCM_REV from $SCM repository
+ # Checkout files from source repository if no revison was
+ # requested find out which revison current HEAD is and
+ # package everything into a tarball.
+ case "$SCM_TYPE" in
+ svn)
+ svn co --non-interactive -r$SCM_REV "$URL" "$SRCDIR/$PACKAGE" | dotprogress || return 1
+ [ "x$SCM_REV" = "xHEAD" ] && cd "$SRCDIR/$PACKAGE" && \
+ DIRNAME="$PACKAGE-r$(svn info | grep Revision: | sed 's/Revision: //')" && cd - 1> /dev/null
+ mv "$SRCDIR/$PACKAGE" "$SRCDIR/$DIRNAME" &&
+ find "$SRCDIR/$DIRNAME" -name .svn | xargs rm -rf &&
+ tar -C "$SRCDIR" -cjf "$SRCDIR/$DIRNAME.tar.bz2" "$DIRNAME" &&
+ rm -rf "$SRCDIR/$DIRNAME" &&
+ return 0
+ ;;
+ esac
+
+ return 1
+}
+
# Confirm a file matches sha1sum, else try to download it from mirror list.
function download()
{
+ try_download_scm && return 0
+
FILENAME=`echo "$URL" | sed 's .*/ '`
[ -z "$RENAME" ] || FILENAME="$(echo "$FILENAME" | sed -r "$RENAME")"
ALTFILENAME=alt-"$(noversion "$FILENAME" -0)"
--
Marc Andre Tanner >< http://www.brain-dump.org/ >< GPG key: CF7D56C0
More information about the firmware
mailing list