/
prepimage
executable file
·119 lines (109 loc) · 3.82 KB
/
prepimage
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
# Make sure to specify the build to grab. I know I could just grab current
# but honestly, do some work yourself!
release=$1
fragged=0
IMAGENAME=Angstrom-bug-image-production-glibc-ipk-2009.X-stable-bug20.rootfs.tar
INCRURL=http://dauber/buildbot/trunk/incremental/
FULLURL=http://dauber/buildbot/trunk/full/
REPOURL=http://dauber/buildbot/repo/full/
#ACCTURL=http://bugcommunity.com/downloads/accenture/
ACCTURL=http://dauber/buildbot/accenture/full/
EXT_URL=http://repo.buglabs.net/buildbot-images/2.0/
if [ "$1" == "--help" ]; then
echo "$0 [Build Number] [full|incr|acct]"
echo "$0 with no arguments will tell you the latest build number for each tree"
echo -e "\trc will pull from the repo/full/RC builds"
echo -e "\tfull will pull from the full builds"
echo -e "\tincr will pull from the incremental builds"
echo -e "\tacct will pull from the Accenture specific builds"
echo
echo "I must be getting soft, there is a special mode for external pulls --bbot no other args"
echo "You need superuser privs to run this, sudo please"
fi
if [[ $EUID -ne 0 ]] && [[ $# -ne 0 ]]; then
echo "You need superuser privs to do anything constructive, sudo please"
exit 1
fi
if [ "$1" == "--bbot" ]; then
BASEURL=$EXT_URL
release=$(wget -q -O - $EXT_URL/svninfo | grep Revision | sed 's/Revision: //')
elif [ "$2" == "rc" ]; then
BASEURL=$REPOURL
elif [ "$2" == "full" ]; then
BASEURL=$FULLURL
elif [ "$2" == "acct" ]; then
BASEURL=$ACCTURL
elif [ "$2" == "incr" ]; then
BASEURL=$INCRURL
else
BASEURL=$FULLURL
fi
if [ -z $release ]; then
echo please specify the svn build \# of the rc ya want
echo the current releases are:
echo $EXT_URL
wget -q -O - $EXT_URL/svninfo | grep Revision
for URL in $REPOURL $FULLURL $ACCTURL $INCRURL ; do
echo $URL :
wget -q -O - $URL/current/svninfo | grep Revision
done
exit
fi
if [ "$1" == "--bbot" ]; then
# grab the tarball
wget -r -nd -np ${BASEURL}${IMAGENAME}.gz
# quick and dirty way to see if we got a good pull
if [ ! -f ${IMAGENAME}.gz ]; then
echo "You took the easy way and it didn't work. Nice"
echo "There is no hope for this option, the build is broke, the network is broke, something broke"
echo Try later, tomorrow, cry on IRC, I dunno. kthxbai
exit
fi
# and the md5 file
wget -r -nd -np ${BASEURL}${IMAGENAME}.gz.md5
if [ $? -ne 0 ]; then
echo Seriously, nothing ever goes right, eh?
echo Go plug in your network cable and see if $release actually built
exit
fi
else
# grab the tarball
wget -r -nd -np $BASEURL${release}/${IMAGENAME}.gz
# quick and dirty way to see if we got a good pull
if [ ! -f ${IMAGENAME}.gz ]; then
echo You are pissing me off. Did you even give me a valid release number?
echo Current is $(wget -q -O - ${BASEURL}current/svninfo | grep Revision)
echo kthxbai
exit
fi
# and the md5 file
wget -r -nd -np $BASEURL${release}/${IMAGENAME}.gz.md5
if [ $? -ne 0 ]; then
echo Seriously, do you hate me that much? I can not get there from here.
echo Go plug in your network cable and see if $release actually built
exit
fi
fi
#clean up paths in md5 files
sed -i 's/ [\.|\/].*\/\(.*\)/ \1/' ${IMAGENAME}.gz.md5
md5sum -c ${IMAGENAME}.gz.md5
if [ $? -ne 0 ]; then
echo '******************************************************** '
echo MD5 sum of file ${IMAGENAME}.gz did not match
echo I echo didn\'t get the rootfs down clean, check your net
echo check your teeth, maybe your shoe is untied, TRY AGAIN
echo '******************************************************** '
exit 1
fi
# In the future, error checking is whay you want to put in here
gunzip ${IMAGENAME}.gz
mv ${IMAGENAME} $release.rootfs.tar
TMPDIR=$(mktemp -d)
cd $TMPDIR
tar xf ${OLDPWD}/$release.rootfs.tar
find -type f -exec md5sum {} \; > ${OLDPWD}/$release.rootfs.tar.list.md5
cd ${OLDPWD}
rm -rf $TMPDIR
rm -f ${IMAGENAME}.gz.md5
md5sum $release.rootfs.tar > $release.rootfs.tar.md5