diff options
Diffstat (limited to 'meta-edison-distro/recipes-core')
51 files changed, 2136 insertions, 0 deletions
diff --git a/meta-edison-distro/recipes-core/base-files/base-files/factory.mount b/meta-edison-distro/recipes-core/base-files/base-files/factory.mount new file mode 100644 index 0000000..2619c96 --- /dev/null +++ b/meta-edison-distro/recipes-core/base-files/base-files/factory.mount @@ -0,0 +1,12 @@ +[Unit] +Description=Mount for factory + +[Install] +WantedBy=default.target + +[Mount] +What=/dev/disk/by-partlabel/factory +Where=/factory +Options=ro,noauto,x-systemd.automount,nosuid,nodev,noatime,discard,barrier=1,data=ordered,noauto_da_alloc +Type=ext4 +TimeoutSec=3 diff --git a/meta-edison-distro/recipes-core/base-files/base-files/fstab b/meta-edison-distro/recipes-core/base-files/base-files/fstab new file mode 100644 index 0000000..55edeef --- /dev/null +++ b/meta-edison-distro/recipes-core/base-files/base-files/fstab @@ -0,0 +1,9 @@ +rootfs / auto nodev,noatime,discard,barrier=1,data=ordered,noauto_da_alloc 1 1 +proc /proc proc defaults 0 0 +devpts /dev/pts devpts mode=0620,gid=5 0 0 +usbdevfs /proc/bus/usb usbdevfs auto 0 0 +tmpfs /run tmpfs mode=0755,nodev,nosuid,strictatime 0 0 +tmpfs /var/volatile tmpfs defaults 0 0 + +/dev/disk/by-partlabel/boot /boot auto noauto,x-systemd.automount,nosuid,nodev,noatime,discard 1 1 +/dev/disk/by-partlabel/home /home auto noauto,x-systemd.automount,nosuid,nodev,noatime,discard,barrier=1,data=ordered,noauto_da_alloc 1 1 diff --git a/meta-edison-distro/recipes-core/base-files/base-files/media-sdcard.automount b/meta-edison-distro/recipes-core/base-files/base-files/media-sdcard.automount new file mode 100644 index 0000000..a577591 --- /dev/null +++ b/meta-edison-distro/recipes-core/base-files/base-files/media-sdcard.automount @@ -0,0 +1,11 @@ +[Unit] +Description=Automount for SDCard +ConditionPathExists=/dev/mmcblk1p1 +RefuseManualStart=true +RefuseManualStop=true + +[Automount] +Where=/media/sdcard + +[Install] +WantedBy=local-fs.target diff --git a/meta-edison-distro/recipes-core/base-files/base-files/media-sdcard.mount b/meta-edison-distro/recipes-core/base-files/base-files/media-sdcard.mount new file mode 100644 index 0000000..a9d310b --- /dev/null +++ b/meta-edison-distro/recipes-core/base-files/base-files/media-sdcard.mount @@ -0,0 +1,9 @@ +[Unit] +Description=Mount for SDCard +BindsTo=dev-mmcblk1p1.device +Conflicts=media-sdcard.automount + +[Mount] +What=/dev/mmcblk1p1 +Where=/media/sdcard +TimeoutSec=3 diff --git a/meta-edison-distro/recipes-core/base-files/base-files/share/dot.profile b/meta-edison-distro/recipes-core/base-files/base-files/share/dot.profile new file mode 100644 index 0000000..4f1d2a0 --- /dev/null +++ b/meta-edison-distro/recipes-core/base-files/base-files/share/dot.profile @@ -0,0 +1,9 @@ +# ~/.profile: executed by Bourne-compatible login shells. + +if [ -f ~/.bashrc ]; then + . ~/.bashrc +fi + +# path set by /etc/profile +# export PATH + diff --git a/meta-edison-distro/recipes-core/base-files/base-files_3.0.14.bbappend b/meta-edison-distro/recipes-core/base-files/base-files_3.0.14.bbappend new file mode 100644 index 0000000..dd8d96a --- /dev/null +++ b/meta-edison-distro/recipes-core/base-files/base-files_3.0.14.bbappend @@ -0,0 +1,33 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/base-files:" +SRC_URI += "file://fstab" +SRC_URI += "file://media-sdcard.mount" +SRC_URI += "file://media-sdcard.automount" +SRC_URI += "file://factory.mount" +SRC_URI += "file://share/dot.profile" + +# override default volatile to suppress var/log link creation +volatiles = "tmp" + +do_install_append() { + install -m 0644 ${WORKDIR}/fstab ${D}${sysconfdir}/fstab + install -m 0755 ${WORKDIR}/share/dot.profile ${D}${sysconfdir}/skel/.profile + + # enable mount of the SDCard in /media/sdcard when inserted + install -d ${D}${systemd_unitdir}/system + install -c -m 0644 ${WORKDIR}/media-sdcard.mount ${D}${systemd_unitdir}/system + install -c -m 0644 ${WORKDIR}/media-sdcard.automount ${D}${systemd_unitdir}/system + install -c -m 0644 ${WORKDIR}/factory.mount ${D}${systemd_unitdir}/system + # Enable the service + install -d ${D}${sysconfdir}/systemd/system/local-fs.target.wants + ln -sf ${systemd_unitdir}/system/media-sdcard.automount \ + ${D}${sysconfdir}/systemd/system/local-fs.target.wants/media-sdcard.automount + install -d ${D}${sysconfdir}/systemd/system/default.target.wants + ln -sf ${systemd_unitdir}/system/factory.mount \ + ${D}${sysconfdir}/systemd/system/default.target.wants/factory.mount + +} + +FILES_${PN} += "${base_libdir}/systemd/system/*.mount" +FILES_${PN} += "${base_libdir}/systemd/system/*.automount" +FILES_${PN} += "${sysconfdir}/systemd/system/default.target.wants/*.mount" +FILES_${PN} += "${sysconfdir}/systemd/system/local-fs.target.wants/*.automount" diff --git a/meta-edison-distro/recipes-core/busybox/busybox_1.22.1.bbappend b/meta-edison-distro/recipes-core/busybox/busybox_1.22.1.bbappend new file mode 100644 index 0000000..faf18af --- /dev/null +++ b/meta-edison-distro/recipes-core/busybox/busybox_1.22.1.bbappend @@ -0,0 +1,5 @@ +# to get brctl and log configuration settings +FILESEXTRAPATHS_prepend := "${THISDIR}/files/:" + +SRC_URI += "file://brctl-utilities.cfg \ + file://busybox-log.cfg " diff --git a/meta-edison-distro/recipes-core/busybox/files/brctl-utilities.cfg b/meta-edison-distro/recipes-core/busybox/files/brctl-utilities.cfg new file mode 100644 index 0000000..53d4ead --- /dev/null +++ b/meta-edison-distro/recipes-core/busybox/files/brctl-utilities.cfg @@ -0,0 +1,2 @@ +CONFIG_BRCTL=y +CONFIG_FEATURE_BRCTL_SHOW=y diff --git a/meta-edison-distro/recipes-core/busybox/files/busybox-log.cfg b/meta-edison-distro/recipes-core/busybox/files/busybox-log.cfg new file mode 100644 index 0000000..7b7408f --- /dev/null +++ b/meta-edison-distro/recipes-core/busybox/files/busybox-log.cfg @@ -0,0 +1,3 @@ +CONFIG_KLOGD=n +CONFIG_SYSLOGD=n + diff --git a/meta-edison-distro/recipes-core/first-install/files/first-install.service b/meta-edison-distro/recipes-core/first-install/files/first-install.service new file mode 100644 index 0000000..3ebb9d7 --- /dev/null +++ b/meta-edison-distro/recipes-core/first-install/files/first-install.service @@ -0,0 +1,9 @@ +[Unit] +Description=First install service +OnFailure=reboot.target +Requires=dev-disk-by\x2dpartlabel-home.device dev-disk-by\x2dpartlabel-update.device +After=dev-disk-by\x2dpartlabel-home.device dev-disk-by\x2dpartlabel-update.device +[Service] +ExecStart=@BASE_BINDIR@/sh -c "shell='sh'; if [ -f /bin/bash ]; then shell='bash'; fi; @BASE_BINDIR@/$shell @BASE_SBINDIR@/first-install.sh systemd-service" +StandardOutput=journal+console + diff --git a/meta-edison-distro/recipes-core/first-install/files/first-install.sh b/meta-edison-distro/recipes-core/first-install/files/first-install.sh new file mode 100644 index 0000000..1b29245 --- /dev/null +++ b/meta-edison-distro/recipes-core/first-install/files/first-install.sh @@ -0,0 +1,185 @@ +#!/bin/bash +# first install script to do post flash install + +# global variable set to 1 if output is systemd journal +fi_journal_out=0 + +export PATH="$PATH:/usr/sbin/" + +# handle argument, if first-install is called from systemd service +# arg1 is "systemd-service" +if [ "$1" == "systemd-service" ]; then fi_journal_out=1; fi; + +#echo function to output to journal system or in colored terminal +#arg $1 message +#arg $2 log level +fi_echo () { + lg_lvl=${2:-"log"} + msg_prefix="" + msg_suffix="" + case "$lg_lvl" in + log) if [ $fi_journal_out -eq 1 ]; then msg_prefix="<5>"; else msg_prefix="\033[1m"; msg_suffix="\033[0m"; fi;; + err) if [ $fi_journal_out -eq 1 ]; then msg_prefix="<1>"; else msg_prefix="\033[31;40m\033[1m"; msg_suffix="\033[0m"; fi;; + esac + printf "${msg_prefix}${1}${msg_suffix}\n" +} + +# set_retry_count to failure file +# arg $1 new retry count +set_retry_count () { + fw_setenv first_install_retry $1 +} + +# get_retry_count from failure from bootloader +get_retry_count () { + retry_count=$(fw_printenv first_install_retry | tr -d "first_install_retry=") + [ -z $retry_count ] && { set_retry_count 0; retry_count=0;} + return $retry_count +} + +# exit first_install by rebooting and handling the failure by setting +# the firmware target according to failure or success +# on failure increment fail count and reboot +# on success reboot in multi-user target +# arg $1 exit code +exit_first_install () { + if [ $1 -eq 0 ]; then + # reset failure count + set_retry_count 0 + # update firmware target + # next reboot will be on multi-user target + fw_setenv bootargs_target multi-user + fi + # dump journal to log file + journalctl -u first-install -o short-iso >> /first-install.log + systemctl daemon-reload + systemctl stop home.mount + systemctl default +} + +# continue normal flow or exit on error code +# arg $1 : return code to check +# arg $2 : string resuming the action +fi_assert () { + if [ $1 -ne 0 ]; then + fi_echo "${2} : Failed ret($1)" err; + exit_first_install $1; + else + fi_echo "${2} : Success"; + fi +} + +factory_partition () { + mkdir -p /factory + mount /dev/disk/by-partlabel/factory /factory + # test can fail if done during manufacturing + if [ $? -ne 0 ]; + then + mkfs.ext4 /dev/disk/by-partlabel/factory + mount /dev/disk/by-partlabel/factory /factory + echo "00:11:22:33:55:66" > /factory/bluetooth_address + echo "VSPPYWWDXXXXXNNN" > /factory/serial_number + fi +} + +# generate sshd keys +sshd_init () { + rm -rf /etc/ssh/*key* + systemctl start sshdgenkeys +} + + +# Substitute the SSID and passphrase in the file /etc/hostapd/hostapd.conf +# The SSID is built from the hostname and a serial number to have a +# unique SSID in case of multiple Edison boards having their WLAN AP active. +setup_ap_ssid_and_passphrase () { + # factory_serial is 16 bytes long + if [ -f /sys/class/net/wlan0/address ]; + then + ifconfig wlan0 up + wlan0_addr=$(cat /sys/class/net/wlan0/address | tr '[:lower:]' '[:upper:]') + ssid="EDISON-${wlan0_addr:12:2}-${wlan0_addr:15:2}" + + # Substitute the SSID + sed -i -e 's/^ssid=.*/ssid='${ssid}'/g' /etc/hostapd/hostapd.conf + fi + + if [ -f /factory/serial_number ] ; + then + factory_serial=$(head -n1 /factory/serial_number | tr '[:lower:]' '[:upper:]') + passphrase="${factory_serial}" + + # Substitute the passphrase + sed -i -e 's/^wpa_passphrase=.*/wpa_passphrase='${passphrase}'/g' /etc/hostapd/hostapd.conf + fi + + sync +} + + +# script main part + +# print to journal the current retry count +get_retry_count +retry_count=$? +set_retry_count $((${retry_count} + 1)) +fi_echo "Starting First Install (try: ${retry_count})" + +# format partition home to ext4 +mkfs.ext4 -m0 /dev/disk/by-partlabel/home +fi_assert $? "Formatting home partition" + +# backup initial /home/root directory +mkdir /tmp/oldhome +cp -R /home/* /tmp/oldhome/ +fi_assert $? "Backup home/root contents of rootfs" + +# mount home partition on /home +mount /dev/disk/by-partlabel/home /home +fi_assert $? "Mount /home partition" + +# copy back contents to /home and cleanup +mv /tmp/oldhome/* /home/ +rm -rf /tmp/oldhome +fi_assert $? "Restore home/root contents on new /home partition" + +# create a fat32 primary partition on all available space +echo -ne "n\np\n1\n\n\nt\nb\np\nw\n" | fdisk /dev/disk/by-partlabel/update + +# silent error code for now because fdisk failed to reread MBR correctly +# MBR is correct but fdisk understand it as the main system MBR, which is +# not the case. +fi_assert 0 "Formatting update partition Step 1" + +# create a loop device on update disk +losetup -o 8192 /dev/loop0 /dev/disk/by-partlabel/update +fi_assert $? "Formatting update partition Step 2" + +# format update partition +mkfs.vfat /dev/loop0 -n "Edison" -F 32 +fi_assert $? "Formatting update partition Step 3" + +# remove loop device on update disk +losetup -d /dev/loop0 +fi_assert $? "Formatting update partition Step 4 final" + +# handle factory partition +factory_partition + +# ssh +sshd_init +fi_assert $? "Generating sshd keys" + +# update entry in /etc/fstab to enable auto mount +sed -i 's/#\/dev\/disk\/by-partlabel/\/dev\/disk\/by-partlabel/g' /etc/fstab +fi_assert $? "Update file system table /etc/fstab" + +# Setup Access Point SSID and passphrase +setup_ap_ssid_and_passphrase +fi_assert $? "Generating Wifi Access Point SSID and passphrase" + +fi_echo "First install success" + +# end main part +exit_first_install 0 + diff --git a/meta-edison-distro/recipes-core/first-install/files/first-install.target b/meta-edison-distro/recipes-core/first-install/files/first-install.target new file mode 100644 index 0000000..e005f55 --- /dev/null +++ b/meta-edison-distro/recipes-core/first-install/files/first-install.target @@ -0,0 +1,7 @@ +[Unit] +Description=First Install target +Requires=sysinit.target +Conflicts=shutdown.target systemd-readahead-collect.service systemd-readahead-replay.service home.automount factory.automount +After=sysinit.target +Before=shutdown.target +AllowIsolate=yes diff --git a/meta-edison-distro/recipes-core/first-install/first-install.bb b/meta-edison-distro/recipes-core/first-install/first-install.bb new file mode 100644 index 0000000..c04b930 --- /dev/null +++ b/meta-edison-distro/recipes-core/first-install/first-install.bb @@ -0,0 +1,40 @@ +DESCRIPTION = "First install systemd target" +LICENSE = "GPLv2+" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6" + +SRC_URI = "file://first-install.service \ + file://first-install.target \ + file://first-install.sh" + +SYSTEMD_SERVICE_${PN} = "first-install.service" + +RDEPENDS_${PN} = "systemd" + +do_install() { + install -d ${D}/sbin + install -c -m 0744 ${WORKDIR}/first-install.sh ${D}/sbin + install -d ${D}${systemd_unitdir}/system + install -d ${D}${sysconfdir}/systemd/system/first-install.target.wants + install -c -m 0644 ${WORKDIR}/first-install.target ${D}${systemd_unitdir}/system + install -c -m 0644 ${WORKDIR}/first-install.service ${D}${systemd_unitdir}/system + sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \ + -e 's,@BASE_SBINDIR@,${base_sbindir},g' \ + -e 's,@SBINDIR@,${sbindir},g' \ + -e 's,@BINDIR@,${bindir},g' \ + ${D}${systemd_unitdir}/system/first-install.service + + # enable services + ln -sf ${systemd_unitdir}/system/first-install.service \ + ${D}${sysconfdir}/systemd/system/first-install.target.wants/first-install.service +} + +FILES_${PN} = "${base_libdir}/systemd/system/*.service \ + ${base_libdir}/systemd/system/first-install.target \ + ${sysconfdir} \ + /sbin/first-install.sh" + +# As this package is tied to systemd, only build it when we're also building systemd. +python () { + if not oe.utils.contains ('DISTRO_FEATURES', 'systemd', True, False, d): + raise bb.parse.SkipPackage("'systemd' not in DISTRO_FEATURES") +} diff --git a/meta-edison-distro/recipes-core/images/edison-image.bb b/meta-edison-distro/recipes-core/images/edison-image.bb new file mode 100644 index 0000000..f106657 --- /dev/null +++ b/meta-edison-distro/recipes-core/images/edison-image.bb @@ -0,0 +1,130 @@ +DESCRIPTION = "A fully functional image to run EDISON" +LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \ + file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" +LICENSE = "MIT" +IMAGE_INSTALL = "packagegroup-core-boot ${ROOTFS_PKGMANAGE_BOOTSTRAP} ${CORE_IMAGE_EXTRA_INSTALL}" +IMAGE_INSTALL += "openssh-sftp-server" + +IMAGE_LINGUAS = " " + +INITRD = "" +INITRD_IMAGE = "" + +# Do not use legacy nor EFI BIOS +PCBIOS = "0" +# Do not support bootable USB stick +NOISO = "1" +ROOTFS = "" + +# This is useless stuff, but necessary for building because +# inheriting bootimg also brings syslinux in.. +AUTO_SYSLINUXCFG = "1" +SYSLINUX_ROOT = "" +SYSLINUX_TIMEOUT ?= "10" +SYSLINUX_LABELS ?= "boot install" +LABELS_append = " ${SYSLINUX_LABELS} " + + +# Specify rootfs image type +IMAGE_FSTYPES = "ext4" + +inherit core-image + +# This has to be set after including core-image otherwise it's overriden with "1" +# and this cancel creation of the boot hddimg +NOHDD = "0" + +inherit bootimg +do_bootimg[depends] += "${PN}:do_rootfs" + +IMAGE_ROOTFS_SIZE = "524288" + +IMAGE_FEATURES += "package-management ssh-server-openssh" +# Allow passwordless root login and postinst logging +IMAGE_FEATURES += "debug-tweaks" + +IMAGE_INSTALL += "connman" +IMAGE_INSTALL += "connman-client" +IMAGE_INSTALL += "connman-tools" +IMAGE_INSTALL += "wireless-tools" +IMAGE_INSTALL += "wpa-supplicant" +IMAGE_INSTALL += "hostapd-daemon" +IMAGE_INSTALL += "bluez5-dev" +IMAGE_INSTALL += "bluez5-obex" +IMAGE_INSTALL += "kernel-modules" +IMAGE_INSTALL += "ethtool" +IMAGE_INSTALL += "iptables" +IMAGE_INSTALL += "libstdc++" +IMAGE_INSTALL += "u-boot" +IMAGE_INSTALL += "u-boot-fw-utils" +IMAGE_INSTALL += "file" +IMAGE_INSTALL += "pciutils" +IMAGE_INSTALL += "usbutils" +IMAGE_INSTALL += "ldd" +IMAGE_INSTALL += "i2c-tools" +IMAGE_INSTALL += "watchdog-sample" +IMAGE_INSTALL += "pwr-button-handler" +IMAGE_INSTALL += "blink-led" +IMAGE_INSTALL += "first-install" +IMAGE_INSTALL += "resize-rootfs" +IMAGE_INSTALL += "systemd-analyze" +IMAGE_INSTALL += "wget" +IMAGE_INSTALL += "ota-update" + +# Allows to enable OpenMP feature +IMAGE_INSTALL += "libgomp" + +# Add audio firmware +IMAGE_INSTALL += "sst-fw-bin" + +# ALSA lib and utilities +IMAGE_INSTALL += "alsa-lib" +IMAGE_INSTALL += "alsa-utils-alsamixer alsa-utils-alsactl alsa-utils-aplay alsa-utils-amixer" + +# Python and some basic modules +IMAGE_INSTALL += "python" +IMAGE_INSTALL += "python-dbus python-smartpm python-pygobject python-argparse" +IMAGE_INSTALL += "python-distutils python-pkgutil python-audio python-image python-imaging python-email python-netserver python-xmlrpc python-ctypes python-html python-json python-compile python-misc python-numbers python-unittest python-pydoc" + +# Wifi firmware +IMAGE_INSTALL += "bcm43340-fw" +# Bluetooth Firmware patch for 43340 and its patch utility +IMAGE_INSTALL += "bcm43340-bt" +# service daemon that listens to rfkill events and trigger FW patch download +IMAGE_INSTALL += "bluetooth-rfkill-event" +# Wifi driver built as a kernel module +IMAGE_INSTALL += "bcm43340-mod" + +# Provides strace and gdb +IMAGE_FEATURES += "tools-debug" +IMAGE_INSTALL += "crashlog" + +# Clean corrupted journald entries +IMAGE_INSTALL += "cleanjournal" + +# Adds various other tools +IMAGE_INSTALL += "tcpdump" +IMAGE_INSTALL += "net-tools" +IMAGE_INSTALL += "lsof" +IMAGE_INSTALL += "iperf" + +# Add pulseaudio +IMAGE_INSTALL += "pulseaudio-server libpulsecore libpulsecommon libpulse libpulse-simple pulseaudio-misc pulseaudio-service" + +# Add Mplayer +IMAGE_INSTALL += "mplayer" + +# Those are necessary to manually create partitions and file systems on the eMMC +IMAGE_INSTALL += "parted" +IMAGE_INSTALL += "e2fsprogs-e2fsck e2fsprogs-mke2fs e2fsprogs-tune2fs e2fsprogs-badblocks libcomerr libss libe2p libext2fs dosfstools" + +# Time related +IMAGE_INSTALL += "tzdata" + +# SWIG +IMAGE_INSTALL += "swig" + +# INTEL MCU FW +IMAGE_INSTALL += "mcu-fw-load" +IMAGE_INSTALL += "mcu-fw-bin" + diff --git a/meta-edison-distro/recipes-core/ota-update/files/ota-update.service b/meta-edison-distro/recipes-core/ota-update/files/ota-update.service new file mode 100644 index 0000000..bc43401 --- /dev/null +++ b/meta-edison-distro/recipes-core/ota-update/files/ota-update.service @@ -0,0 +1,9 @@ +[Unit] +Description=OTA update service +OnFailure=reboot.target +Requires=dev-disk-by\x2dpartlabel-home.device dev-disk-by\x2dpartlabel-update.device +After=dev-disk-by\x2dpartlabel-home.device dev-disk-by\x2dpartlabel-update.device +[Service] +ExecStart=@BASE_BINDIR@/sh -c "shell='sh'; if [ -f /bin/bash ]; then shell='bash'; fi; @BASE_BINDIR@/$shell @BASE_SBINDIR@/ota-update.sh systemd-service" +StandardOutput=journal+console + diff --git a/meta-edison-distro/recipes-core/ota-update/files/ota-update.sh b/meta-edison-distro/recipes-core/ota-update/files/ota-update.sh new file mode 100644 index 0000000..cfbe8ea --- /dev/null +++ b/meta-edison-distro/recipes-core/ota-update/files/ota-update.sh @@ -0,0 +1,149 @@ +#!/bin/bash +# FIXME: function definition shall be moved to a common script + +# global variable set to 1 if output is systemd journal +fi_journal_out=0 + +export PATH="$PATH:/usr/sbin/" + +# handle argument, if ota-update is called from systemd service +# arg1 is "systemd-service" +if [ "$1" == "systemd-service" ]; then fi_journal_out=1; fi; + +#echo function to output to journal system or in colored terminal +#arg $1 message +#arg $2 log level +fi_echo () { + lg_lvl=${2:-"log"} + msg_prefix="" + msg_suffix="" + case "$lg_lvl" in + log) if [ $fi_journal_out -eq 1 ]; then msg_prefix="<5>"; else msg_prefix="\033[1m"; msg_suffix="\033[0m"; fi;; + err) if [ $fi_journal_out -eq 1 ]; then msg_prefix="<1>"; else msg_prefix="\033[31;40m\033[1m"; msg_suffix="\033[0m"; fi;; + esac + printf "${msg_prefix}${1}${msg_suffix}\n" +} + +# set_retry_count to failure file +# arg $1 new retry count +set_retry_count () { + fw_setenv ota_update_retry $1 +} + +# get_retry_count from failure from bootloader +get_retry_count () { + retry_count=$(fw_printenv ota_update_retry | tr -d "ota_update_retry=") + [ -z $retry_count ] && { set_retry_count 0; retry_count=0;} + return $retry_count +} + +# exit ota_update by rebooting and handling the failure by setting +# the firmware target according to failure or success +# on failure increment fail count and reboot +# on success reboot in multi-user target +# arg $1 exit code +exit_ota_update () { + if [ $1 -eq 0 ]; then + # reset failure count + set_retry_count 0 + # update firmware target + # next reboot will be on multi-user target + fw_setenv bootargs_target multi-user + fi + + fi_echo "Rebooting...." + # dump journal to log file + journalctl -u ota-update -o short-iso >> /ota-update.log + systemctl daemon-reload + systemctl stop home.mount + systemctl default +} + +# continue normal flow or exit on error code +# arg $1 : return code to check +# arg $2 : string resuming the action +fi_assert () { + if [ $1 -ne 0 ]; then + fi_echo "${2} : Failed ret($1)" err; + exit_ota_update $1; + else + fi_echo "${2} : Success"; + fi +} + +factory_partition () { + mkdir -p /factory + mount /dev/disk/by-partlabel/factory /factory + # test can fail if done during manufacturing + if [ $? -ne 0 ]; + then + mkfs.ext4 /dev/disk/by-partlabel/factory + mount /dev/disk/by-partlabel/factory /factory + echo "00:11:22:33:55:66" > /factory/bluetooth_address + echo "VSPPYWWDXXXXXNNN" > /factory/serial_number + fi +} + +# generate sshd keys +sshd_init () { + rm -rf /etc/ssh/*key* + systemctl start sshdgenkeys +} + + +# Substitute the SSID and passphrase in the file /etc/hostapd/hostapd.conf +# The SSID is built from the hostname and a serial number to have a +# unique SSID in case of multiple Edison boards having their WLAN AP active. +setup_ap_ssid_and_passphrase () { + # factory_serial is 16 bytes long + if [ -f /sys/class/net/wlan0/address ]; + then + ifconfig wlan0 up + wlan0_addr=$(cat /sys/class/net/wlan0/address | tr '[:lower:]' '[:upper:]') + ssid="EDISON-${wlan0_addr:12:2}-${wlan0_addr:15:2}" + + # Substitute the SSID + sed -i -e 's/^ssid=.*/ssid='${ssid}'/g' /etc/hostapd/hostapd.conf + fi + + if [ -f /factory/serial_number ] ; + then + factory_serial=$(head -n1 /factory/serial_number | tr '[:lower:]' '[:upper:]') + passphrase="${factory_serial}" + + # Substitute the passphrase + sed -i -e 's/^wpa_passphrase=.*/wpa_passphrase='${passphrase}'/g' /etc/hostapd/hostapd.conf + fi + + sync +} + + +# script main part + +# print to journal the current retry count +get_retry_count +retry_count=$? +set_retry_count $((${retry_count} + 1)) +fi_echo "Starting OTA update (try: ${retry_count})" + +# handle factory partition +factory_partition + +# ssh +sshd_init +fi_assert $? "Generating sshd keys" + +# update entry in /etc/fstab to enable auto mount +sed -i 's/#\/dev\/disk\/by-partlabel/\/dev\/disk\/by-partlabel/g' /etc/fstab +fi_assert $? "Update file system table /etc/fstab" + +# Setup Access Point SSID and passphrase +setup_ap_ssid_and_passphrase +fi_assert $? "Generating Wifi Access Point SSID and passphrase" + +fi_echo "OTA update success" + +# end main part +exit_ota_update 0 + diff --git a/meta-edison-distro/recipes-core/ota-update/files/ota-update.target b/meta-edison-distro/recipes-core/ota-update/files/ota-update.target new file mode 100644 index 0000000..6b23e39 --- /dev/null +++ b/meta-edison-distro/recipes-core/ota-update/files/ota-update.target @@ -0,0 +1,7 @@ +[Unit] +Description=OTA update target +Requires=sysinit.target +Conflicts=shutdown.target systemd-readahead-collect.service systemd-readahead-replay.service home.automount factory.automount +After=sysinit.target +Before=shutdown.target +AllowIsolate=yes diff --git a/meta-edison-distro/recipes-core/ota-update/ota-update.bb b/meta-edison-distro/recipes-core/ota-update/ota-update.bb new file mode 100644 index 0000000..f41eb0d --- /dev/null +++ b/meta-edison-distro/recipes-core/ota-update/ota-update.bb @@ -0,0 +1,40 @@ +DESCRIPTION = "OTA update systemd target" +LICENSE = "GPLv2+" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6" + +SRC_URI = "file://ota-update.service \ + file://ota-update.target \ + file://ota-update.sh" + +SYSTEMD_SERVICE_${PN} = "ota-update.service" + +RDEPENDS_${PN} = "systemd" + +do_install() { + install -d ${D}/sbin + install -c -m 0744 ${WORKDIR}/ota-update.sh ${D}/sbin + install -d ${D}${systemd_unitdir}/system + install -d ${D}${sysconfdir}/systemd/system/ota-update.target.wants + install -c -m 0644 ${WORKDIR}/ota-update.target ${D}${systemd_unitdir}/system + install -c -m 0644 ${WORKDIR}/ota-update.service ${D}${systemd_unitdir}/system + sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \ + -e 's,@BASE_SBINDIR@,${base_sbindir},g' \ + -e 's,@SBINDIR@,${sbindir},g' \ + -e 's,@BINDIR@,${bindir},g' \ + ${D}${systemd_unitdir}/system/ota-update.service + + # enable services + ln -sf ${systemd_unitdir}/system/ota-update.service \ + ${D}${sysconfdir}/systemd/system/ota-update.target.wants/ota-update.service +} + +FILES_${PN} = "${base_libdir}/systemd/system/*.service \ + ${base_libdir}/systemd/system/ota-update.target \ + ${sysconfdir} \ + /sbin/ota-update.sh" + +# As this package is tied to systemd, only build it when we're also building systemd. +python () { + if not oe.utils.contains ('DISTRO_FEATURES', 'systemd', True, False, d): + raise bb.parse.SkipPackage("'systemd' not in DISTRO_FEATURES") +} diff --git a/meta-edison-distro/recipes-core/readline/files/readline-fix-segfault-when-pressing-DEL-key-twice.patch b/meta-edison-distro/recipes-core/readline/files/readline-fix-segfault-when-pressing-DEL-key-twice.patch new file mode 100644 index 0000000..4dcaf89 --- /dev/null +++ b/meta-edison-distro/recipes-core/readline/files/readline-fix-segfault-when-pressing-DEL-key-twice.patch @@ -0,0 +1,39 @@ +From 8acbcaa6b3d855f3e85e6a108db323278584091e Mon Sep 17 00:00:00 2001 +From: Loic Akue <loicx.akue@intel.com> +Date: Mon, 3 Nov 2014 16:26:42 +0100 +Subject: [PATCH] bug readline + +| READLINE PATCH REPORT +| ===================== +| +|Readline-Release: 6.3 +|Patch-ID: readline63-002 +| +|Bug-Reported-by: Anatol Pomozov <anatol.pomozov@gmail.com> +|Bug-Reference-ID: <CAOMFOmXy3mT2So5GQ5F-smCVArQuAeBwZ2QKzgCtMeXJoDeYOQ@mail.gmail.com> +|Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-readline/2014-03/msg00010.html +| +|Bug-Description: +| +|When in callback mode, some readline commands can cause readline to seg +|fault by passing invalid contexts to callback functions. + +Signed-off-by: Loic Akue <loicx.akue@intel.com> + +diff --git a/readline.c b/readline.c +index 03eefa6..55c0522 100644 +--- a/readline.c ++++ b/readline.c +@@ -744,7 +744,8 @@ _rl_dispatch_callback (cxt) + r = _rl_subseq_result (r, cxt->oldmap, cxt->okey, (cxt->flags & KSEQ_SUBSEQ)); + + RL_CHECK_SIGNALS (); +- if (r == 0) /* success! */ ++ /* We only treat values < 0 specially to simulate recursion. */ ++ if (r >= 0 || (r == -1 && (cxt->flags & KSEQ_SUBSEQ) == 0)) /* success! or failure! */ + { + _rl_keyseq_chain_dispose (); + RL_UNSETSTATE (RL_STATE_MULTIKEY); +-- +1.7.9.5 + diff --git a/meta-edison-distro/recipes-core/readline/readline_6.3.bbappend b/meta-edison-distro/recipes-core/readline/readline_6.3.bbappend new file mode 100644 index 0000000..c8ecc36 --- /dev/null +++ b/meta-edison-distro/recipes-core/readline/readline_6.3.bbappend @@ -0,0 +1,4 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/files:" +SRC_URI += "\ + file://readline-fix-segfault-when-pressing-DEL-key-twice.patch \ + " diff --git a/meta-edison-distro/recipes-core/resize-rootfs/files/resize-rootfs.service b/meta-edison-distro/recipes-core/resize-rootfs/files/resize-rootfs.service new file mode 100644 index 0000000..708226f --- /dev/null +++ b/meta-edison-distro/recipes-core/resize-rootfs/files/resize-rootfs.service @@ -0,0 +1,14 @@ +[Unit] +Description=Increases rootfs image size to fit partition +Requires=dev-disk-by\x2dpartlabel-rootfs.device +After=dev-disk-by\x2dpartlabel-rootfs.device + +[Service] +Type=oneshot +ExecStart=/sbin/resize2fs /dev/disk/by-partlabel/rootfs +ExecStart=/bin/systemctl disable resize-rootfs.service + +StandardOutput=journal+console + +[Install] +WantedBy=default.target diff --git a/meta-edison-distro/recipes-core/resize-rootfs/resize-rootfs.bb b/meta-edison-distro/recipes-core/resize-rootfs/resize-rootfs.bb new file mode 100644 index 0000000..f91e4ba --- /dev/null +++ b/meta-edison-distro/recipes-core/resize-rootfs/resize-rootfs.bb @@ -0,0 +1,24 @@ +DESCRIPTION = "Resize Rootfs systemd service" +LICENSE = "GPLv2+" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6" + +SRC_URI = "file://resize-rootfs.service" + +inherit systemd + +SYSTEMD_SERVICE_${PN} = "resize-rootfs.service" + +RDEPENDS_${PN} = "systemd e2fsprogs-resize2fs" + +do_install() { + install -d ${D}${systemd_unitdir}/system + install -c -m 0644 ${WORKDIR}/resize-rootfs.service ${D}${systemd_unitdir}/system +} + +FILES_${PN} = "${base_libdir}/systemd/system/resize-rootfs.service" + +# As this package is tied to systemd, only build it when we're also building systemd. +python () { + if not oe.utils.contains ('DISTRO_FEATURES', 'systemd', True, False, d): + raise bb.parse.SkipPackage("'systemd' not in DISTRO_FEATURES") +} diff --git a/meta-edison-distro/recipes-core/systemd/files/edison-machine-id.service b/meta-edison-distro/recipes-core/systemd/files/edison-machine-id.service new file mode 100644 index 0000000..3caa836 --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/files/edison-machine-id.service @@ -0,0 +1,14 @@ +[Unit] +Description= Generate unique machine-id +After=systemd-remount-fs.service + +[Service] +Type=oneshot +ExecStartPre=/bin/umount /etc/machine-id +ExecStart=/bin/systemd-machine-id-setup +ExecStartPost=/bin/systemctl disable edison-machine-id +StandardOutput=journal+console + +[Install] +WantedBy=basic.target + diff --git a/meta-edison-distro/recipes-core/systemd/files/hsu-pm-runtime.service b/meta-edison-distro/recipes-core/systemd/files/hsu-pm-runtime.service new file mode 100644 index 0000000..e81b6ff --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/files/hsu-pm-runtime.service @@ -0,0 +1,14 @@ +[Unit] +Description= HSU runtime pm service +Requires=getty.target +After=getty.target + +[Service] +Type=oneshot +ExecStart=/bin/sh -c 'echo auto > /sys/devices/pci0000:00/0000:00:04.3/power/control' +ExecStart=/bin/sh -c 'echo auto > /sys/devices/pci0000:00/0000:00:04.1/power/control' +StandardOutput=null + +[Install] +WantedBy=default.target + diff --git a/meta-edison-distro/recipes-core/systemd/files/journald.conf b/meta-edison-distro/recipes-core/systemd/files/journald.conf new file mode 100644 index 0000000..e096485 --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/files/journald.conf @@ -0,0 +1,36 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. +# +# See journald.conf(5) for details + +[Journal] +Storage=persistent +#Compress=yes +#Seal=yes +#SplitMode=login +#SyncIntervalSec=5m +#RateLimitInterval=30s +#RateLimitBurst=1000 +#SystemMaxUse= +#SystemKeepFree= +#SystemMaxFileSize= +#RuntimeMaxUse= +#RuntimeKeepFree= +#RuntimeMaxFileSize= +#MaxRetentionSec= +#MaxFileSec=1month +#ForwardToSyslog=yes +#ForwardToKMsg=no +#ForwardToConsole=no +#ForwardToWall=yes +#TTYPath=/dev/console +#MaxLevelStore=debug +#MaxLevelSyslog=debug +#MaxLevelKMsg=notice +#MaxLevelConsole=info +#MaxLevelWall=emerg + diff --git a/meta-edison-distro/recipes-core/systemd/files/system.conf b/meta-edison-distro/recipes-core/systemd/files/system.conf new file mode 100644 index 0000000..e21ba85 --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/files/system.conf @@ -0,0 +1,45 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. +# +# See systemd-system.conf(5) for details + +[Manager] +#LogLevel=info +#LogTarget=journal-or-kmsg +#LogColor=yes +#LogLocation=no +#DumpCore=yes +#CrashShell=no +#ShowStatus=yes +#CrashChVT=1 +#CPUAffinity=1 2 +#DefaultControllers=cpu +#DefaultStandardOutput=journal +#DefaultStandardError=inherit +#JoinControllers=cpu,cpuacct,cpuset net_cls,net_prio +# Watchdog timeout. Value must be between 35 and 170 seconds. +RuntimeWatchdogSec=90 +#ShutdownWatchdogSec=10min +#CapabilityBoundingSet= +#TimerSlackNSec= +#DefaultEnvironment= +#DefaultLimitCPU= +#DefaultLimitFSIZE= +#DefaultLimitDATA= +#DefaultLimitSTACK= +#DefaultLimitCORE= +#DefaultLimitRSS= +#DefaultLimitNOFILE= +#DefaultLimitAS= +#DefaultLimitNPROC= +#DefaultLimitMEMLOCK= +#DefaultLimitLOCKS= +#DefaultLimitSIGPENDING= +#DefaultLimitMSGQUEUE= +#DefaultLimitNICE= +#DefaultLimitRTPRIO= +#DefaultLimitRTTIME= diff --git a/meta-edison-distro/recipes-core/systemd/files/systemd-reboot-service.patch b/meta-edison-distro/recipes-core/systemd/files/systemd-reboot-service.patch new file mode 100644 index 0000000..aaf1121 --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/files/systemd-reboot-service.patch @@ -0,0 +1,9 @@ +diff --git a/units/systemd-reboot.service.in b/units/systemd-reboot.service.in +index d99bd3e..4517cfe 100644 +--- a/units/systemd-reboot.service.in ++++ b/units/systemd-reboot.service.in +@@ -15,3 +15,4 @@ After=shutdown.target umount.target final.target + [Service] + Type=oneshot + ExecStart=@SYSTEMCTL@ --force reboot ++ExecStartPre=/bin/sh -c " if test -e /run/systemd/reboot-param ; then read REBOOTPARAM < /run/systemd/reboot-param ; fw_setenv bootargs_mode $REBOOTPARAM ; fi " diff --git a/meta-edison-distro/recipes-core/systemd/files/timesyncd.conf b/meta-edison-distro/recipes-core/systemd/files/timesyncd.conf new file mode 100644 index 0000000..620ef45 --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/files/timesyncd.conf @@ -0,0 +1,12 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. +# +# See timesyncd.conf(5) for details + +[Time] +Servers=time1.google.com time2.google.com time3.google.com time4.google.com + diff --git a/meta-edison-distro/recipes-core/systemd/files/usb0.network b/meta-edison-distro/recipes-core/systemd/files/usb0.network new file mode 100644 index 0000000..b7d1042 --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/files/usb0.network @@ -0,0 +1,6 @@ +[Match] +Name=usb0 + +[Network] +Address=192.168.2.15/24 + diff --git a/meta-edison-distro/recipes-core/systemd/systemd-compat-units.bb b/meta-edison-distro/recipes-core/systemd/systemd-compat-units.bb new file mode 100644 index 0000000..6419bc2 --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/systemd-compat-units.bb @@ -0,0 +1,41 @@ +SUMMARY = "Enhances systemd compatilibity with existing SysVinit scripts" + +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690" + +PR = "r29" + +DEPENDS = "systemd-systemctl-native" + +inherit allarch + +ALLOW_EMPTY_${PN} = "1" + +SYSTEMD_DISABLED_SYSV_SERVICES = " \ + busybox-udhcpc \ + hwclock \ + networking \ + nfsserver \ + nfscommon \ + syslog.busybox \ +" + +pkg_postinst_${PN} () { + cd $D${sysconfdir}/init.d + + echo "Disabling the following sysv scripts: " + + OPTS="" + + if [ -n "$D" ]; then + OPTS="--root=$D" + fi + + for i in ${SYSTEMD_DISABLED_SYSV_SERVICES} ; do + if [ \( -e $i -o $i.sh \) -a ! \( -e $D${sysconfdir}/systemd/system/$i.service -o -e $D${systemd_unitdir}/system/$i.service \) ] ; then + echo -n "$i: " ; systemctl ${OPTS} mask $i.service + fi + done ; echo +} + +RDPEPENDS_${PN} = "systemd" diff --git a/meta-edison-distro/recipes-core/systemd/systemd-serialgetty.bb b/meta-edison-distro/recipes-core/systemd/systemd-serialgetty.bb new file mode 100644 index 0000000..1c34d5c --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/systemd-serialgetty.bb @@ -0,0 +1,49 @@ +SUMMARY = "Serial terminal support for systemd" +LICENSE = "GPLv2+" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6" + +PR = "r5" + +SERIAL_CONSOLE ?= "115200 ttyS0" + +SRC_URI = "file://serial-getty@.service" + +do_install() { + if [ ! -z "${SERIAL_CONSOLES}" ] ; then + default_baudrate=`echo "${SERIAL_CONSOLES}" | sed 's/\;.*//'` + install -d ${D}${systemd_unitdir}/system/ + install -d ${D}${sysconfdir}/systemd/system/getty.target.wants/ + install -m 0644 ${WORKDIR}/serial-getty@.service ${D}${systemd_unitdir}/system/ + sed -i -e s/\@BAUDRATE\@/$default_baudrate/g ${D}${systemd_unitdir}/system/serial-getty@.service + + tmp="${SERIAL_CONSOLES}" + for entry in $tmp ; do + baudrate=`echo $entry | sed 's/\;.*//'` + ttydev=`echo $entry | sed -e 's/^[0-9]*\;//' -e 's/\;.*//'` + if [ "$baudrate" = "$default_baudrate" ] ; then + # enable the service + ln -sf ${systemd_unitdir}/system/serial-getty@.service \ + ${D}${sysconfdir}/systemd/system/getty.target.wants/serial-getty@$ttydev.service + else + # install custom service file for the non-default baudrate + install -m 0644 ${WORKDIR}/serial-getty@.service ${D}${systemd_unitdir}/system/serial-getty$baudrate@.service + sed -i -e s/\@BAUDRATE\@/$baudrate/g ${D}${systemd_unitdir}/system/serial-getty$baudrate@.service + # enable the service + ln -sf ${systemd_unitdir}/system/serial-getty$baudrate@.service \ + ${D}${sysconfdir}/systemd/system/getty.target.wants/serial-getty$baudrate@$ttydev.service + fi + done + fi +} + +RDEPENDS_${PN} = "systemd" + +# This is a machine specific file +FILES_${PN} = "${systemd_unitdir}/system/*.service ${sysconfdir}" +PACKAGE_ARCH = "${MACHINE_ARCH}" + +# As this package is tied to systemd, only build it when we're also building systemd. +python () { + if not bb.utils.contains ('DISTRO_FEATURES', 'systemd', True, False, d): + raise bb.parse.SkipPackage("'systemd' not in DISTRO_FEATURES") +} diff --git a/meta-edison-distro/recipes-core/systemd/systemd-serialgetty/serial-getty@.service b/meta-edison-distro/recipes-core/systemd/systemd-serialgetty/serial-getty@.service new file mode 100644 index 0000000..6dd335c --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/systemd-serialgetty/serial-getty@.service @@ -0,0 +1,37 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. + +[Unit] +Description=Serial Getty on %I +Documentation=man:agetty(8) man:systemd-getty-generator(8) +Documentation=http://0pointer.de/blog/projects/serial-console.html +BindsTo=dev-%i.device +After=dev-%i.device systemd-user-sessions.service plymouth-quit-wait.service +After=rc-local.service + +# If additional gettys are spawned during boot then we should make +# sure that this is synchronized before getty.target, even though +# getty.target didn't actually pull it in. +Before=getty.target +IgnoreOnIsolate=yes + +[Service] +Environment="TERM=xterm" +ExecStart=-/sbin/agetty -8 --keep-baud %I @BAUDRATE@ $TERM +Type=idle +Restart=always +RestartSec=0 +UtmpIdentifier=%I +TTYPath=/dev/%I +TTYReset=yes +TTYVHangup=yes +KillMode=process +IgnoreSIGPIPE=no +SendSIGHUP=yes + +[Install] +WantedBy=getty.target diff --git a/meta-edison-distro/recipes-core/systemd/systemd-systemctl-native.bb b/meta-edison-distro/recipes-core/systemd/systemd-systemctl-native.bb new file mode 100644 index 0000000..72bc77d --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/systemd-systemctl-native.bb @@ -0,0 +1,15 @@ +SUMMARY = "Wrapper for enabling systemd services" + +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690" + +PR = "r6" + +inherit native + +SRC_URI = "file://systemctl" + +do_install() { + install -d ${D}${bindir} + install -m 0755 ${WORKDIR}/systemctl ${D}${bindir} +} diff --git a/meta-edison-distro/recipes-core/systemd/systemd-systemctl/systemctl b/meta-edison-distro/recipes-core/systemd/systemd-systemctl/systemctl new file mode 100755 index 0000000..b37f27a --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/systemd-systemctl/systemctl @@ -0,0 +1,153 @@ +#!/bin/sh +echo "Started $0 $*" + +ROOT= + +# parse command line params +action= +while [ $# != 0 ]; do + opt="$1" + + case "$opt" in + enable) + shift + + action="$opt" + services="$1" + cmd_args="1" + shift + ;; + disable) + shift + + action="$opt" + services="$1" + cmd_args="1" + shift + ;; + mask) + shift + + action="$opt" + services="$1" + cmd_args="1" + shift + ;; + preset) + shift + + action="$opt" + services="$1" + cmd_args="1" + shift + ;; + --root=*) + ROOT=${opt##--root=} + cmd_args="0" + shift + ;; + *) + if [ "$cmd_args" = "1" ]; then + services="$services $opt" + shift + else + echo "'$opt' is an unkown option; exiting with error" + exit 1 + fi + ;; + esac +done +if [ "$action" = "preset" -a "$service_file" = "" ]; then + services=$(for f in `find $ROOT/etc/systemd/system $ROOT/lib/systemd/system $ROOT/usr/lib/systemd/system -type f 2>1`; do basename $f; done) + services="$services $opt" + presetall=1 +fi + +for service in $services; do + if [ "$presetall" = "1" ]; then + action="preset" + fi + if [ "$action" = "mask" ]; then + if [ ! -d $ROOT/etc/systemd/system/ ]; then + mkdir -p $ROOT/etc/systemd/system/ + fi + cmd="ln -s /dev/null $ROOT/etc/systemd/system/$service" + echo "$cmd" + $cmd + exit 0 + fi + + echo "Try to find location of $service..." + # find service file + for p in $ROOT/etc/systemd/system \ + $ROOT/lib/systemd/system \ + $ROOT/usr/lib/systemd/system; do + if [ -e $p/$service ]; then + service_file=$p/$service + service_file=${service_file##$ROOT} + fi + done + if [ -z "$service_file" ]; then + echo "'$service' couldn't be found; exiting with error" + exit 1 + fi + echo "Found $service in $service_file" + + # If any new unit types are added to systemd they should be added + # to this regular expression. + unit_types_re='\.\(service\|socket\|device\|mount\|automount\|swap\|target\|path\|timer\|snapshot\)$' + if [ "$action" = "preset" ]; then + action=`egrep -sh $service $ROOT/etc/systemd/user-preset/*.preset | cut -f1 -d' '` + if [ -z "$action" ]; then + globalpreset=`egrep -sh '\*' $ROOT/etc/systemd/user-preset/*.preset | cut -f1 -d' '` + if [ -n "$globalpreset" ]; then + action="$globalpreset" + else + action="enable" + fi + fi + fi + # create the required symbolic links + wanted_by=$(sed '/^WantedBy[[:space:]]*=/s,[^=]*=,,p;d' "$ROOT/$service_file" \ + | tr ',' '\n' \ + | grep "$unit_types_re") + + for r in $wanted_by; do + echo "WantedBy=$r found in $service" + if [ "$action" = "enable" ]; then + mkdir -p $ROOT/etc/systemd/system/$r.wants + ln -s $service_file $ROOT/etc/systemd/system/$r.wants + echo "Enabled $service for $wanted_by." + else + rm -f $ROOT/etc/systemd/system/$r.wants/$service + rmdir --ignore-fail-on-non-empty -p $ROOT/etc/systemd/system/$r.wants + echo "Disabled $service for $wanted_by." + fi + done + + # create the required symbolic 'Alias' links + alias=$(sed '/^Alias[[:space:]]*=/s,[^=]*=,,p;d' "$ROOT/$service_file" \ + | tr ',' '\n' \ + | grep "$unit_types_re") + + for r in $alias; do + if [ "$action" = "enable" ]; then + mkdir -p $ROOT/etc/systemd/system + ln -s $service_file $ROOT/etc/systemd/system/$r + echo "Enabled $service for $alias." + else + rm -f $ROOT/etc/systemd/system/$r + echo "Disabled $service for $alias." + fi + done + + # call us for the other required scripts + also=$(sed '/^Also[[:space:]]*=/s,[^=]*=,,p;d' "$ROOT/$service_file" \ + | tr ',' '\n') + for a in $also; do + echo "Also=$a found in $service" + if [ "$action" = "enable" ]; then + $0 --root=$ROOT enable $a + fi + done +done diff --git a/meta-edison-distro/recipes-core/systemd/systemd/00-create-volatile.conf b/meta-edison-distro/recipes-core/systemd/systemd/00-create-volatile.conf new file mode 100644 index 0000000..01ec03e --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/systemd/00-create-volatile.conf @@ -0,0 +1,6 @@ +#This goes hand-in-hand with the base-files of OE-Core. The file must +# be sorted before 'systemd.conf' becuase this attempts to create a file +# inside /var/log. + + +d /var/volatile/tmp - - - - diff --git a/meta-edison-distro/recipes-core/systemd/systemd/0001-uClibc-doesn-t-implement-pwritev-preadv.patch b/meta-edison-distro/recipes-core/systemd/systemd/0001-uClibc-doesn-t-implement-pwritev-preadv.patch new file mode 100644 index 0000000..9fdb3c9 --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/systemd/0001-uClibc-doesn-t-implement-pwritev-preadv.patch @@ -0,0 +1,34 @@ +Upstream-Status: Inappropriate [uclibc specific] + +From 7be9273548bcb1f57d011fc252965e45dd2a058c Mon Sep 17 00:00:00 2001 +From: Khem Raj <raj.khem@gmail.com> +Date: Wed, 21 Aug 2013 19:09:27 -0700 +Subject: [PATCH] uClibc doesn't implement pwritev/preadv + +Lets stub out the testcase for building. + +Signed-off-by: Khem Raj <raj.khem@gmail.com> +--- + src/libsystemd-bus/test-bus-memfd.c | 2 ++ + 1 file changed, 2 insertions(+) + +Index: systemd-209/src/libsystemd/sd-bus/test-bus-memfd.c +=================================================================== +--- systemd-209.orig/src/libsystemd/sd-bus/test-bus-memfd.c 2014-02-19 15:03:09.983254602 -0800 ++++ systemd-209/src/libsystemd/sd-bus/test-bus-memfd.c 2014-02-19 23:42:10.636652864 -0800 +@@ -151,6 +151,7 @@ + /* check content */ + assert_se(memcmp(buf, "ll", 2) == 0); + ++#ifndef __UCLIBC__ + /* writev it out*/ + iov[0].iov_base = (char *)"ABC"; + iov[0].iov_len = 3; +@@ -173,6 +174,7 @@ + assert_se(memcmp(bufv[0], "ABC", 3) == 0); + assert_se(memcmp(bufv[1], "DEF", 3) == 0); + assert_se(memcmp(bufv[2], "GHI", 3) == 0); ++#endif /* __UCLIBC__ */ + + sd_memfd_free(m); + diff --git a/meta-edison-distro/recipes-core/systemd/systemd/binfmt-install.patch b/meta-edison-distro/recipes-core/systemd/systemd/binfmt-install.patch new file mode 100644 index 0000000..c2d5099 --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/systemd/binfmt-install.patch @@ -0,0 +1,56 @@ +Don't install dependency links at install time for the binfmt services, use +[Install] blocks so that they get created when the service is enabled like a +traditional service. + +The [Install] blocks were rejected upstream as they don't have a way to "enable" +it on install without static symlinks which can't be disabled, only masked. We +however can do that in a postinst. + +Upstream-Status: Denied +Signed-off-by: Ross Burton <ross.burton@intel.com> + +diff --git a/Makefile.am b/Makefile.am +index 7933de6..78acb6f 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -3133,10 +3133,6 @@ INSTALL_DIRS += \ + $(prefix)/lib/binfmt.d \ + $(sysconfdir)/binfmt.d + +-SYSINIT_TARGET_WANTS += \ +- systemd-binfmt.service \ +- proc-sys-fs-binfmt_misc.automount +- + endif + + EXTRA_DIST += \ +diff --git a/units/proc-sys-fs-binfmt_misc.automount b/units/proc-sys-fs-binfmt_misc.automount +index 6be3893..709adef 100644 +--- a/units/proc-sys-fs-binfmt_misc.automount ++++ b/units/proc-sys-fs-binfmt_misc.automount +@@ -16,3 +16,6 @@ ConditionPathIsReadWrite=/proc/sys/ + + [Automount] + Where=/proc/sys/fs/binfmt_misc ++ ++[Install] ++WantedBy=sysinit.target +diff --git a/units/systemd-binfmt.service.in b/units/systemd-binfmt.service.in +index 02dfe77..86d3481 100644 +--- a/units/systemd-binfmt.service.in ++++ b/units/systemd-binfmt.service.in +@@ -11,6 +11,7 @@ Documentation=man:systemd-binfmt.service(8) man:binfmt.d(5) + Documentation=https://www.kernel.org/doc/Documentation/binfmt_misc.txt + DefaultDependencies=no + Conflicts=shutdown.target ++Wants=proc-sys-fs-binfmt_misc.automount + After=systemd-readahead-collect.service systemd-readahead-replay.service proc-sys-fs-binfmt_misc.automount + Before=sysinit.target shutdown.target + ConditionPathIsReadWrite=/proc/sys/ +@@ -24,3 +25,6 @@ ConditionDirectoryNotEmpty=|/run/binfmt.d + Type=oneshot + RemainAfterExit=yes + ExecStart=@rootlibexecdir@/systemd-binfmt ++ ++[Install] ++WantedBy=sysinit.target diff --git a/meta-edison-distro/recipes-core/systemd/systemd/init b/meta-edison-distro/recipes-core/systemd/systemd/init new file mode 100644 index 0000000..ea52be4 --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/systemd/init @@ -0,0 +1,104 @@ +#!/bin/sh + +### BEGIN INIT INFO +# Provides: udev +# Required-Start: mountvirtfs +# Required-Stop: +# Default-Start: S +# Default-Stop: +# Short-Description: Start udevd, populate /dev and load drivers. +### END INIT INFO + +. /etc/init.d/functions + +export TZ=/etc/localtime + +[ -d /sys/class ] || exit 1 +[ -r /proc/mounts ] || exit 1 +[ -x @UDEVD@ ] || exit 1 +[ -f /etc/default/udev-cache ] && . /etc/default/udev-cache +[ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf + +readfile () { + filename=$1 + READDATA="" + if [ -r $filename ]; then + while read line; do + READDATA="$READDATA$line" + done < $filename + fi +} + +case "$1" in + start) + export ACTION=add + # propagate /dev from /sys + echo "Starting udev" + + # mount the devtmpfs on /dev, if not already done + LANG=C awk '$2 == "/dev" && ($3 == "devtmpfs") { exit 1 }' /proc/mounts && { + mount -n -o mode=0755 -t devtmpfs none "/dev" + } + [ -e /dev/pts ] || mkdir -m 0755 /dev/pts + [ -e /dev/shm ] || mkdir -m 1777 /dev/shm + mount -a -t tmpfs 2>/dev/null + + # cache handling + if [ "$DEVCACHE" != "" ]; then + readfile /proc/version + VERSION="$READDATA" + readfile /proc/cmdline + CMDLINE="$READDATA" + readfile /proc/devices + DEVICES="$READDATA" + readfile /proc/atags + ATAGS="$READDATA" + + if [ -e $DEVCACHE ]; then + readfile /etc/udev/cache.data + if [ "$READDATA" = "$VERSION$CMDLINE$DEVICES$ATAGS" ]; then + (cd /; tar xf $DEVCACHE > /dev/null 2>&1) + not_first_boot=1 + [ "$VERBOSE" != "no" ] && echo "udev: using cache file $DEVCACHE" + [ -e /dev/shm/udev.cache ] && rm -f /dev/shm/udev.cache + else + echo "$VERSION$CMDLINE$DEVICES$ATAGS" > /dev/shm/udev.cache + fi + else + echo "$VERSION$CMDLINE$DEVICES$ATAGS" > /dev/shm/udev.cache + fi + fi + + # make_extra_nodes + killproc systemd-udevd > "/dev/null" 2>&1 + + # trigger the sorted events + echo -e '\000\000\000\000' > /proc/sys/kernel/hotplug + @UDEVD@ -d + + udevadm control --env=STARTUP=1 + if [ "$not_first_boot" != "" ];then + udevadm trigger --action=add --subsystem-nomatch=tty --subsystem-nomatch=mem --subsystem-nomatch=vc --subsystem-nomatch=vtconsole --subsystem-nomatch=misc --subsystem-nomatch=dcon --subsystem-nomatch=pci_bus --subsystem-nomatch=graphics --subsystem-nomatch=backlight --subsystem-nomatch=video4linux --subsystem-nomatch=platform + (udevadm settle --timeout=3; udevadm control --env=STARTUP=)& + else + udevadm trigger --action=add + udevadm settle + fi + ;; + stop) + echo "Stopping udevd" + start-stop-daemon --stop --name systemd-udevd --quiet + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + status) + status systemd-udevd + ;; + *) + echo "Usage: $0 {start|stop|status|restart}" + exit 1 +esac +exit 0 diff --git a/meta-edison-distro/recipes-core/systemd/systemd/optional_secure_getenv.patch b/meta-edison-distro/recipes-core/systemd/systemd/optional_secure_getenv.patch new file mode 100644 index 0000000..2063268 --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/systemd/optional_secure_getenv.patch @@ -0,0 +1,19 @@ +on uclibc secure_getenv is not available +therefore default to using getenv instead + +Upstream-Status: Denied [no desire for uclibc support] +Signed-off-by: Khem Raj <raj.khem@gmail.com> + +Index: git/src/shared/missing.h +=================================================================== +--- git.orig/src/shared/missing.h 2012-09-22 18:46:44.141282145 -0700 ++++ git/src/shared/missing.h 2012-09-22 18:48:44.081276570 -0700 +@@ -233,6 +233,8 @@ + #ifndef HAVE_SECURE_GETENV + # ifdef HAVE___SECURE_GETENV + # define secure_getenv __secure_getenv ++# elif defined __UCLIBC__ ++# define secure_getenv getenv + # else + # error neither secure_getenv nor __secure_getenv are available + # endif diff --git a/meta-edison-distro/recipes-core/systemd/systemd/run-ptest b/meta-edison-distro/recipes-core/systemd/systemd/run-ptest new file mode 100644 index 0000000..2f6bd93 --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/systemd/run-ptest @@ -0,0 +1,3 @@ +tar -C test -xJf test/sys.tar.xz +make test/rules-test.sh.log +make test/udev-test.pl.log diff --git a/meta-edison-distro/recipes-core/systemd/systemd/systemd-older-kernel.patch b/meta-edison-distro/recipes-core/systemd/systemd/systemd-older-kernel.patch new file mode 100644 index 0000000..18b50e7 --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/systemd/systemd-older-kernel.patch @@ -0,0 +1,56 @@ +From 6109f02dcc4f2d7a461c5772bab494f5753a2203 Mon Sep 17 00:00:00 2001 +From: Robert Yang <liezhi.yang@windriver.com> +Date: Thu, 29 May 2014 08:09:07 +0000 +Subject: [PATCH] rtnl-types.c: check IFLA_VLAN_PROTOCOL + +The older kernel's linux/if_link.h doesn't have IFLA_VLAN_PROTOCOL, we need +check whether it has been defined or not. + +The maintainer said that he would fix it: + +http://thread.gmane.org/gmane.comp.sysutils.systemd.devel/18200 + +Also we need redefine IFLA_MAX from 34 to 35 when define IFLA_CARRIER, +otherwise there would be error: + +| src/libsystemd/sd-rtnl/rtnl-types.c:233:9: error: array index in initializer exceeds array bounds +| [IFLA_CARRIER] = { .type = NLA_U8 }, + +Upstream-Status: Pending + +Signed-off-by: Robert Yang <liezhi.yang@windriver.com> +--- + src/libsystemd/sd-rtnl/rtnl-types.c | 2 ++ + src/shared/missing.h | 2 ++ + 2 files changed, 4 insertions(+) + +diff --git a/src/libsystemd/sd-rtnl/rtnl-types.c b/src/libsystemd/sd-rtnl/rtnl-types.c +index 44ac5ec..ab6161f 100644 +--- a/src/libsystemd/sd-rtnl/rtnl-types.c ++++ b/src/libsystemd/sd-rtnl/rtnl-types.c +@@ -67,7 +67,9 @@ static const NLType rtnl_link_info_data_vlan_types[IFLA_VLAN_MAX + 1] = { + [IFLA_VLAN_EGRESS_QOS] = { .type = NLA_NESTED }, + [IFLA_VLAN_INGRESS_QOS] = { .type = NLA_NESTED }, + */ ++#ifdef IFLA_VLAN_PROTOCOL + [IFLA_VLAN_PROTOCOL] = { .type = NLA_U16 }, ++#endif + }; + + static const NLType rtnl_link_info_data_bond_types[IFLA_BOND_MAX + 1] = { +diff --git a/src/shared/missing.h b/src/shared/missing.h +index d5ec2f8..732853f 100644 +--- a/src/shared/missing.h ++++ b/src/shared/missing.h +@@ -94,6 +94,8 @@ + + #ifndef IFLA_CARRIER + #define IFLA_CARRIER 33 ++ #undef IFLA_MAX ++ #define IFLA_MAX 35 + #ifndef IFLA_NUM_RX_QUEUES + #define IFLA_NUM_RX_QUEUES 32 + #ifndef IFLA_NUM_TX_QUEUES +-- +1.8.3.4 + diff --git a/meta-edison-distro/recipes-core/systemd/systemd/systemd-pam-configure-check-uclibc.patch b/meta-edison-distro/recipes-core/systemd/systemd/systemd-pam-configure-check-uclibc.patch new file mode 100644 index 0000000..4639532 --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/systemd/systemd-pam-configure-check-uclibc.patch @@ -0,0 +1,32 @@ +Upstream-Status: Denied [no desire for uclibc support] +Signed-off-by: Khem Raj <raj.khem@gmail.com> + +Index: git/configure.ac +=================================================================== +--- git.orig/configure.ac 2014-03-15 17:53:51.756340454 -0700 ++++ git/configure.ac 2014-03-15 18:07:34.888355897 -0700 +@@ -78,6 +78,24 @@ + + M4_DEFINES= + ++# check for few functions not implemented in uClibc ++ ++AC_CHECK_FUNCS_ONCE(mkostemp execvpe posix_fallocate) ++ ++# check for %ms format support - assume always no if cross compiling ++ ++AC_MSG_CHECKING([whether %ms format is supported by *scanf]) ++ ++AC_LINK_IFELSE( ++ [AC_LANG_PROGRAM([ ++ #include <stdio.h> ++ ],[ ++ char *buf1, *buf2, *buf3, str="1 2.3 abcde" ; ++ int rc = sscanf(str, "%ms %ms %ms", &buf1, &buf2, &buf3) ; ++ return (rc==3)?0:1;])], ++ [AC_DEFINE([HAVE_MSFORMAT], [1], [Define if %ms format is supported by *scanf.])], ++ [AC_MSG_RESULT([no])]) ++ + # gtkdocize greps for '^GTK_DOC_CHECK', so it needs to be on its own line + m4_ifdef([GTK_DOC_CHECK], [ + GTK_DOC_CHECK([1.18],[--flavour no-tmpl])], diff --git a/meta-edison-distro/recipes-core/systemd/systemd/systemd-pam-fix-execvpe.patch b/meta-edison-distro/recipes-core/systemd/systemd/systemd-pam-fix-execvpe.patch new file mode 100644 index 0000000..7170a38 --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/systemd/systemd-pam-fix-execvpe.patch @@ -0,0 +1,29 @@ +Upstream-Status: Denied [no desire for uclibc support] +Signed-off-by: Khem Raj <raj.khem@gmail.com> + +Index: systemd-209/src/nspawn/nspawn.c +=================================================================== +--- systemd-209.orig/src/nspawn/nspawn.c 2014-02-19 15:03:09.000000000 -0800 ++++ systemd-209/src/nspawn/nspawn.c 2014-02-19 23:20:38.720628627 -0800 +@@ -91,6 +91,8 @@ + LINK_GUEST + } LinkJournal; + ++#include "config.h" ++ + static char *arg_directory = NULL; + static char *arg_user = NULL; + static sd_id128_t arg_uuid = {}; +@@ -2045,7 +2047,12 @@ + a[0] = (char*) "/sbin/init"; + execve(a[0], a, env_use); + } else if (argc > optind) ++#ifdef HAVE_EXECVPE + execvpe(argv[optind], argv + optind, env_use); ++#else ++ environ = env_use; ++ execvp(argv[optind], argv + optind); ++#endif /* HAVE_EXECVPE */ + else { + chdir(home ? home : "/root"); + execle("/bin/bash", "-bash", NULL, env_use); diff --git a/meta-edison-distro/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch b/meta-edison-distro/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch new file mode 100644 index 0000000..f8e19ce --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch @@ -0,0 +1,92 @@ +Upstream-Status: Denied [no desire for uclibc support] + +This patch is uclibc specific, thus not suitable for upstream. + +Signed-off-by: Khem Raj <raj.khem@gmail.com> +Signed-off-by: Chen Qi <Qi.Chen@windriver.com> +--- + src/journal/journal-file.c | 16 +++++++++++++++- + src/journal/journald-kmsg.c | 16 ++++++++++++++-- + 2 files changed, 29 insertions(+), 3 deletions(-) + +diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c +index f2f1f35..092f87b 100644 +--- a/src/journal/journal-file.c ++++ b/src/journal/journal-file.c +@@ -38,6 +38,8 @@ + #include "compress.h" + #include "fsprg.h" + ++#include "config.h" ++ + #define DEFAULT_DATA_HASH_TABLE_SIZE (2047ULL*sizeof(HashItem)) + #define DEFAULT_FIELD_HASH_TABLE_SIZE (333ULL*sizeof(HashItem)) + +@@ -314,7 +316,7 @@ static int journal_file_verify_header(JournalFile *f) { + + static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size) { + uint64_t old_size, new_size; +- int r; ++ int r = 0; + + assert(f); + +@@ -362,9 +364,21 @@ static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size) + /* Note that the glibc fallocate() fallback is very + inefficient, hence we try to minimize the allocation area + as we can. */ ++#ifdef HAVE_POSIX_FALLOCATE + r = posix_fallocate(f->fd, old_size, new_size - old_size); + if (r != 0) + return -r; ++#else ++ /* Write something every 512 bytes to make sure the block is allocated */ ++ uint64_t len = new_size - old_size; ++ uint64_t offset = old_size; ++ for (offset += (len-1) % 512; len > 0; offset += 512) { ++ len -= 512; ++ if (pwrite(f->fd, "", 1, offset) != 1) ++ return -errno; ++ } ++ ++#endif /* HAVE_POSIX_FALLOCATE */ + + if (fstat(f->fd, &f->last_stat) < 0) + return -errno; +diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c +index 12992e7..dc4fa93 100644 +--- a/src/journal/journald-kmsg.c ++++ b/src/journal/journald-kmsg.c +@@ -437,6 +437,7 @@ fail: + int server_open_kernel_seqnum(Server *s) { + _cleanup_close_ int fd; + uint64_t *p; ++ int r = 0; + + assert(s); + +@@ -449,8 +450,19 @@ int server_open_kernel_seqnum(Server *s) { + log_error("Failed to open /run/systemd/journal/kernel-seqnum, ignoring: %m"); + return 0; + } +- +- if (posix_fallocate(fd, 0, sizeof(uint64_t)) < 0) { ++#ifdef HAVE_POSIX_FALLOCATE ++ r = posix_fallocate(fd, 0, sizeof(uint64_t)); ++#else ++ /* Use good old method to write zeros into the journal file ++ perhaps very inefficient yet working. */ ++ char *buf = alloca(sizeof(uint64_t)); ++ off_t oldpos = lseek(fd, 0, SEEK_CUR); ++ bzero(buf, sizeof(uint64_t)); ++ lseek(fd, 0, SEEK_SET); ++ r = write(fd, buf, sizeof(uint64_t)); ++ lseek(fd, oldpos, SEEK_SET); ++#endif /* HAVE_POSIX_FALLOCATE */ ++ if (r < 0) { + log_error("Failed to allocate sequential number file, ignoring: %m"); + return 0; + } +-- +1.7.9.5 + diff --git a/meta-edison-distro/recipes-core/systemd/systemd/systemd-pam-fix-getty-unit.patch b/meta-edison-distro/recipes-core/systemd/systemd/systemd-pam-fix-getty-unit.patch new file mode 100644 index 0000000..9b4c940 --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/systemd/systemd-pam-fix-getty-unit.patch @@ -0,0 +1,35 @@ +Prefer getty to agetty in console setup systemd units + +Upstream-Status: Inappropriate [configuration specific] +Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> +--- + units/getty@.service.m4 | 2 +- + units/serial-getty@.service.m4 | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +Index: git/units/getty@.service.m4 +=================================================================== +--- git.orig/units/getty@.service.m4 2014-03-15 08:16:17.000000000 -0700 ++++ git/units/getty@.service.m4 2014-03-15 08:21:11.007695825 -0700 +@@ -27,7 +27,7 @@ + + [Service] + # the VT is cleared by TTYVTDisallocate +-ExecStart=-/sbin/agetty --noclear %I $TERM ++ExecStart=-/sbin/getty -L %I $TERM + Type=idle + Restart=always + RestartSec=0 +Index: git/units/serial-getty@.service.m4 +=================================================================== +--- git.orig/units/serial-getty@.service.m4 2014-03-15 08:16:17.000000000 -0700 ++++ git/units/serial-getty@.service.m4 2014-03-15 08:22:31.291697331 -0700 +@@ -22,7 +22,7 @@ + IgnoreOnIsolate=yes + + [Service] +-ExecStart=-/sbin/agetty --keep-baud 115200,38400,9600 %I $TERM ++ExecStart=-/sbin/getty -L 115200 %I $TERM + Type=idle + Restart=always + RestartSec=0 diff --git a/meta-edison-distro/recipes-core/systemd/systemd/systemd-pam-fix-mkostemp.patch b/meta-edison-distro/recipes-core/systemd/systemd/systemd-pam-fix-mkostemp.patch new file mode 100644 index 0000000..8c7aa07 --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/systemd/systemd-pam-fix-mkostemp.patch @@ -0,0 +1,30 @@ +Upstream-Status: Denied [no desire for uclibc support] +Signed-off-by: Khem Raj <raj.khem@gmail.com> + +Index: git/src/shared/util.c +=================================================================== +--- git.orig/src/shared/util.c 2014-03-15 15:14:21.368160908 -0700 ++++ git/src/shared/util.c 2014-03-15 15:44:21.988194688 -0700 +@@ -85,6 +85,8 @@ + #include "def.h" + #include "missing.h" + ++#include "config.h" ++ + int saved_argc = 0; + char **saved_argv = NULL; + +@@ -6222,7 +6224,13 @@ + + u = umask(077); + ++#ifdef HAVE_MKOSTEMP + fd = mkostemp(pattern, flags); ++#else ++ fd = mkstemp(pattern); ++ if (fd >= 0) fcntl(fd, F_SETFD, flags); ++#endif /* HAVE_MKOSTEMP */ ++ + if (fd < 0) + return -errno; + diff --git a/meta-edison-distro/recipes-core/systemd/systemd/touchscreen.rules b/meta-edison-distro/recipes-core/systemd/systemd/touchscreen.rules new file mode 100644 index 0000000..d83fd16 --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/systemd/touchscreen.rules @@ -0,0 +1,18 @@ +# There are a number of modifiers that are allowed to be used in some +# of the different fields. They provide the following subsitutions: +# +# %n the "kernel number" of the device. +# For example, 'sda3' has a "kernel number" of '3' +# %e the smallest number for that name which does not matches an existing node +# %k the kernel name for the device +# %M the kernel major number for the device +# %m the kernel minor number for the device +# %b the bus id for the device +# %c the string returned by the PROGRAM +# %s{filename} the content of a sysfs attribute +# %% the '%' char itself +# + +# Create a symlink to any touchscreen input device +SUBSYSTEM=="input", KERNEL=="event[0-9]*", ATTRS{modalias}=="input:*-e0*,3,*a0,1,*18,*", SYMLINK+="input/touchscreen0" +SUBSYSTEM=="input", KERNEL=="event[0-9]*", ATTRS{modalias}=="ads7846", SYMLINK+="input/touchscreen0" diff --git a/meta-edison-distro/recipes-core/systemd/systemd/uclibc-get-physmem.patch b/meta-edison-distro/recipes-core/systemd/systemd/uclibc-get-physmem.patch new file mode 100644 index 0000000..39dfc9e --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/systemd/uclibc-get-physmem.patch @@ -0,0 +1,37 @@ +bypass unimplemented _SC_PHYS_PAGES system configuration API in uclibc + +Upstream-Status: Inappropriate [uclibc-specific] + +Signed-off-by: Khem Raj <raj.khem@gmail.com> + +Index: git/src/shared/util.c +=================================================================== +--- git.orig/src/shared/util.c 2014-03-15 18:09:34.796358146 -0700 ++++ git/src/shared/util.c 2014-03-15 20:16:33.836501084 -0700 +@@ -6332,11 +6332,24 @@ + + /* We return this as uint64_t in case we are running as 32bit + * process on a 64bit kernel with huge amounts of memory */ +- ++#ifdef __UCLIBC__ ++ char line[128]; ++ FILE *f = fopen("/proc/meminfo", "r"); ++ if (f == NULL) ++ return 0; ++ while (!feof(f) && fgets(line, sizeof(line)-1, f)) { ++ if (sscanf(line, "MemTotal: %l kB", &mem) == 1) { ++ mem *= 1024; ++ break; ++ } ++ } ++ fclose(f); ++ return (uint64_t) mem; ++#else + mem = sysconf(_SC_PHYS_PAGES); + assert(mem > 0); +- + return (uint64_t) mem * (uint64_t) page_size(); ++#endif + } + + char* mount_test_option(const char *haystack, const char *needle) { diff --git a/meta-edison-distro/recipes-core/systemd/systemd/uclibc-sysinfo_h.patch b/meta-edison-distro/recipes-core/systemd/systemd/uclibc-sysinfo_h.patch new file mode 100644 index 0000000..15645de --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/systemd/uclibc-sysinfo_h.patch @@ -0,0 +1,19 @@ +Dont include sys/sysinfo.h on uclibc it conflicts with linux/sysinfo.h + +Signed-off-by: Khem Raj <raj.khem@gmail.com> +Upstream-Status: Inappropriate [uclibc specific] + +Index: systemd-209/src/readahead/readahead-common.c +=================================================================== +--- systemd-209.orig/src/readahead/readahead-common.c 2014-02-12 18:42:33.810685053 -0800 ++++ systemd-209/src/readahead/readahead-common.c 2014-02-19 23:49:31.856661142 -0800 +@@ -22,7 +22,9 @@ + #include <errno.h> + #include <stdlib.h> + #include <string.h> ++#ifndef __UCLIBC__ + #include <sys/sysinfo.h> ++#endif + #include <sys/inotify.h> + #include <fcntl.h> + #include <sys/mman.h> diff --git a/meta-edison-distro/recipes-core/systemd/systemd_%.bbappend b/meta-edison-distro/recipes-core/systemd/systemd_%.bbappend new file mode 100644 index 0000000..07b6cb2 --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/systemd_%.bbappend @@ -0,0 +1,34 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/files:" +SRC_URI += "file://journald.conf \ + file://timesyncd.conf \ + file://system.conf \ + file://systemd-reboot-service.patch \ + file://hsu-pm-runtime.service \ + file://usb0.network \ + file://edison-machine-id.service" + +do_install_append() { + # Push the custom conf files on target + install -m 0644 ${WORKDIR}/journald.conf ${D}${sysconfdir}/systemd + install -m 0644 ${WORKDIR}/system.conf ${D}${sysconfdir}/systemd + install -m 0644 ${WORKDIR}/timesyncd.conf ${D}${sysconfdir}/systemd + install -m 0644 ${WORKDIR}/usb0.network ${D}${sysconfdir}/systemd/network + + # enable timesyncd service + install -d ${D}${sysconfdir}/systemd/system/sysinit.target.wants + ln -sf ${systemd_unitdir}/system/systemd-timesyncd.service \ + ${D}${sysconfdir}/systemd/system/sysinit.target.wants/systemd-timesyncd.service + + # enable a custom service to enable the hsu driver's runtime pm + install -d ${D}${sysconfdir}/systemd/system/default.target.wants + install -m 0644 ${WORKDIR}/hsu-pm-runtime.service \ + ${D}${systemd_unitdir}/system/hsu-pm-runtime.service + + # enable a custom service to provide a persistant machine-id value to Edison + install -d ${D}${sysconfdir}/systemd/system/basic.target.wants + install -m 0644 ${WORKDIR}/edison-machine-id.service \ + ${D}${systemd_unitdir}/system/edison-machine-id.service + ln -sf ${systemd_unitdir}/system/edison-machine-id.service \ + ${D}${sysconfdir}/systemd/system/basic.target.wants/edison-machine-id.service + +} diff --git a/meta-edison-distro/recipes-core/systemd/systemd_213.bb b/meta-edison-distro/recipes-core/systemd/systemd_213.bb new file mode 100644 index 0000000..003b33e --- /dev/null +++ b/meta-edison-distro/recipes-core/systemd/systemd_213.bb @@ -0,0 +1,351 @@ +SUMMARY = "System and service manager for Linux, replacing SysVinit" +HOMEPAGE = "http://www.freedesktop.org/wiki/Software/systemd" + +LICENSE = "GPLv2 & LGPLv2.1 & MIT" +LIC_FILES_CHKSUM = "file://LICENSE.GPL2;md5=751419260aa954499f7abaabaa882bbe \ + file://LICENSE.LGPL2.1;md5=4fbd65380cdd255951079008b364516c \ + file://LICENSE.MIT;md5=544799d0b492f119fa04641d1b8868ed" + +PROVIDES = "udev" + +PE = "1" + +DEPENDS = "kmod docbook-sgml-dtd-4.1-native intltool-native gperf-native acl readline dbus libcap libcgroup glib-2.0 qemu-native util-linux" +DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'libpam', '', d)}" + +SECTION = "base/shell" + +inherit gtk-doc useradd pkgconfig autotools perlnative update-rc.d update-alternatives qemu systemd ptest + +SRCREV = "c9679c652b3c31f2510e8805d81630680ebc7e95" + +PV = "213+git${SRCPV}" + +SRC_URI = "git://anongit.freedesktop.org/systemd/systemd;branch=master;protocol=git \ + file://binfmt-install.patch \ + file://systemd-pam-configure-check-uclibc.patch \ + file://systemd-pam-fix-execvpe.patch \ + file://systemd-pam-fix-fallocate.patch \ + file://systemd-pam-fix-mkostemp.patch \ + file://optional_secure_getenv.patch \ + file://0001-uClibc-doesn-t-implement-pwritev-preadv.patch \ + file://uclibc-sysinfo_h.patch \ + file://uclibc-get-physmem.patch \ + file://touchscreen.rules \ + file://00-create-volatile.conf \ + file://init \ + file://run-ptest \ + file://systemd-older-kernel.patch \ + " + +S = "${WORKDIR}/git" + +SRC_URI_append_libc-uclibc = "\ + file://systemd-pam-fix-getty-unit.patch \ + " +LDFLAGS_append_libc-uclibc = " -lrt" + +GTKDOC_DOCDIR = "${S}/docs/" + +PACKAGECONFIG ??= "xz" +# Sign the journal for anti-tampering +PACKAGECONFIG[gcrypt] = "--enable-gcrypt,--disable-gcrypt,libgcrypt" +# regardless of PACKAGECONFIG, libgcrypt is always required to expand +# the AM_PATH_LIBGCRYPT autoconf macro +DEPENDS += "libgcrypt" +# Compress the journal +PACKAGECONFIG[xz] = "--enable-xz,--disable-xz,xz" +PACKAGECONFIG[cryptsetup] = "--enable-libcryptsetup,--disable-libcryptsetup,cryptsetup" +PACKAGECONFIG[microhttpd] = "--enable-microhttpd,--disable-microhttpd,libmicrohttpd" + +CACHED_CONFIGUREVARS = "ac_cv_path_KILL=${base_bindir}/kill" + +# Helper variables to clarify locations. This mirrors the logic in systemd's +# build system. +rootprefix ?= "${base_prefix}" +rootlibdir ?= "${base_libdir}" +rootlibexecdir = "${rootprefix}/lib" + +# The gtk+ tools should get built as a separate recipe e.g. systemd-tools +EXTRA_OECONF = " --with-rootprefix=${rootprefix} \ + --with-rootlibdir=${rootlibdir} \ + ${@bb.utils.contains('DISTRO_FEATURES', 'pam', '--enable-pam', '--disable-pam', d)} \ + --disable-manpages \ + --disable-coredump \ + --disable-introspection \ + --disable-kdbus \ + --enable-split-usr \ + --without-python \ + --with-sysvrcnd-path=${sysconfdir} \ + --with-firmware-path=/lib/firmware \ + ac_cv_path_KILL=${base_bindir}/kill \ + " +# uclibc does not have NSS +EXTRA_OECONF_append_libc-uclibc = " --disable-myhostname " + +do_configure_prepend() { + export CPP="${HOST_PREFIX}cpp ${TOOLCHAIN_OPTIONS} ${HOST_CC_ARCH}" + export NM="${HOST_PREFIX}gcc-nm" + export AR="${HOST_PREFIX}gcc-ar" + export RANLIB="${HOST_PREFIX}gcc-ranlib" + export KMOD="${base_bindir}/kmod" + if [ -d ${S}/units.pre_sed ] ; then + cp -r ${S}/units.pre_sed ${S}/units + else + cp -r ${S}/units ${S}/units.pre_sed + fi + sed -i -e 's:=/root:=${ROOT_HOME}:g' ${S}/units/*.service* + sed -i '/ln --relative --help/d' ${S}/configure.ac + sed -i -e 's:\$(LN_S) --relative -f:lnr:g' ${S}/Makefile.am + sed -i -e 's:\$(LN_S) --relative:lnr:g' ${S}/Makefile.am +} + +do_install() { + autotools_do_install + install -d ${D}/${base_sbindir} + # Provided by a separate recipe + rm ${D}${systemd_unitdir}/system/serial-getty* -f + + # Provide support for initramfs + [ ! -e ${D}/init ] && ln -s ${rootlibexecdir}/systemd/systemd ${D}/init + [ ! -e ${D}/${base_sbindir}/udevd ] && ln -s ${rootlibexecdir}/systemd/systemd-udevd ${D}/${base_sbindir}/udevd + + # Create machine-id + # 20:12 < mezcalero> koen: you have three options: a) run systemd-machine-id-setup at install time, b) have / read-only and an empty file there (for stateless) and c) boot with / writable + touch ${D}${sysconfdir}/machine-id + + install -m 0644 ${WORKDIR}/*.rules ${D}${sysconfdir}/udev/rules.d/ + + install -m 0644 ${WORKDIR}/00-create-volatile.conf ${D}${sysconfdir}/tmpfiles.d/ + + if ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then + install -d ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/systemd-udevd + sed -i s%@UDEVD@%${rootlibexecdir}/systemd/systemd-udevd% ${D}${sysconfdir}/init.d/systemd-udevd + fi + + # Delete journal README, as log can be symlinked inside volatile. + rm -f ${D}/${localstatedir}/log/README +} + +do_install_ptest () { + install -d ${D}${PTEST_PATH}/test + cp -rf ${S}/test/* ${D}${PTEST_PATH}/test + install -m 0755 ${B}/test-udev ${D}${PTEST_PATH}/ + install -d ${D}${PTEST_PATH}/build-aux + cp ${S}/build-aux/test-driver ${D}${PTEST_PATH}/build-aux/ + cp -rf ${B}/rules ${D}${PTEST_PATH}/ + # This directory needs to be there for udev-test.pl to work. + install -d ${D}${libdir}/udev/rules.d + cp ${B}/Makefile ${D}${PTEST_PATH}/ + cp ${S}/test/sys.tar.xz ${D}${PTEST_PATH}/test + sed -i 's/"tree"/"ls"/' ${D}${PTEST_PATH}/test/udev-test.pl + sed -i 's#${S}#${PTEST_PATH}#g' ${D}${PTEST_PATH}/Makefile + sed -i 's#${B}#${PTEST_PATH}#g' ${D}${PTEST_PATH}/Makefile +} + +python populate_packages_prepend (){ + systemdlibdir = d.getVar("rootlibdir", True) + do_split_packages(d, systemdlibdir, '^lib(.*)\.so\.*', 'lib%s', 'Systemd %s library', extra_depends='', allow_links=True) +} +PACKAGES_DYNAMIC += "^lib(udev|gudev|systemd).*" + +PACKAGES =+ "${PN}-gui ${PN}-vconsole-setup ${PN}-initramfs ${PN}-analyze ${PN}-kernel-install \ + ${PN}-rpm-macros ${PN}-binfmt ${PN}-pam ${PN}-zsh" + +SYSTEMD_PACKAGES = "${PN}-binfmt" +SYSTEMD_SERVICE_${PN}-binfmt = "systemd-binfmt.service" + +USERADD_PACKAGES = "${PN}" +USERADD_PARAM_${PN} += "--system systemd-journal-gateway;--system systemd-timesync" +GROUPADD_PARAM_${PN} = "-r lock; -r systemd-journal" + +FILES_${PN}-analyze = "${bindir}/systemd-analyze" + +FILES_${PN}-initramfs = "/init" +RDEPENDS_${PN}-initramfs = "${PN}" + +# The test cases need perl and bash to run correctly. +RDEPENDS_${PN}-ptest += "perl bash" +FILES_${PN}-ptest += "${libdir}/udev/rules.d" + +FILES_${PN}-dbg += "${libdir}/systemd/ptest/.debug" + +FILES_${PN}-gui = "${bindir}/systemadm" + +FILES_${PN}-vconsole-setup = "${rootlibexecdir}/systemd/systemd-vconsole-setup \ + ${systemd_unitdir}/system/systemd-vconsole-setup.service \ + ${systemd_unitdir}/system/sysinit.target.wants/systemd-vconsole-setup.service" + +FILES_${PN}-kernel-install = "${bindir}/kernel-install \ + ${sysconfdir}/kernel/ \ + ${exec_prefix}/lib/kernel \ + " +FILES_${PN}-rpm-macros = "${exec_prefix}/lib/rpm \ + " + +FILES_${PN}-zsh = "${datadir}/zsh/site-functions" + +FILES_${PN}-binfmt = "${sysconfdir}/binfmt.d/ \ + ${exec_prefix}/lib/binfmt.d \ + ${rootlibexecdir}/systemd/systemd-binfmt \ + ${systemd_unitdir}/system/proc-sys-fs-binfmt_misc.* \ + ${systemd_unitdir}/system/systemd-binfmt.service" +RRECOMMENDS_${PN}-binfmt = "kernel-module-binfmt-misc" + +RRECOMMENDS_${PN}-vconsole-setup = "kbd kbd-consolefonts" + +CONFFILES_${PN} = "${sysconfdir}/systemd/journald.conf \ + ${sysconfdir}/systemd/logind.conf \ + ${sysconfdir}/systemd/system.conf \ + ${sysconfdir}/systemd/user.conf" + +FILES_${PN} = " ${base_bindir}/* \ + ${datadir}/bash-completion \ + ${datadir}/dbus-1/services \ + ${datadir}/dbus-1/system-services \ + ${datadir}/polkit-1 \ + ${datadir}/${BPN} \ + ${sysconfdir}/bash_completion.d/ \ + ${sysconfdir}/dbus-1/ \ + ${sysconfdir}/machine-id \ + ${sysconfdir}/modules-load.d/ \ + ${sysconfdir}/sysctl.d/ \ + ${sysconfdir}/systemd/ \ + ${sysconfdir}/tmpfiles.d/ \ + ${sysconfdir}/xdg/ \ + ${sysconfdir}/init.d/README \ + ${rootlibexecdir}/systemd/* \ + ${systemd_unitdir}/* \ + ${base_libdir}/security/*.so \ + ${libdir}/libnss_myhostname.so.2 \ + /cgroup \ + ${bindir}/systemd* \ + ${bindir}/busctl \ + ${bindir}/localectl \ + ${bindir}/hostnamectl \ + ${bindir}/timedatectl \ + ${bindir}/bootctl \ + ${bindir}/kernel-install \ + ${exec_prefix}/lib/tmpfiles.d/*.conf \ + ${exec_prefix}/lib/systemd \ + ${exec_prefix}/lib/modules-load.d \ + ${exec_prefix}/lib/sysctl.d \ + ${localstatedir} \ + /lib/udev/rules.d/70-uaccess.rules \ + /lib/udev/rules.d/71-seat.rules \ + /lib/udev/rules.d/73-seat-late.rules \ + /lib/udev/rules.d/99-systemd.rules \ + ${@bb.utils.contains('DISTRO_FEATURES', 'pam', '${sysconfdir}/pam.d', '', d)} \ + " + +FILES_${PN}-dbg += "${rootlibdir}/.debug ${systemd_unitdir}/.debug ${systemd_unitdir}/*/.debug ${base_libdir}/security/.debug/" +FILES_${PN}-dev += "${base_libdir}/security/*.la ${datadir}/dbus-1/interfaces/ ${sysconfdir}/rpm/macros.systemd" + +RDEPENDS_${PN} += "kmod dbus util-linux-mount udev (= ${EXTENDPKGV})" + +RRECOMMENDS_${PN} += "systemd-serialgetty systemd-compat-units \ + util-linux-agetty \ + util-linux-fsck e2fsprogs-e2fsck \ + kernel-module-autofs4 kernel-module-unix kernel-module-ipv6 \ +" + +PACKAGES =+ "udev-dbg udev udev-hwdb" + +FILES_udev-dbg += "/lib/udev/.debug" + +RPROVIDES_udev = "hotplug" +RRECOMMENDS_udev += "udev-hwdb" + +FILES_udev += "${base_sbindir}/udevd \ + ${rootlibexecdir}/systemd/systemd-udevd \ + ${rootlibexecdir}/udev/accelerometer \ + ${rootlibexecdir}/udev/ata_id \ + ${rootlibexecdir}/udev/cdrom_id \ + ${rootlibexecdir}/udev/collect \ + ${rootlibexecdir}/udev/findkeyboards \ + ${rootlibexecdir}/udev/keyboard-force-release.sh \ + ${rootlibexecdir}/udev/keymap \ + ${rootlibexecdir}/udev/mtd_probe \ + ${rootlibexecdir}/udev/scsi_id \ + ${rootlibexecdir}/udev/v4l_id \ + ${rootlibexecdir}/udev/keymaps \ + ${rootlibexecdir}/udev/rules.d/4*.rules \ + ${rootlibexecdir}/udev/rules.d/5*.rules \ + ${rootlibexecdir}/udev/rules.d/6*.rules \ + ${rootlibexecdir}/udev/rules.d/70-power-switch.rules \ + ${rootlibexecdir}/udev/rules.d/75*.rules \ + ${rootlibexecdir}/udev/rules.d/78*.rules \ + ${rootlibexecdir}/udev/rules.d/8*.rules \ + ${rootlibexecdir}/udev/rules.d/95*.rules \ + ${sysconfdir}/udev \ + ${sysconfdir}/init.d/systemd-udevd \ + ${systemd_unitdir}/system/*udev* \ + ${systemd_unitdir}/system/*.wants/*udev* \ + ${base_bindir}/udevadm \ + ${datadir}/bash-completion/completions/udevadm \ + " + +FILES_udev-hwdb = "${rootlibexecdir}/udev/hwdb.d" + +INITSCRIPT_PACKAGES = "udev" +INITSCRIPT_NAME_udev = "systemd-udevd" +INITSCRIPT_PARAMS_udev = "start 03 S ." + +python __anonymous() { + if not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d): + d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1") +} + +# TODO: +# u-a for runlevel and telinit + +ALTERNATIVE_${PN} = "init halt reboot shutdown poweroff runlevel" + +ALTERNATIVE_TARGET[init] = "${rootlibexecdir}/systemd/systemd" +ALTERNATIVE_LINK_NAME[init] = "${base_sbindir}/init" +ALTERNATIVE_PRIORITY[init] ?= "300" + +ALTERNATIVE_TARGET[halt] = "${base_bindir}/systemctl" +ALTERNATIVE_LINK_NAME[halt] = "${base_sbindir}/halt" +ALTERNATIVE_PRIORITY[halt] ?= "300" + +ALTERNATIVE_TARGET[reboot] = "${base_bindir}/systemctl" +ALTERNATIVE_LINK_NAME[reboot] = "${base_sbindir}/reboot" +ALTERNATIVE_PRIORITY[reboot] ?= "300" + +ALTERNATIVE_TARGET[shutdown] = "${base_bindir}/systemctl" +ALTERNATIVE_LINK_NAME[shutdown] = "${base_sbindir}/shutdown" +ALTERNATIVE_PRIORITY[shutdown] ?= "300" + +ALTERNATIVE_TARGET[poweroff] = "${base_bindir}/systemctl" +ALTERNATIVE_LINK_NAME[poweroff] = "${base_sbindir}/poweroff" +ALTERNATIVE_PRIORITY[poweroff] ?= "300" + +ALTERNATIVE_TARGET[runlevel] = "${base_bindir}/systemctl" +ALTERNATIVE_LINK_NAME[runlevel] = "${base_sbindir}/runlevel" +ALTERNATIVE_PRIORITY[runlevel] ?= "300" + +pkg_postinst_udev-hwdb () { + if test -n "$D"; then + ${@qemu_run_binary(d, '$D', '${base_bindir}/udevadm')} hwdb --update \ + --root $D + else + udevadm hwdb --update + fi +} + +pkg_prerm_udev-hwdb () { + if test -n "$D"; then + exit 1 + fi + + rm -f ${sysconfdir}/udev/hwdb.bin +} + +# As this recipe builds udev, respect systemd being in DISTRO_FEATURES so +# that we don't build both udev and systemd in world builds. +python () { + if not bb.utils.contains ('DISTRO_FEATURES', 'systemd', True, False, d): + raise bb.parse.SkipPackage("'systemd' not in DISTRO_FEATURES") +} |