filesystem layout: configure via base-files instead of config-image
authorPatrick Ohly <patrick.ohly@intel.com>
Tue, 3 Feb 2015 14:39:23 +0000 (06:39 -0800)
committerPatrick Ohly <patrick.ohly@intel.com>
Tue, 3 Feb 2015 15:22:49 +0000 (07:22 -0800)
Changing file permissions via postinst is bad style, for example,
rpm cannot be used to determine why permissions were set this way.
The right way of solving this is via rpm manifest files.

The whole custom config-image can be replaced with a modified base-file
that has a manifest file and DIRFILES_${PN} set up accordingly.

In adddition, this commit also makes "Tizen on Yocto" more like Tizen:
- no more /var/volation - that dependend on a systemd unit from OE
  that was not even present in "Tizen on Yocto"
- /sbin /lib and /bin are now symlinks to /usr

The advantage of these symlinks are that recipes from Tizen which
contain hard-coded paths will work without having to be fixed. It is
uncertain whether there *are* any such recipes at the moment, but
there might be some or might be in the future.

The real advantage right now is that it makes it simpler to compare
file systems from Tizen and "Tizen on Yocto".

Change-Id: I2a1dbdc6de58cdfd245a3c42b6f7a0f8855cb97d

meta-tizen-adaptation/meta/files/tizen-fs-perms.txt [new file with mode: 0644]
meta-tizen-adaptation/meta/recipes-core/base-files/base-files/base-files.manifest [new file with mode: 0644]
meta-tizen-adaptation/meta/recipes-core/base-files/base-files_3.0.14.bbappend
meta-tizen-common-base/recipes-image/config-image/config-image.bb [deleted file]
meta-tizen-common-base/recipes-image/images/tizen-core-image-minimal.bb
meta-tizen-ivi/recipes-image/config-image/config-image.bbappend [deleted file]

diff --git a/meta-tizen-adaptation/meta/files/tizen-fs-perms.txt b/meta-tizen-adaptation/meta/files/tizen-fs-perms.txt
new file mode 100644 (file)
index 0000000..cb812a5
--- /dev/null
@@ -0,0 +1,66 @@
+# This file contains a list of files and directories with known permissions.
+# It is used by the packaging class to ensure that the permissions, owners and
+# group of listed files and directories are in sync across the system.
+#
+# The format of this file 
+#
+#<path>        <mode>  <uid>   <gid>   <walk>  <fmode> <fuid>  <fgid>
+#
+# or
+#
+#<path> link <target>
+#
+# <path>: directory path
+# <mode>: mode for directory
+# <uid>:  uid for directory
+# <gid>:  gid for directory
+# <walk>: recursively walk the directory?  true or false
+# <fmode>: if walking, new mode for files
+# <fuid>:  if walking, new uid for files
+# <fgid>:  if walking, new gid for files
+# <target>: turn the directory into a symlink point to target
+#
+# in mode, uid or gid, a "-" means don't change any existing values
+#
+# /usr/src             0755    root    root    false   -       -       -
+# /usr/share/man       0755    root    root    true    0644    root    root
+
+# Note: all standard config directories are automatically assigned "0755 root root false - - -"
+
+# Documentation should always be corrected
+${mandir}              0755    root    root    true    0644    root    root
+${infodir}             0755    root    root    true    0644    root    root
+${docdir}              0755    root    root    true    0644    root    root
+${datadir}/gtk-doc     0755    root    root    true    0644    root    root
+
+# Fixup locales
+${datadir}/locale      0755    root    root    true    0644    root    root
+
+# Cleanup headers
+${includedir}          0755    root    root    true    0644    root    root
+${oldincludedir}       0755    root    root    true    0644    root    root
+
+# Cleanup debug src
+/usr/src/debug         0755    root    root    true    -       root    root
+
+# Items from base-files (see .bbappend!). We are not using /var/volatile.
+# Links
+${localstatedir}/run   link    /run
+${localstatedir}/lock  link    /run/lock
+
+/home                          0755    root    root    false - - -
+/srv                           0755    root    root    false - - -
+${prefix}/src                  0755    root    root    false - - -
+${localstatedir}/local         0755    root    root    false - - -
+
+# Special permissions from base-files
+# Set 1777
+# We must also set smack labels, so rely on base-files.rpm owning these directories.
+#/tmp                          01777   root    root    false - - -
+#${localstatedir}/volatile/tmp 01777   root    root    false - - -
+
+# Set 755-lsb
+/srv                           0755    root    root    false - - -
+
+# Set 2775-lsb
+/var/mail                      02775   root    mail    false - - -
diff --git a/meta-tizen-adaptation/meta/recipes-core/base-files/base-files/base-files.manifest b/meta-tizen-adaptation/meta/recipes-core/base-files/base-files/base-files.manifest
new file mode 100644 (file)
index 0000000..1b2eb5c
--- /dev/null
@@ -0,0 +1,13 @@
+<!-- from https://review.tizen.org/gerrit/gitweb?p=platform/upstream/filesystem.git;a=blob;f=packaging/filesystem.manifest -->
+
+<manifest>
+  <request>
+     <domain name="_"/>
+  </request>
+  <assign>
+     <filesystem path="/etc" label="System::Shared" type="transmutable" />
+     <filesystem path="/var/log" label="System::Log" type="transmutable" />
+     <filesystem path="/tmp" label="*" />
+     <filesystem path="/var/tmp" label="*" />
+  </assign>
+</manifest>
index 1d916c6..e1df96e 100644 (file)
@@ -1,53 +1,34 @@
 FILESEXTRAPATHS_prepend := "${THISDIR}/base-files:"
 
