summaryrefslogtreecommitdiff
path: root/scripts/fetch-curl.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/fetch-curl.sh')
-rw-r--r--scripts/fetch-curl.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/scripts/fetch-curl.sh b/scripts/fetch-curl.sh
new file mode 100644
index 00000000..86f7598e
--- /dev/null
+++ b/scripts/fetch-curl.sh
@@ -0,0 +1,40 @@
+set -e
+
+if [ "$#" != 1 ] ; then
+ echo 'usage: fetch-curl.sh dir' >&2
+ exit 2
+fi
+
+dir=$1
+shift
+
+cd "$dir"
+
+if [ -e src ] ; then
+ rm -rf src
+fi
+
+if ! sha256sum -c sha256 2>/dev/null ; then
+ curl -L -K url -O
+ sha256sum -c sha256
+fi
+
+while read -r checksum archive ; do
+ case $archive in
+ *.tar.gz|*.tgz)
+ tool=zcat ;;
+ *.tar.bz2)
+ tool=bzcat ;;
+ *.tar.xz)
+ tool=xzcat ;;
+ *)
+ tool=
+ esac
+ if [ -n "$tool" ] ; then
+ "$tool" "$archive" | pax -r -s '/^\.\|[^\/]*/src/' '*/*'
+ fi
+done <sha256
+
+if [ -d patch ] ; then
+ git apply -v --whitespace=nowarn --directory "$dir/src" patch/*
+fi