forked from CentOS/sig-atomic-buildscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_stage1.sh
executable file
·89 lines (63 loc) · 2.76 KB
/
build_stage1.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
#!/bin/bash
## Run the script from /srv (or other HomeDir, if you change the value
## below) like so:
##
## bash sig-atomic-buildscripts/build_ostree_components.sh /srv/builddir
##
## Other files to edit/check:
##
## atomic-7.1.tdl must point to an install tree avail over http,
## there's a hard-coded IP address there now
##
## atomic-7.1-cloud.ks and atomic-7.1-vagrant.ks must point to
## the desired ostree repo in line beginning w/ "ostreesetup"
VERSION=7.$( date +%Y%m%d )
DateStamp=$( date +%Y%m%d_%H%M%S )
BuildDir=$1
LogFile=${BuildDir}/log
mkdir -p ${BuildDir}
# Make it absolute
BuildDir=$(cd $BuildDir && pwd)
GitDir=${BuildDir}/sig-atomic-buildscripts
OstreeRepoDir=/srv/repo && mkdir -p $OstreeRepoDir
ln -s ${OstreeRepoDir} ${BuildDir}/repo
set -x
set -e
set -o pipefail
## update script from git, commented out for now
cd ${BuildDir}
git clone https://github.com/CentOS/sig-atomic-buildscripts && cd sig-atomic-buildscripts && git checkout downstream
cd ${BuildDir}
# Init, make sure we have the bits we need installed.
cp -f ${GitDir}/rhel-atomic-rebuild.repo /etc/yum.repos.d/
yum -y install ostree rpm-ostree glib2 docker libvirt epel-release libgsystem
if [ -f ${GitDir}/atomic7-testing.repo ]; then
mv ${GitDir}/atomic7-testing.repo /etc/yum.repos.d/
fi
echo 'enabled=0' >> /etc/yum.repos.d/atomic7-testing.repo
yum --enablerepo=atomic7-testing -y install rpm-ostree-toolbox
service firewalld stop
## backup the last built repo, commented out for now
# XXX: We need to only retain the last 14 builds or so, Todo, add a find + rm for older tree's
#/bin/rsync -Ha --stats /srv/rolling/ /srv/rolling.${DateStamp} > ${LogFile} 2>&1
#echo '----------' >> ${LogFile}
## create repo in BuildDir, this will fail w/o issue if already exists
if ! test -d ${BuildDir}/repo/objects; then
ostree --repo=${BuildDir}/repo init --mode=archive-z2
fi
# sync repo from ds location
ostree remote add --repo=/srv/repo centos-atomic-host --set=gpg-verify=false http://mirror.centos.org/centos/7/atomic/x86_64/repo && ostree pull --depth=-1 --repo=/srv/repo --mirror centos-atomic-host centos-atomic-host/7/x86_64/standard
## compose a new tree, based on defs in centos-atomic-host.json
rpm-ostree compose --repo=${OstreeRepoDir} tree --touch-if-changed=${BuildDir}/changed.stamp ${GitDir}/centos-atomic-host.json |& tee ${BuildDir}/log.compose
## stop the script unless a new commit has been made
if ! test -f ${BuildDir}/changed.stamp; then
echo "No changes, will not proceed."
exit 1
else
rm ${BuildDir}/changed.stamp
fi
# deal with https://bugzilla.gnome.org/show_bug.cgi?id=748959
chmod -R a+r /srv/repo/objects
find /srv/repo/ -type d -exec chmod -R a+x {} \;
find /srv/repo/ -type f -exec chmod -R a+r {} \;
echo 'Stage-1 done, you can now sign the repo, or just run stage2 '