-volatiles = "tmp"
-dirs1777 = "/tmp"
+SRC_URI += " \
+file://base-files.manifest \
+"
 
-dirs755 = "/bin /boot /dev ${sysconfdir} ${sysconfdir}/default \
-           ${sysconfdir}/skel /lib /mnt /proc ${ROOT_HOME} /run /sbin \
-           ${prefix} ${bindir} ${docdir} /usr/games ${includedir} \
-           ${libdir} ${sbindir} ${datadir} \
-           ${datadir}/common-licenses ${datadir}/dict ${infodir} \
-           ${mandir} ${datadir}/misc ${localstatedir} \
-           ${localstatedir}/backups ${localstatedir}/lib \
-           /sys ${localstatedir}/lib/misc ${localstatedir}/spool \
-           /media"
+# Don't use /var/volatile. Instead create regular directories for things that
+# used to be symlinks into it (tmp, log).
+volatiles_remove = "log tmp"
+dirs1777 += " ${localstatedir}/tmp ${localstatedir}/log"
+dirs1777_remove = "${localstatedir}/volatile/tmp"
+dirs755_remove = "${localstatedir}/volatile ${localstatedir}/volatile/log"
+# This gets symlinked to in the .bb but isn't created?
+dirs755 += "/run/lock"
 
