summaryrefslogtreecommitdiffstats
path: root/create-n-build.sh
blob: 61184cd530fade953b6f5f5f55d95461bb7c6475 (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
46
47
48
49
50
51
52
53
54
#!/bin/bash

THISDIR=/home/rolson/swift-lang-packaging-fedora

pushd $THISDIR

# Gives us the version number of this platform
THISVERSION=`cat /etc/os-release | grep PLATFORM_ID | awk -F: '/platform:*/{print $2}' | cut -c 2- | rev | cut -c 2- | rev`
echo Building on $THISVERSION of Fedora

# First we want to capture the hash of the swift-lang.spec
# file...
bh=`md5sum ./swift-lang.spec`

# Now run the python program to check for updates
# and modify the swift-lang.spec file accordingly
./nrc.py

# Now hash the file again
ah=`md5sum ./swift-lang.spec`

# And now only bother doing the rest of the script
# if the hash was changed, otherwise exit
if [ "$bh" = "$ah" ]; then
	exit 0
fi

# Okay, we're gonna do this...

rm -rf /home/rolson/rpmbuild
rm $THISDIR/cnb-build-output.txt
mkdir -p /home/rolson/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
cp $THISDIR/*.patch /home/rolson/rpmbuild/SOURCES
cp $THISDIR/*.conf /home/rolson/rpmbuild/SOURCES
cp $THISDIR/swift-lang.spec /home/rolson/rpmbuild/SPECS

pushd /home/rolson/rpmbuild/SPECS
spectool -g -R ./swift-lang.spec
# Get the dependencies
dnf builddep -y ./swift-lang.spec
# Now do the actual build
rpmbuild -ba ./swift-lang.spec 2>&1 | tee $THISDIR/cnb-build-output.txt
popd

# And commit it to the nightly-builds branch
#git checkout nightly-builds
git commit -am "Updated to `awk '/%global swifttag *./{print $3}' ./swift-lang.spec`"
git push 

# Now move it to fedorapeople
ssh fedorapeople.org "rm ~/public_html/swift-lang/*$THISVERSION*.rpm"
scp /home/rolson/rpmbuild/SRPMS/* fedorapeople.org:~/public_html/swift-lang
scp /home/rolson/rpmbuild/RPMS/x86_64/* fedorapeople.org:~/public_html/swift-lang
scp /home/rolson/rpmbuild/SPECS/* fedorapeople.org:~/public_html/swift-lang