summaryrefslogtreecommitdiffstats
path: root/classes
diff options
context:
space:
mode:
authorAnton Gerasimov <anton@advancedtelematic.com>2016-09-01 16:11:52 +0200
committerAnton Gerasimov <anton@advancedtelematic.com>2016-09-01 16:11:52 +0200
commit38b09fb1d11a2d66decaff2c5180eb6fac0cbb6d (patch)
treee76a79a349871195d3fd7ef6be4ab5527d06e2b1 /classes
parent081b8be83fd8dd718ea8feb7e3cd6baea271032b (diff)
downloadmeta-updater-38b09fb1d11a2d66decaff2c5180eb6fac0cbb6d.tar.gz
Adds image type for OSTree deployment sysroot
Bug-AGL: SPEC-246 Change-Id: I1390d1aae652f84b61a3b9ca33ae886c138edc50 Signed-off-by: Anton Gerasimov <anton@advancedtelematic.com>
Diffstat (limited to 'classes')
-rw-r--r--classes/image_types_ostree.bbclass87
1 files changed, 87 insertions, 0 deletions
diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass
new file mode 100644
index 0000000..b82bfb7
--- /dev/null
+++ b/classes/image_types_ostree.bbclass
@@ -0,0 +1,87 @@
1# OSTree deployment
2
3inherit image_types
4
5IMAGE_DEPENDS_ostree = "ostree-native:do_populate_sysroot \
6 virtual/kernel:do_deploy \
7 ${INITRAMFS_IMAGE}:do_rootfs"
8
9# Please redefine OSTREE_REPO in your local.conf in order to have a persistent
10# OSTree repo
11OSTREE_REPO ?= "${DEPLOY_DIR_IMAGE}/ostree_repo"
12export OSTREE_REPO
13
14# OSTREE_BRANCHNAME can also be redefined
15OSTREE_BRANCHNAME ?= "${IMAGE_BASENAME}"
16export OSTREE_BRANCHNAME
17
18IMAGE_CMD_ostree () {
19 OSTREE_ROOTFS=`mktemp -d ${WORKDIR}/ostree-root-XXXXX`
20 cp -rp ${IMAGE_ROOTFS}/* ${OSTREE_ROOTFS}
21 cd ${OSTREE_ROOTFS}
22
23 # Create sysroot directory to which physical sysroot will be mounted
24 mkdir sysroot
25 ln -sf /sysroot/ostree ostree
26 ln -sf /sysroot/tmp tmp
27
28 mkdir -p usr/rootdirs
29 mkdir -p var/rootdirs
30
31 # Implement UsrMove
32 dirs="bin sbin lib"
33
34 for dir in ${dirs} ; do
35 if [ -d ${dir} ] && [ ! -L ${dir} ] ; then
36 mv ${dir} usr/rootdirs/
37 rm -rf ${dir}
38 ln -sf /usr/rootdirs/${dir} ${dir}
39 fi
40 done
41
42 # Move persistent directories to /var
43 dirs="home opt mnt media srv"
44
45 for dir in ${dirs}; do
46 if [ -d ${dir} ] && [ ! -L ${dir} ]; then
47 mv ${dir} var/rootdirs/
48 ln -sf /var/rootdirs/${dir} ${dir}
49 fi
50 done
51
52 if [ -d root ] && [ ! -L root ]; then
53 mv root var/roothome
54 ln -sf /var/roothome root
55 fi
56
57 # Creating boot directories is required for "ostree admin deploy"
58
59 mkdir -p boot/loader.0
60 mkdir -p boot/loader.1
61 ln -sf boot/loader.0 boot/loader
62
63 checksum=`sha256sum ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} | cut -f 1 -d " "`
64
65 cp ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} boot/vmlinuz-${checksum}
66 cp ${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}-${MACHINE}.cpio.gz boot/initramfs-${checksum}
67
68 cd ${WORKDIR}
69
70 # Create a tarball that can be then commited to OSTree repo
71 OSTREE_TAR=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ostree.tar.bz2
72 tar -C ${OSTREE_ROOTFS} -cjf ${OSTREE_TAR} .
73 rm -rf ${OSTREE_ROOTFS}
74
75 if [ ! -d ${OSTREE_REPO} ]; then
76 ostree --repo=${OSTREE_REPO} init --mode=archive-z2
77 fi
78
79 # Commit the result
80 ostree --repo=${OSTREE_REPO} commit \
81 --tree=tar=${OSTREE_TAR} \
82 --skip-if-unchanged \
83 --branch=${OSTREE_BRANCHNAME} \
84 --subject="Commit-id: ${IMAGE_NAME}"
85
86}
87