forked from RasPlex/OpenELEC.tv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdobuild.sh
executable file
·183 lines (147 loc) · 4.45 KB
/
dobuild.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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/bin/bash
# options
version=""
devbuild=0
sourceforge=0
force_pht_rebuild=0
force_pht_update=0
#read default settings
settingsfile=~/.rasplex
[ -f "$settingsfile" ] && source "$settingsfile"
function usage {
echo "$0 usage:
[-h | --help] : print this usage info
-v | --version <version> : set the rasplex version
[-d | --devbuild] : create a developer build
[-s | --sourceforge] : upload the image to sourceforge
[--user <user>] : the sourceforge user to use
optional build options:
--force-pht-rebuild : will force a pht rebuild
--force-pht-update : will force a pht to download the latest code
and will force a rebuild
default options can be set via $settingsfile and will be evaluated first.
";
}
[ $# -eq 0 ] && usage && exit 1
while true; do
case $1 in
-h|--help)
usage
exit 0
;;
-v|--version)
shift
if [ -z $1 ]; then
echo "version parameter missing!"
exit 1
fi
version="$1"
;;
-d|--devbuild)
devbuild=1
;;
-s|--sourceforge)
sourceforge=1
;;
--user)
shift
if [ -z $1 ]; then
echo "user parameter missing!"
exit 1
fi
user="$1"
;;
--force-pht-rebuild)
force_pht_rebuild=1
;;
--force-pht-update)
force_pht_update=1
;;
--)
shift; break;;
*)
shift; break;;
esac
shift
done
# validate settings
[ -z "$version" ] && echo "Missing version number" && usage && exit 1
# setup variables
distroname="rasplex"
devtools="no"
if [ $devbuild -eq 1 ];then
distroname="rasplexdev"
devtools="yes"
echo "This is a development build!"
fi
scriptdir=$(cd `dirname $0` && pwd)
outfilename="$distroname-RPi.arm-$version"
tmpdir="$scriptdir/tmp"
outimagename="$distroname-$version.img"
outimagefile="$tmpdir/$outimagename"
targetdir="$scriptdir/target"
# set rasplex config
echo "
RASPLEX_VERSION=\"$version\"
DISTRONAME=\"$distroname\"
" > $scriptdir/config/rasplex
sed s/SET_RASPLEXVERSION/"$version"/g $scriptdir/config/version.in > $scriptdir/config/version
# build
function build {
echo "Building rasplex"
source $scriptdir/config/version
if [ $force_pht_update -eq 1 ]; then
rm -r "sources/plexht"
rm -r "$scriptdir/build.rasplex-RPi.arm-$OPENELEC_VERSION/.stamps/plexht"
elif [ $force_pht_rebuild -eq 1 ]; then
rm "$scriptdir/build.rasplex-RPi.arm-$OPENELEC_VERSION/.stamps/plexht/build"
fi
time DEVTOOLS="$devtools" PROJECT=RPi ARCH=arm make release -j `nproc` || exit 2
}
# create image file
function create_image {
echo "Creating SD image"
mkdir -p $tmpdir
rm -rf $tmpdir/*
cp "$targetdir/$outfilename".tar $tmpdir
echo " Extracting release tarball..."
tar -xpf "$tmpdir/$outfilename".tar -C $tmpdir
echo " Setup loopback device..."
if [ "`losetup -f`" != "/dev/loop0" ];then
umount /dev/loop0
losetup -d /dev/loop0 || eval 'echo "It demands loop0 instead of first free loopback device... : (" ; exit 1'
fi
losetup -d /dev/loop0 || [ echo "It demands loop0 instead of first free device... : (" && exit 1 ]
loopback=`losetup -f`
echo " Prepare image file..."
dd if=/dev/zero of=$outimagefile bs=1M count=1500
echo " Write data to image..."
cd $tmpdir/$outfilename
./create_sdcard $loopback $outimagefile
echo "Created SD image at $outimagefile"
}
function upload_sourceforge {
projectdir="/home/frs/project/rasplex"
projectdlbase="http://sourceforge.net/projects/rasplex/files"
[ -z "$user" ] && user=`whoami`
echo "Distributing build"
cd "$tmpdir"
echo " compressing image..."
gzip "$outimagefile"
echo " uploading autoupdate package"
time scp "$outfilename".tar "$user@frs.sourceforge.net:$projectdir/autoupdate/$distroname/"
echo " uploading install image"
if [ $devbuild -eq 1 ];then
releasedir="development"
else
releasedir="release"
fi
time scp "$outimagefile.gz" "$user@frs.sourceforge.net:$projectdir/$releasedir/"
}
# main
build
create_image
if [ $sourceforge -eq 1 ]; then
upload_sourceforge
fi
echo "done."