From 9239a4ea343b4bb0411e109f7aa09e986af8bd18 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Tue, 15 Dec 2015 12:10:54 -0800 Subject: [PATCH] Jessie support. --- .../rootfs/jessie/common/amd64-packages.yml | 13 +++ .../rootfs/jessie/common/common-packages.yml | 70 ++++++++++++++ .../rootfs/jessie/common/overlay/etc/adjtime | 1 + .../jessie/common/overlay/etc/filesystems | 6 ++ .../jessie/common/overlay/etc/inetd.conf | 3 + .../jessie/common/overlay/etc/init.d/initdev | 26 ++++++ .../etc/profile.d/onl-platform-current.sh | 7 ++ .../jessie/common/overlay/etc/rssh.conf | 3 + .../overlay/etc/udev/rules.d/60-block.rules | 1 + .../overlay/etc/udev/rules.d/60-net.rules | 1 + .../jessie/common/overlay/sbin/initblockdev | 62 +++++++++++++ .../rootfs/jessie/common/overlay/sbin/pgetty | 23 +++++ .../jessie/common/overlay/sbin/watchdir | 71 ++++++++++++++ .../rootfs/jessie/common/powerpc-packages.yml | 10 ++ .../any/rootfs/jessie/standard/standard.yml | 93 +++++++++++++++++++ 15 files changed, 390 insertions(+) create mode 100644 builds/any/rootfs/jessie/common/amd64-packages.yml create mode 100644 builds/any/rootfs/jessie/common/common-packages.yml create mode 100644 builds/any/rootfs/jessie/common/overlay/etc/adjtime create mode 100644 builds/any/rootfs/jessie/common/overlay/etc/filesystems create mode 100644 builds/any/rootfs/jessie/common/overlay/etc/inetd.conf create mode 100755 builds/any/rootfs/jessie/common/overlay/etc/init.d/initdev create mode 100644 builds/any/rootfs/jessie/common/overlay/etc/profile.d/onl-platform-current.sh create mode 100644 builds/any/rootfs/jessie/common/overlay/etc/rssh.conf create mode 100644 builds/any/rootfs/jessie/common/overlay/etc/udev/rules.d/60-block.rules create mode 100644 builds/any/rootfs/jessie/common/overlay/etc/udev/rules.d/60-net.rules create mode 100755 builds/any/rootfs/jessie/common/overlay/sbin/initblockdev create mode 100755 builds/any/rootfs/jessie/common/overlay/sbin/pgetty create mode 100755 builds/any/rootfs/jessie/common/overlay/sbin/watchdir create mode 100644 builds/any/rootfs/jessie/common/powerpc-packages.yml create mode 100644 builds/any/rootfs/jessie/standard/standard.yml diff --git a/builds/any/rootfs/jessie/common/amd64-packages.yml b/builds/any/rootfs/jessie/common/amd64-packages.yml new file mode 100644 index 00000000..f06a44d0 --- /dev/null +++ b/builds/any/rootfs/jessie/common/amd64-packages.yml @@ -0,0 +1,13 @@ +############################################################ +# +# Common packages for all amd64 systems. +# +############################################################ +- dmidecode +- parted +- smartmontools +- grub2 + + + + diff --git a/builds/any/rootfs/jessie/common/common-packages.yml b/builds/any/rootfs/jessie/common/common-packages.yml new file mode 100644 index 00000000..ca9869b3 --- /dev/null +++ b/builds/any/rootfs/jessie/common/common-packages.yml @@ -0,0 +1,70 @@ +############################################################ +# +# Common Release Packages for all systems. +# +############################################################ +- base-files +- sysvinit-core +- locales +- python +- apt +- apt-utils +- procps +- net-tools +- iputils-ping +- less +- sudo +- openssh-server +- iproute +- resolvconf +- vim-tiny +- zile +- nano +- lsof +- mingetty +- traceroute +- realpath +- rsyslog +- nfs-common +- netbase +- bsdmainutils +- ifupdown +- psmisc +- make +- python-cherrypy3 +- python-tz +- scapy +- python-pypcap +- snmpd +- lm-sensors +- fancontrol +- pciutils +- usbutils +- mtd-utils +- kexec-tools +- i2c-tools +- module-init-tools +- isc-dhcp-client +- ntp +- wget +- ethtool +- localepurge +- telnetd +- python-pyinotify +- cpio +- util-linux +- dosfstools +- rssh +- u-boot-tools +- ntpdate +- onlp +- parted +- watchdog +- netplug +- binutils +- file +- smartmontools +- realpath +- iptables +- onl-faultd +- onl-loader-initscripts diff --git a/builds/any/rootfs/jessie/common/overlay/etc/adjtime b/builds/any/rootfs/jessie/common/overlay/etc/adjtime new file mode 100644 index 00000000..7481b115 --- /dev/null +++ b/builds/any/rootfs/jessie/common/overlay/etc/adjtime @@ -0,0 +1 @@ +0.0 0 0.0 diff --git a/builds/any/rootfs/jessie/common/overlay/etc/filesystems b/builds/any/rootfs/jessie/common/overlay/etc/filesystems new file mode 100644 index 00000000..01350bea --- /dev/null +++ b/builds/any/rootfs/jessie/common/overlay/etc/filesystems @@ -0,0 +1,6 @@ +jffs2 +ubifs +vfat +ext4 +ext3 +ext2 diff --git a/builds/any/rootfs/jessie/common/overlay/etc/inetd.conf b/builds/any/rootfs/jessie/common/overlay/etc/inetd.conf new file mode 100644 index 00000000..367f8d08 --- /dev/null +++ b/builds/any/rootfs/jessie/common/overlay/etc/inetd.conf @@ -0,0 +1,3 @@ +telnet stream tcp nowait telnetd /usr/sbin/tcpd /usr/sbin/in.telnetd +qotd stream tcp nowait telnetd /usr/sbin/tcpd /sbin/versiond + diff --git a/builds/any/rootfs/jessie/common/overlay/etc/init.d/initdev b/builds/any/rootfs/jessie/common/overlay/etc/init.d/initdev new file mode 100755 index 00000000..df9dd898 --- /dev/null +++ b/builds/any/rootfs/jessie/common/overlay/etc/init.d/initdev @@ -0,0 +1,26 @@ +#!/bin/sh + +### BEGIN INIT INFO +# Provides: initdev +# Required-Start: +# Required-Stop: +# Default-Start: S +# Default-Stop: +# Short-Description: Set up block and net devices +### END INIT INFO + +. /lib/lsb/init-functions + +log_action_begin_msg "Setting up block and net devices" + +ln -snf /proc/mounts /etc/mtab + +( cd /sys/class/block; for d in *; do /sbin/initblockdev $d add; done ) +if [ -d /sys/class/ubi ]; then + ( cd /sys/class/ubi; for d in *; do /sbin/initblockdev $d add; done ) +fi +( cd /sys/class/net; for d in *; do /sbin/initnetdev $d add; done ) + +initmounts + +log_action_end_msg 0 diff --git a/builds/any/rootfs/jessie/common/overlay/etc/profile.d/onl-platform-current.sh b/builds/any/rootfs/jessie/common/overlay/etc/profile.d/onl-platform-current.sh new file mode 100644 index 00000000..5237bbb8 --- /dev/null +++ b/builds/any/rootfs/jessie/common/overlay/etc/profile.d/onl-platform-current.sh @@ -0,0 +1,7 @@ +############################################################ +# +# Add platform specific directories to path. +# +############################################################ +dir=/lib/platform-config/current/onl +export PATH="$PATH:$dir/bin:$dir/sbin:$dir/lib/bin:$dir/lib/sbin" diff --git a/builds/any/rootfs/jessie/common/overlay/etc/rssh.conf b/builds/any/rootfs/jessie/common/overlay/etc/rssh.conf new file mode 100644 index 00000000..37438ead --- /dev/null +++ b/builds/any/rootfs/jessie/common/overlay/etc/rssh.conf @@ -0,0 +1,3 @@ +logfacility = LOG_USER +allowsftp +umask = 022 diff --git a/builds/any/rootfs/jessie/common/overlay/etc/udev/rules.d/60-block.rules b/builds/any/rootfs/jessie/common/overlay/etc/udev/rules.d/60-block.rules new file mode 100644 index 00000000..f2345a37 --- /dev/null +++ b/builds/any/rootfs/jessie/common/overlay/etc/udev/rules.d/60-block.rules @@ -0,0 +1 @@ +SUBSYSTEM=="block", RUN+="/sbin/initblockdev $kernel $env{ACTION}" diff --git a/builds/any/rootfs/jessie/common/overlay/etc/udev/rules.d/60-net.rules b/builds/any/rootfs/jessie/common/overlay/etc/udev/rules.d/60-net.rules new file mode 100644 index 00000000..627e65e4 --- /dev/null +++ b/builds/any/rootfs/jessie/common/overlay/etc/udev/rules.d/60-net.rules @@ -0,0 +1 @@ +SUBSYSTEM=="net", RUN+="/sbin/initnetdev $kernel $env{ACTION}" diff --git a/builds/any/rootfs/jessie/common/overlay/sbin/initblockdev b/builds/any/rootfs/jessie/common/overlay/sbin/initblockdev new file mode 100755 index 00000000..e4b7cc3d --- /dev/null +++ b/builds/any/rootfs/jessie/common/overlay/sbin/initblockdev @@ -0,0 +1,62 @@ +#!/bin/bash +set -e +exec 9<$0 +flock -x 9 +case $2 in + add) + eval $(echo $1 | sed "s#^\(mmcblk[0-9]*\|ubi[0-9]*_[0-9]*\|mtdblock[0-9]*\|[a-z]*\)\(p[0-9]*\|[0-9]*\).*#dev='\1' part='\2'#") + if [ -e /etc/onl/recover ]; then + recover=$(cat /etc/onl/recover) + fi + devid= + if [ -e /sys/class/ubi/${dev}/device ]; then + eval $(realpath /sys/class/ubi/${dev}/device | sed "s#/sys/devices/\(.*\)#devid='\1'#") + fi + if [ -e /sys/class/block/${dev}/device ]; then + eval $(realpath /sys/class/block/${dev}/device | sed "s#/sys/devices/\(.*\)#devid='\1'#") + fi + while read i n; do + expr match "$i" "#" >/dev/null && continue || : + [ -n "${devid}" ] && expr match "${devid}" "$i" >/dev/null && mount=/mnt/$n && break || : + expr match "@${dev}" "$i" >/dev/null && mount=/mnt/$n && break || : + done /dev/null)" = "070701" ]; then + mount=${mount}-recover + else + mkdir -p ${mount} + [ $(stat -c %D ${mount}) = $(stat -c %D /mnt) ] + if [ "$(dd if=/dev/${dev}${part} bs=1 skip=82 count=5 2>/dev/null)" = "FAT32" ] \ + || [ "$(dd if=/dev/${dev}${part} bs=1 skip=54 count=5 2>/dev/null)" = "FAT16" ]; then + if [ ! -e /etc/onl/kdump ]; then + if [ "$recover" = "fsck" ]; then + # Try to repair FAT filesystem automatically to prevent further + # damage (but skip it in kdump to save time and memory) + if dosfsck -a /dev/${dev}${part} >/dev/null 2>&1; then + : + else + dosfsck -n /dev/${dev}${part} >/dev/null 2>&1 + fi + else + dosfsck -n /dev/${dev}${part} >/dev/null 2>&1 + fi + fi + mount -o flush,dirsync,noatime,umask=0007 /dev/${dev}${part} ${mount} 2>/dev/null + else + mount -o noatime /dev/${dev}${part} ${mount} 2>/dev/null + fi + fi + echo -e "devid='${devid}'\ndev='${dev}'\npart='${part}'" >${mount}.conf + ;; + remove) + mtab=$(mktemp /tmp/tmp.XXXXXX) + cp /proc/mounts ${mtab} + while read dev mount x; do + if [ /dev/$1 = "${dev}" ]; then + rm -f ${mount}.conf + umount -l ${mount} 2>/dev/null || : + fi + done <${mtab} + rm -f ${mtab} + ;; +esac diff --git a/builds/any/rootfs/jessie/common/overlay/sbin/pgetty b/builds/any/rootfs/jessie/common/overlay/sbin/pgetty new file mode 100755 index 00000000..01ed10dc --- /dev/null +++ b/builds/any/rootfs/jessie/common/overlay/sbin/pgetty @@ -0,0 +1,23 @@ +#!/bin/sh + +t=/dev/$1 +# if $1 is not set, use linux cmdline console as default tty +[ -z "$1" ] && { + tty=$(/bin/sed 's/.*console=\([^,]*\).*/\1/' /proc/cmdline) + t=/dev/$tty +} + +# Reset the console tty to standard settings +/bin/stty -F $t sane pass8 -ixon -cstopb clocal + +# Kill any processes with the console tty open before starting a new +# login session (login tries to do this, but vhangup() spares processes +# that ignore SIGHUP) +#/usr/bin/lsof -p ^$$ -t $t 0<&- 1>&- 2>&- | /usr/bin/xargs -r /bin/kill -9 + +# Flush tty input and output queues +#/sbin/flushtty <$t + +# We use mingetty instead of agetty, as the latter messes up the tty +# settings if it receives junk characters at the wrong speed +exec /sbin/mingetty --noclear $t diff --git a/builds/any/rootfs/jessie/common/overlay/sbin/watchdir b/builds/any/rootfs/jessie/common/overlay/sbin/watchdir new file mode 100755 index 00000000..3ff32aa7 --- /dev/null +++ b/builds/any/rootfs/jessie/common/overlay/sbin/watchdir @@ -0,0 +1,71 @@ +#!/usr/bin/python +############################################################ +# +# +# Copyright 2013, 2014 Big Switch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# watchdir +# +############################################################ +import optparse, os.path, sys +import pyinotify + +#pyinotify.log.setLevel(pyinotify.logging.DEBUG) + +op = optparse.OptionParser( usage="%prog [OPTIONS] command") +op.add_option("-w", "--watchdir", action="append", + help="monitor watchdir for changes (may be used multiple times)") +op.add_option("--period", action="store", type="float", + help="run command at most every period sec (default=%default)") +op.add_option("-d", "--daemon", action="store_true", + help="run in background") +op.add_option("--logfile", action="store", + help="send output to logfile when running in background") +op.add_option("--pidfile", action="store", + help="write pid to pidfile when running in background") +op.set_defaults(period=0, logfile="/dev/stdout", pidfile=False) +opts, args = op.parse_args() + +if not opts.watchdir: + op.error("need at least one watchdir") + +os.close(0) +os.open("/dev/null", os.O_RDONLY) + +wm = pyinotify.WatchManager() +n = pyinotify.Notifier(wm, read_freq=opts.period) +def handle(event): + dir = None + for d in opts.watchdir: + if os.path.commonprefix([d, event.pathname]) == d: + dir = d + sys.stdout.write("%s: %s %s\n" % (dir, event.pathname, event)) + sys.stdout.flush() + if args: + os.spawnvp(os.P_WAIT, args[0], + args + [dir, event.pathname, event.maskname]) +wm.add_watch( + opts.watchdir, + pyinotify.IN_ATTRIB | pyinotify.IN_CREATE | pyinotify.IN_DELETE | + pyinotify.IN_MODIFY | pyinotify.IN_MOVED_FROM | pyinotify.IN_MOVED_TO, + handle, + rec=True, + auto_add=True) +n.loop(daemonize=opts.daemon, stdout=opts.logfile, stderr=opts.logfile, + pid_file=opts.pidfile) diff --git a/builds/any/rootfs/jessie/common/powerpc-packages.yml b/builds/any/rootfs/jessie/common/powerpc-packages.yml new file mode 100644 index 00000000..618f3581 --- /dev/null +++ b/builds/any/rootfs/jessie/common/powerpc-packages.yml @@ -0,0 +1,10 @@ +############################################################ +# +# Common packages for all PowerPC systems. +# +############################################################ +- u-boot-tools + + + + diff --git a/builds/any/rootfs/jessie/standard/standard.yml b/builds/any/rootfs/jessie/standard/standard.yml new file mode 100644 index 00000000..7621f3c4 --- /dev/null +++ b/builds/any/rootfs/jessie/standard/standard.yml @@ -0,0 +1,93 @@ +############################################################ +# +# Standard ONL Debian 8 Root Filesystem Configuration. +# +# Requires: +# ARCH, PLATFORM_LIST +# +# +############################################################ +Packages: &Packages + - !include $ONL/builds/any/rootfs/$ONL_DEBIAN_SUITE/common/common-packages.yml + - !include $ONL/builds/any/rootfs/$ONL_DEBIAN_SUITE/common/${ARCH}-packages.yml + - !script $ONL/tools/onl-platform-pkgs.py ${PLATFORM_LIST} + +Multistrap: + General: + arch: ${ARCH} + cleanup: true + noauth: true + explicitsuite: false + unpack: true + debootstrap: Debian-Local Local-All Local-Arch ONL + aptsources: Debian ONL + + Debian: + packages: *Packages + source: http://${DEBIAN_MIRROR} + suite: ${ONL_DEBIAN_SUITE} + keyring: debian-archive-keyring + omitdebsrc: true + + Debian-Local: + packages: *Packages + source: http://${APT_CACHE}${DEBIAN_MIRROR} + suite: ${ONL_DEBIAN_SUITE} + keyring: debian-archive-keyring + omitdebsrc: true + + ONL: + packages: *Packages + source: http://apt.opennetlinux.org/debian + suite: unstable + omitdebsrc: true + + Local-All: + source: ${ONL}/REPO/${ONL_DEBIAN_SUITE}/packages/all + omitdebsrc: true + + Local-Arch: + source: ${ONL}/REPO/${ONL_DEBIAN_SUITE}/packages/${ARCH} + omitdebsrc: true + +Configure: + overlays: + - ${ONL}/builds/any/rootfs/${ONL_DEBIAN_SUITE}/common/overlay + + update-rc.d: + - 'initdev defaults' + - 'onl-platform-baseconf defaults' + - 'faultd defaults' + - 'snmpd remove' + - 'ssh defaults' + - 'openbsd-inetd remove' + - 'ntp remove' + - 'nfs-common remove' + - 'rpcbind remove' + - 'motd remove' + - 'mountall-bootclean.sh remove' + - 'mountall.sh remove' + - 'checkfs.sh remove' + - 'mtab.sh remove' + - 'checkroot-bootclean.sh remove' + - 'checkroot.sh remove' + - 'mountnfs-bootclean.sh remove' + - 'mountnfs.sh remove' + - 'lm-sensors remove' + - 'netplug defaults' + - 'watchdog defaults' + - 'wd_keepalive remove' + + options: + clean: True + securetty: False + ttys: False + console: True + + users: + root: + password: onl + + manifest: + version: $ONL/make/version-onl.json + platforms: $PLATFORM_LIST