summaryrefslogtreecommitdiffstats
path: root/make-fedora-ostree-tarball
blob: c27c5a2fe524b3bbc95cb9f518cc1d8849bab937 (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
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
#!/usr/bin/env bash

srcdir=$(dirname $0)
builddir=$(pwd)
releasever=19
name=fedora-ostree-${releasever}
prefix=$(pwd)/${name}
yumroot=${prefix}.yum
targetroot=${prefix}.root
output=${name}.tar.gz
yumcachedir=${yumroot}/var/cache/yum
yumcache_lookaside=${prefix}.yum-cache
logs_lookaside=${prefix}.logs

set -x
set -e

rm ${yumroot} -rf
if test -d ${yumcache_lookaside}; then
    mkdir -p ${yumroot}/var/cache/
    cp -a ${yumcache_lookaside} ${yumcachedir}
fi
yum -c ${srcdir}/fedora-ostree.repo -y --releasever=${releasever} --nogpg --installroot=${yumroot} --disablerepo='*' --enablerepo=fedora --enablerepo=fedora-ostree install systemd passwd yum ostree fedora-release vim-minimal kernel dracut e2fsprogs less
if test "${mfotbreak}" = "post-yum"; then
    bash
fi

# Now make an empty "real" root
rm ${targetroot} -rf
mkdir ${targetroot}
cd ${targetroot}

for d in dev proc run sys var; do
    mkdir $d
done

# Special ostree mount
mkdir sysroot

# Some FHS targets; these all live in /var
ln -s var/opt opt
ln -s var/srv srv
ln -s var/mnt mnt
ln -s var/roothome root

# This one is dynamic, so just lives in /run
ln -s run/media media

# Special OSTree link, so it's /ostree both on
# the real disk and inside the chroot.
ln -s sysroot/ostree ostree

# /tmp is always /sysroot/tmp
ln -s sysroot/tmp tmp

# By default, /home -> var/home -> ../sysroot/home
ln -s var/home home

# These are the only directories we take from the Fedora build
mv ${yumroot}/usr .
# Except /usr/local -> ../var/usrlocal
rm usr/local -rf
ln -s ../var/usrlocal usr/local
# And /etc -> /usr/etc
rm usr/etc -rf
mv ${yumroot}/etc usr/etc

# Move boot, but rename the kernel/initramfs to have a checksum
mv ${yumroot}/boot .
kernel=$(ls boot/vmlinuz-3*)
initramfs=$(ls boot/initramfs-3*)
bootcsum=$(cat ${kernel} ${initramfs} | sha256sum | cut -f 1 -d ' ')
mv ${kernel} ${kernel}-${bootcsum}
mv ${initramfs} ${initramfs}-${bootcsum}

# Also move the toplevel compat links
mv ${yumroot}/lib .
if test -L ${yumroot}/lib64; then
    mv ${yumroot}/lib64 .
fi
mv ${yumroot}/bin .
mv ${yumroot}/sbin .

mkdir -p usr/lib/tmpfiles.d
cp ${srcdir}/tmpfiles-gnome-ostree.conf usr/lib/tmpfiles.d

# Ok, let's globally fix permissions in the Fedora content;
# everything is root owned, all directories are u=rwx,g=rx,og=rx.
chown -R -h 0:0 usr boot
for x in usr boot; do
    find $x -type d -exec chmod u=rwx,g=rx,og=rx "{}" \;
done

cd ${builddir}

# Attempt to cache stuff between runs
rm ${yumcache_lookaside} -rf
mv ${yumcachedir} ${yumcache_lookaside}

# And move the log files out
rm "${logs_lookaside}" -rf
mkdir -p "${logs_lookaside}"
mv ${yumroot}/var/log/* ${logs_lookaside}

tar -c -z -C ${targetroot} -f ${output} .
echo "Generated ${output}"
rm ${yumroot} -rf
rm ${targetroot} -rf