summaryrefslogtreecommitdiffstats
path: root/meta/classes/rootfs_deb.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/rootfs_deb.bbclass')
-rw-r--r--meta/classes/rootfs_deb.bbclass130
1 files changed, 130 insertions, 0 deletions
diff --git a/meta/classes/rootfs_deb.bbclass b/meta/classes/rootfs_deb.bbclass
new file mode 100644
index 0000000000..7712911b02
--- /dev/null
+++ b/meta/classes/rootfs_deb.bbclass
@@ -0,0 +1,130 @@
1DEPENDS_prepend = "dpkg-native apt-native fakeroot-native "
2DEPENDS_append = " ${EXTRA_IMAGEDEPENDS}"
3
4PACKAGES = ""
5
6do_rootfs[nostamp] = 1
7do_rootfs[dirs] = ${TOPDIR}
8do_build[nostamp] = 1
9
10ROOTFS_POSTPROCESS_COMMAND ?= ""
11
12PID = "${@os.getpid()}"
13
14# some default locales
15IMAGE_LINGUAS ?= "de-de fr-fr en-gb"
16
17LINGUAS_INSTALL = "${@" ".join(map(lambda s: "locale-base-%s" % s, bb.data.getVar('IMAGE_LINGUAS', d, 1).split()))}"
18
19fakeroot rootfs_deb_do_rootfs () {
20 set +e
21 mkdir -p ${IMAGE_ROOTFS}/var/dpkg/{info,updates}
22
23 rm -f ${STAGING_DIR}/etc/apt/sources.list
24 rm -f ${STAGING_DIR}/etc/apt/preferences
25 > ${IMAGE_ROOTFS}/var/dpkg/status
26 > ${IMAGE_ROOTFS}/var/dpkg/available
27 # > ${STAGING_DIR}/var/dpkg/status
28
29 priority=1
30 for arch in ${PACKAGE_ARCHS}; do
31 if [ ! -d ${DEPLOY_DIR_DEB}/$arch ]; then
32 continue;
33 fi
34 cd ${DEPLOY_DIR_DEB}/$arch
35 # if [ -z "${DEPLOY_KEEP_PACKAGES}" ]; then
36 rm -f Packages.gz Packages Packages.bz2
37 # fi
38 apt-ftparchive packages . | bzip2 > Packages.bz2
39
40 echo "deb file:${DEPLOY_DIR_DEB}/$arch/ ./" >> ${STAGING_DIR}/etc/apt/sources.list
41 (echo "Package: *"
42 echo "Pin origin ${DEPLOY_DIR_DEB}/$arch"
43 echo "Pin-Priority: $((800 + $priority))") >> ${STAGING_DIR}/etc/apt/preferences
44 priority=$(expr $priority + 5)
45 done
46
47 export APT_CONFIG="${STAGING_DIR}/etc/apt/apt.conf"
48 export D=${IMAGE_ROOTFS}
49 export OFFLINE_ROOT=${IMAGE_ROOTFS}
50 export IPKG_OFFLINE_ROOT=${IMAGE_ROOTFS}
51
52 apt-get update
53
54 _flag () {
55 sed -i -e "/^Package: $2\$/{n; s/Status: install ok .*/Status: install ok $1/;}" ${IMAGE_ROOTFS}/var/dpkg/status
56 }
57 _getflag () {
58 cat ${IMAGE_ROOTFS}/var/dpkg/status | sed -n -e "/^Package: $2\$/{n; s/Status: install ok .*/$1/; p}"
59 }
60
61 if [ ! -z "${LINGUAS_INSTALL}" ]; then
62 apt-get install glibc-localedata-i18n
63 if [ $? -eq 1 ]; then
64 exit 1
65 fi
66 for i in ${LINGUAS_INSTALL}; do
67 apt-get install $i
68 if [ $? -eq 1 ]; then
69 exit 1
70 fi
71 done
72 fi
73
74 if [ ! -z "${PACKAGE_INSTALL}" ]; then
75 for i in ${PACKAGE_INSTALL}; do
76 apt-get install $i
77 if [ $? -eq 1 ]; then
78 exit 1
79 fi
80 find ${IMAGE_ROOTFS} -name \*.dpkg-new | for i in `cat`; do
81 mv $i `echo $i | sed -e's,\.dpkg-new$,,'`
82 done
83 done
84 fi
85
86 install -d ${IMAGE_ROOTFS}/${sysconfdir}
87 echo ${BUILDNAME} > ${IMAGE_ROOTFS}/${sysconfdir}/version
88
89 for i in ${IMAGE_ROOTFS}/var/dpkg/info/*.preinst; do
90 if [ -f $i ] && ! sh $i; then
91 _flag unpacked `basename $i .preinst`
92 fi
93 done
94
95 for i in ${IMAGE_ROOTFS}/var/dpkg/info/*.postinst; do
96 if [ -f $i ] && ! sh $i configure; then
97 _flag unpacked `basename $i .postinst`
98 fi
99 done
100
101 set -e
102
103 ${ROOTFS_POSTPROCESS_COMMAND}
104}
105
106# set '*' as the rootpassword so the images
107# can decide if they want it or not
108
109zap_root_password () {
110 sed 's%^root:[^:]*:%root:*:%' < ${IMAGE_ROOTFS}/etc/passwd >${IMAGE_ROOTFS}/etc/passwd.new
111 mv ${IMAGE_ROOTFS}/etc/passwd.new ${IMAGE_ROOTFS}/etc/passwd
112}
113
114create_etc_timestamp() {
115 date +%2m%2d%2H%2M%Y >${IMAGE_ROOTFS}/etc/timestamp
116}
117
118# Turn any symbolic /sbin/init link into a file
119remove_init_link () {
120 if [ -h ${IMAGE_ROOTFS}/sbin/init ]; then
121 LINKFILE=${IMAGE_ROOTFS}`readlink ${IMAGE_ROOTFS}/sbin/init`
122 rm ${IMAGE_ROOTFS}/sbin/init
123 cp $LINKFILE ${IMAGE_ROOTFS}/sbin/init
124 fi
125}
126
127# export the zap_root_password, create_etc_timestamp and remote_init_link
128EXPORT_FUNCTIONS zap_root_password create_etc_timestamp remove_init_link do_rootfs
129
130addtask rootfs before do_build after do_install