-do_install () {
-       for d in ${dirs755}; do
-               install -m 0755 -d ${D}$d
-       done
-       for d in ${dirs1777}; do
-               install -m 1777 -d ${D}$d
-       done
-       for d in ${dirs2775}; do
-               install -m 2755 -d ${D}$d
-       done
-       for d in ${volatiles}; do
-               ln -sf volatile/$d ${D}${localstatedir}/$d
-       done
-       ln -snf ../run ${D}${localstatedir}/run
-       ln -snf ../run/lock ${D}${localstatedir}/lock
+merged_dirs = "/bin /lib /sbin"
+dirs755_remove = "/bin /lib /sbin"
+do_install_prepend () {
+        for d in ${merged_dirs}; do
+                ln -sf usr$d ${D}$d
+        done
+}
 
-       ${BASEFILESISSUEINSTALL}
+# Empty directories must be listed explicitly to be packaged.
+# This is relevant for our directories with special permissions (see manifest).
+DIRFILES_${PN} += "/etc /var/log /var/tmp /tmp"
 
-       rotation=`cat ${WORKDIR}/rotation`
-       if [ "$rotation" != "0" ]; then
-               install -m 0644 ${WORKDIR}/rotation ${D}${sysconfdir}/rotation
-       fi
+# The ${merged_dirs} symlinks to directories get ignored by the
+# current walk_files() in OE-core's package_rpm.bbclass. A patch
+# is needed to support that.
 
-       install -m 0644 ${WORKDIR}/fstab ${D}${sysconfdir}/fstab
-       install -m 0644 ${WORKDIR}/filesystems ${D}${sysconfdir}/filesystems
-       install -m 0644 ${WORKDIR}/usbd ${D}${sysconfdir}/default/usbd
-       install -m 0644 ${WORKDIR}/profile ${D}${sysconfdir}/profile
-       sed -i 's#ROOTHOME#${ROOT_HOME}#' ${D}${sysconfdir}/profile
-       install -m 0644 ${WORKDIR}/shells ${D}${sysconfdir}/shells
-       install -m 0755 ${WORKDIR}/share/dot.profile ${D}${sysconfdir}/skel/.profile
-       install -m 0755 ${WORKDIR}/share/dot.bashrc ${D}${sysconfdir}/skel/.bashrc
-       install -m 0644 ${WORKDIR}/inputrc ${D}${sysconfdir}/inputrc
-       install -m 0644 ${WORKDIR}/nsswitch.conf ${D}${sysconfdir}/nsswitch.conf
-       install -m 0644 ${WORKDIR}/host.conf ${D}${sysconfdir}/host.conf
-       install -m 0644 ${WORKDIR}/motd ${D}${sysconfdir}/motd
-
-       ln -sf /proc/mounts ${D}${sysconfdir}/mtab
-}
\ No newline at end of file
+# We don't use the "/var/volatile" support from OE, so provide
+# a modified standard file system permission file without those.
+FILESYSTEM_PERMS_TABLES = "files/tizen-fs-perms.txt"
diff --git a/meta-tizen-common-base/recipes-image/config-image/config-image.bb b/meta-tizen-common-base/recipes-image/config-image/config-image.bb
deleted file mode 100644 (file)
index 5056845..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-SUMMARY = "Config image"
-DESCRIPTION = "This Config image"
-SECTION = "config"
-PR = "r1"
-LICENSE = "MIT"
-LIC_FILES_CHKSUM ??= "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
-
-RDEPENDS_${PN} += "systemd"
-
-basesymlinks = ""
-# "/bin /sbin /lib"
-
-do_install() {
-  mkdir -p ${D}${sysconfdir}
-  echo "Tizen on Yocto" > ${D}${sysconfdir}/tizen
-  
-  touch ${D}${sysconfdir}/environment
-  chmod 0644 ${D}${sysconfdir}/environment
-
-  mkdir -p ${D}${sysconfdir}/profile.d
-cat >${D}${sysconfdir}/profile.d/bash_prompt_custom.sh <<'EOF'
-    # set a fancy prompt (overwrite the one in /etc/profile)
-    default="\[\e[0m\]"
-    usercol='\[\e[1;34m\]' # blue
-    hostcol='\[\e[1;32m\]' # green
-    pathcol='\[\e[1;33m\]' # yellow
-    gitcol='\[\e[1;31m\]' # light red
-    termcmd=''
-    _p="$";
-
-    if [ "`id -u`" -eq 0 ]; then
-        usercol='\[\e[1;31m\]'
-        _p="#"
-    fi
-
-    PS1="${usercol}\u${default}@${hostcol}\h${default}:${pathcol}\w${default}${gitcol}${default}${_p} ${termcmd}"
-
-    alias ll="ls -lZ"
-    alias lr="ls -ltrZ"
-    alias la="ls -alZ"
-
-EOF
-  
-}
-
-pkg_postinst_${PN} () {
-  # Same symlinks as in Tizen. tizen.conf sets base_ dirs to /usr/<something>,
-  # so all files should already go into that. If they don't, install
-  # failures will tell us which recipe did not honor path configurations
-  # (and potentially other system settings!).
-  for i in ${basesymlinks}; do
-     ln -s usr$i ${D}$i
-  done
-
-  # This corresponds to:
-  # https://review.tizen.org/gerrit/gitweb?p=platform/upstream/filesystem.git;a=blob;f=packaging/filesystem.manifest
-
-  mkdir -p $D${sysconfdir}
-  chsmack -t $D${sysconfdir}
-  chsmack -a 'System::Shared' $D${sysconfdir}
-
-  mkdir -p $D${localstatedir}/log
-  chsmack -t $D${localstatedir}/log
-  chsmack -a 'System::Log'  $D${localstatedir}/log
-
-  mkdir -p $D/tmp
-  chsmack -a '*' $D/tmp
-
-  mkdir -p $D/${localstatedir}/tmp
-  chsmack -a '*' $D/${localstatedir}/tmp
-
-  rm -rf $D/${localstatedir}/run
-  ln -s ../run $D/${localstatedir}/run
-
-  touch $D${localstatedir}/log/lastlog
-  touch $D${localstatedir}/log/faillog
-  touch $D${localstatedir}/log/wtmp
-  touch $D${localstatedir}/log/btmp
-  
-  mkdir -p $D${sysconfdir}/profile.d
-  
-  #if [ "x$D" != "x" ]; then  
-  #  cp -fra $D${localstatedir}/log $D${localstatedir}/volatile
-  #  rm -fr $D${localstatedir}/log
-  #  ln -s volatile/log  $D${localstatedir}/log
-  #  
- #fi
-}
-
-FILES_${PN} = "${sysconfdir}/tizen \
-               ${sysconfdir}/environment \
-               ${sysconfdir}/profile.d/bash_prompt_custom.sh \
-               ${base_sbindir}/init \
-               ${basesymlinks} \
-               "
index 5ae7528..e60609b 100644 (file)
@@ -8,6 +8,11 @@ inherit core-image distro_features_check
 
 REQUIRED_DISTRO_FEATURES = "wayland pam"
 
+# Because of our symlink hack for /lib /sbin /bin,
+# this package must be installed first and not just
+# randomly based of some dependency.
+IMAGE_INSTALL_prepend = "base-files "
+
 CORE_IMAGE_BASE_INSTALL += "weston weston-init clutter-1.0-examples"
 
 DESCRIPTION = "A weston image with Tizen common."
@@ -40,7 +45,6 @@ CORE_IMAGE_BASE_INSTALL += "pam"
 CORE_IMAGE_BASE_INSTALL += "user-session-units"
 CORE_IMAGE_BASE_INSTALL += "default-ac-domains"
 CORE_IMAGE_BASE_INSTALL += "rpm-security-plugin"
-CORE_IMAGE_BASE_INSTALL += "config-image"
 CORE_IMAGE_BASE_INSTALL += "kernel-modules"
 CORE_IMAGE_BASE_INSTALL += "less"
 CORE_IMAGE_BASE_INSTALL += "bash"
diff --git a/meta-tizen-ivi/recipes-image/config-image/config-image.bbappend b/meta-tizen-ivi/recipes-image/config-image/config-image.bbappend
deleted file mode 100644 (file)
index f61476e..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-# Not used in Tizen IVI 3.0.
-RDEPENDS_${PN}_remove = "wrt-widgets"