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

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

set -x
set -e

rm ${root} -rf
if test -d ${yumcache_lookaside}; then
    mkdir -p ${root}/var/cache/
    cp -a ${yumcache_lookaside} ${yumcachedir}
fi
yum -c ${srcdir}/fedora-ostree.repo -y --releasever=${releasever} --nogpg --installroot=${root} --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 ${root}.real -rf
mkdir ${root}.real
cd ${root}.real

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 ${root}/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 ${root}/etc usr/etc

# Move boot, but rename the kernel/initramfs to have a checksum
mv ${root}/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 ${root}/lib .
if test -L ${root}/lib64; then
    mv ${root}/lib64 .
fi
mv ${root}/bin .
mv ${root}/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 etc boot
for x in usr etc boot; do
    find $x -type d -exec chmod u=rwx,g=rx,og=rx "{}" \;
done

# Blow away stuff we don't want here
rm ${root}/var/lib/yum/* -rf

# 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 ${root}/var/log/* ${logs_lookaside}

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