-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakenewzfs.sh
executable file
·80 lines (69 loc) · 2.44 KB
/
makenewzfs.sh
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
function guessnewversion() {
txt=$(curl --silent https://zfsonlinux.org/ | grep -A4 '#80ff00'|tr /- "\n"|grep '[0-9]\+.*<$'|sed 's/<$//'|uniq)
c=$(echo "$txt"|wc -l)
if [ '1' == "$c" ]; then
echo $txt
fi
}
function guesslatestkernel() {
curl https://www.kernel.org/ --silent|grep -A2 latest_link|tr '<>' '\n'|grep -B1 ^/a$|head -1
}
set -e
pwd=$(pwd)
wd=$(mktemp -d)
cd $wd
guessed=$(guessnewversion)
NEWVERSION=${NEWVERSION:-${guessed:-0.7.9}}
KERN=${KERN:-"$(uname -r)"}
PKGTYPE=${PKGTYPE:-txz}
slackver=${slackver:-14.2}
sbourl=${sbourl:-https://www.slackbuilds.org/slackbuilds}
pending=$(echo $sbourl|sed 's?/slackbuilds?/pending/?')
sbolist=zfs-on-linux
out=$pwd/out/$NEWVERSION
failfast=$(curl --silent --insecure $pending|grep zfs-on-linux.tar|cut -d'>' -f4-|cut -d'<' -f1)
if [[ ! -z "$failfast" ]]; then
echo Submission pending since $failfast UTC. Skipping.
exit 0
fi
export KERN PKGTYPE
mkdir -pv $out
for sbo in $sbolist; do
curl -# --insecure $sbourl/$slackver/system/$sbo.tar.gz > $sbo.tar.gz
tar xf $sbo.tar.gz
(
cd $sbo
VERSION=$(grep ^VERSION= $sbo.info|cut -d'"' -f2|sed 's:\.:\\.:g')
sed -i.old "s/$VERSION/$NEWVERSION/g; s/2017 Marcin/2017-2020 Marcin/; s/2017-2020 Marcin/2017-$(date +%Y) Marcin/" $sbo.info $sbo.SlackBuild
sed -i.older "s/\(export KERN=\)\([45]\(\.[0-9]\{1,2\}\)\{1,2\}\)/\1$(guesslatestkernel)/" README
sums=$(md5sum $sbo.info $sbo.info.old|cut -d ' ' -f1|uniq|wc -l)
if [ "1" == "$sums" ]; then
echo Nothing has changed yet, leave it.
exit 1
fi
srcurl=$(grep DOWNLOAD= $sbo.info|cut -d'"' -f2)
wget --no-check-certificate "$srcurl"
MD5SUM=$(md5sum *.gz |cut -d' ' -f1)
sed -i.old.md5 "s/^MD5SUM=.*$/MD5SUM=\"$MD5SUM\"/" $sbo.info
tar xf *.gz
# Build faster, stay low:
sed -e 's/^env -u ARCH make$/env -u ARCH make -j 19 || env -u ARCH make/' ./$sbo.SlackBuild -i
./$sbo.SlackBuild
sed -e 's/^env -u ARCH make -j 19 || env -u ARCH make$/env -u ARCH make/' ./$sbo.SlackBuild -i
#installpkg /tmp/$sbo-${NEWVERSION}_${KERN}-*_SBo.$PKGTYPE
)
tar tf $sbo.tar.gz|grep -v /$|tar cvvf - -T -|gzip -9 > $out/$sbo.tar.gz
ln -f $out/$sbo.tar.gz $out/../$sbo.tar.gz
done
#exit 14
cd $pwd
for sbo in $sbolist; do
curl \
-F "userfile=@out/$sbo.tar.gz;filename=$sbo.tar.gz" \
-F 'comments=Updated for version $NEWVERSION' \
-F [email protected] \
-F MAX_FILE_SIZE=1048576 -F category=System -F submit=Submit \
https://www.slackbuilds.org/process_submit/
done
rm -rf $wd /tmp/SBo