summaryrefslogtreecommitdiff
path: root/scripts/fetch-curl.rc
blob: 9f811837943aac59d3d2477984a6fb0bcb7c8366 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/rc

flag e +

if(~ $#* 0) {
	echo 'usage: fetch-curl.rc dir pattern...' >[1=2]
	exit 2
}

cd $1
shift

if([ -e 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 *.tar.gz
		tool=zcat
	case *.tar.bz2
		tool=bzcat
	case *.tar.xz
		tool=xzcat
	case *
		tool=()
	}
	pats=()
	while(! ~ $1 '' ';') {
		pats=($pats $1)
		shift
	}
	shift
	if(! ~ $#tool 0) $tool $archive | pax -r -s '/^\.\|[^\/]*/src/' $pats
}

if([ -d patch ]) {
	if(prefix=`{git rev-parse --show-prefix >[2]/dev/null}) dir=$prefix^src
	if not dir=src
	git apply -v '--whitespace=nowarn' --directory $dir patch/*
}
status=()