summaryrefslogtreecommitdiff
path: root/fetch.rc
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2016-06-07 00:43:30 -0700
committerMichael Forney <mforney@mforney.org>2016-06-07 00:43:30 -0700
commitcd95be727e4a727da3a3097bf68191c8a4a8e8b6 (patch)
tree640da16fd3e3fe0bd013e7bbd6283b7ccd0456da /fetch.rc
parenta26f7ea299737660277c9775c41f57b74e8c21c4 (diff)
Add global fetch.rc script
Diffstat (limited to 'fetch.rc')
-rwxr-xr-xfetch.rc101
1 files changed, 101 insertions, 0 deletions
diff --git a/fetch.rc b/fetch.rc
new file mode 100755
index 00000000..5c2137f1
--- /dev/null
+++ b/fetch.rc
@@ -0,0 +1,101 @@
+#!/bin/rc
+
+flag e +
+
+aflag=0
+if(~ $1 -a) aflag=1
+if not if(~ $#* 0) {
+ echo 'usage: '$0' package...'
+ echo ' '$0' -a'
+} >[1=2]
+
+packages=$*
+
+cd `{git rev-parse --show-toplevel}
+
+fn fetch-git {
+ git submodule update --init --checkout src
+ if([ -d patch ]) {
+ patches=patch/*
+ git -C src am ../$patches
+ }
+ status=()
+}
+
+fn fetch-curl {
+ if([ -d src ]) rm -rf src
+
+ if(! sha256sum -c sha256 >[2]/dev/null) {
+ curl -L -O -K url
+ sha256sum -c sha256
+ }
+
+ for(archive in `{awk '{print $2}' sha256}) {
+ switch($archive) {
+ case *.gz
+ tool=zcat
+ case *.bz2
+ tool=bzcat
+ case *.xz
+ tool=xzcat
+ case *
+ tool=()
+ }
+ if(! ~ $#tool 0) $tool $archive | pax -r -s '/^\.\|[^\/]*/src/'
+ }
+
+ if([ -d patch ]) {
+ if(prefix=`{git rev-parse --show-prefix >[2]/dev/null}) dir=$prefix^src
+ if not dir=src
+ git apply -v --directory $dir patch/*
+ }
+ status=()
+}
+
+fn fetch {
+ if (~ $aflag 1 || ~ $1 $packages) @ {
+ cd $1
+ switch($2) {
+ case git
+ fetch-git
+ case curl
+ fetch-curl
+ case *
+ echo 'unknown fetch type: '$2
+ }
+ }
+ status=()
+}
+
+fetch core/awk git
+fetch core/bzip2 curl
+fetch core/curl git
+fetch core/file git
+fetch core/git git
+fetch core/iproute2 git
+fetch core/kbd git
+fetch core/libressl git
+fetch core/loksh git
+fetch core/mdocml curl
+fetch core/msmtp git
+fetch core/ninja git
+fetch core/openbsd curl
+fetch core/openssh git
+fetch core/perp curl
+fetch core/pigz git
+fetch core/plan9port git
+fetch core/sbase git
+fetch core/sinit git
+fetch core/tz git
+fetch core/ubase git
+fetch core/zlib git
+fetch desktop/plan9fontsn git
+fetch devel/cparser git
+fetch devel/libfirm git
+fetch devel/make git
+fetch extra/libevent git
+fetch extra/libfuse git
+fetch extra/pcre curl
+fetch extra/sshfs git
+fetch extra/the_silver_searcher git
+fetch extra/transmission curl