#!/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 set -x set -e rm ${root} -rf if test -d ${yumcache_lookaside}; then mkdir -p ${root}/var/cache/ mv ${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 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 if test -d ${yumcachedir}; then mv ${yumcachedir} ${yumcache_lookaside} fi rm ${root}/var/lib/yum/* -rf rm ${root}/var/cache/yum/* -rf rm ${root}/var/log/* -rf tar -c -z -C ${root} -f ${output} . echo "Generated ${output}" rm ${root} -rf