diff --git a/builds/amd64/installer/legacy/builds/amd64-installer.sh b/builds/amd64/installer/legacy/builds/amd64-installer.sh index 0f12a5a0..86accc8f 100644 --- a/builds/amd64/installer/legacy/builds/amd64-installer.sh +++ b/builds/amd64/installer/legacy/builds/amd64-installer.sh @@ -130,6 +130,9 @@ do_handle_disk() return 0 } +ONL_CONFIG_TARBALL=/tmp/onl_config.tgz +ONL_CONFIG_MOUNTPOINT=/mnt/onl_config_partition + do_handle_partitions() { local part start end sz fs label flags @@ -143,8 +146,16 @@ do_handle_partitions() installer_say "Examining $DEV part $part" - case "$label" in + ONL-CONFIG) + installer_say "Preserving the contents of the existing ONL-CONFIG partition..." + rm -rf $ONL_CONFIG_MOUNTPOINT + mkdir -p $ONL_CONFIG_MOUNTPOINT + mount $DEV$part $ONL_CONFIG_MOUNTPOINT + tar -C $ONL_CONFIG_MOUNTPOINT -cvzf $ONL_CONFIG_TARBALL . + umount $ONL_CONFIG_MOUNTPOINT + parted $DEV rm $part || return 1 + ;; ONIE-BOOT|GRUB-BOOT|*-DIAG) installer_say "Partition $DEV$part: $label: Preserving..." ;; @@ -184,10 +195,15 @@ partition_gpt() { local start end part - installer_say "Creating 128MB for Open Network Linux boot" start=$1; shift + + ############################################################ + # + # ONL Boot Partition. + # + ############################################################ + installer_say "Creating 128MB for ONL Boot partition..." end=$(( $start + 128 )) - echo "start=$start end=$end" parted -s $DEV unit mb mkpart "ONL-BOOT" ext4 ${start} ${end} || return 1 if ! part=$(get_part_number $DEV "ONL-BOOT"); then @@ -198,23 +214,59 @@ partition_gpt() mkfs.ext4 -L "ONL-BOOT" ${DEV}${part} start=$(( $end + 1 )) - installer_say "Creating /mnt/flash" - end=$(( $start + 128 )) - parted -s $DEV unit mb mkpart "FLASH" fat32 ${start} ${end} || return 1 - if ! part=$(get_part_number $DEV "FLASH"); then + + ############################################################ + # + # ONL Configuration Partition. + # + ############################################################ + installer_say "Creating 128MB ONL Configuration partition..." + end=$(( $start + 128 )) + parted -s $DEV unit mb mkpart "ONL-CONFIG" ext4 ${start} ${end} || return 1 + if ! part=$(get_part_number $DEV "ONL-CONFIG"); then return 1 fi - mkfs.vfat -n "FLASH" ${DEV}${part} - + mkfs.ext4 -L "ONL-CONFIG" ${DEV}${part} start=$(( $end + 1 )) - installer_say "Allocating remainder for /mnt/flash2" - parted -s $DEV unit mb mkpart "FLASH2" fat32 ${start} "100%" || return 1 - if ! part=$(get_part_number $DEV "FLASH2"); then + if [ -f $ONL_CONFIG_TARBALL ]; then + installer_say "Restoring the contents of the ONL-CONFIG partition..." + rm -rf $ONL_CONFIG_MOUNTPOINT + mkdir -p $ONL_CONFIG_MOUNTPOINT + mount $DEV$part $ONL_CONFIG_MOUNTPOINT + tar -C $ONL_CONFIG_MOUNTPOINT -xvzf $ONL_CONFIG_TARBALL + umount $ONL_CONFIG_MOUNTPOINT + fi + + ############################################################ + # + # ONL Image Partition. + # + ############################################################ + installer_say "Creating 1G ONL Image partition..." + end=$(( $start + 1024 )) + + parted -s $DEV unit mb mkpart "ONL-IMAGES" ext4 ${start} ${end} || return 1 + if ! part=$(get_part_number $DEV "ONL-IMAGES"); then return 1 fi - mkfs.vfat -n "FLASH2" ${DEV}${part} + mkfs.ext4 -L "ONL-IMAGES" ${DEV}${part} + start=$(( $end + 1 )) + + + + ############################################################ + # + # ONL Root Partition. + # + ############################################################ + installer_say "Creating the ONL Data partition..." + parted -s $DEV unit mb mkpart "ONL-DATA" ext4 ${start} "100%" || return 1 + if ! part=$(get_part_number $DEV "ONL-DATA"); then + return 1 + fi + mkfs.ext4 -L "ONL-DATA" ${DEV}${part} return 0 } @@ -231,8 +283,8 @@ installer_standard_gpt_install() mkdir "$workdir/mnt" if [ -f "${installer_dir}/boot-config" ]; then - installer_say "Installing boot-config" - mount LABEL="FLASH" "$workdir/mnt" + installer_say "Installing boot-config..." + mount LABEL="ONL-BOOT" "$workdir/mnt" cp "${installer_dir}/boot-config" "$workdir/mnt/boot-config" umount "$workdir/mnt" fi @@ -244,7 +296,7 @@ installer_standard_gpt_install() SWIDST="$(basename ${SWISRC})" fi installer_say "Installing Open Network Linux Software Image (${SWIDST})..." - mount LABEL="FLASH2" "$workdir/mnt" + mount LABEL="ONL-IMAGES" "$workdir/mnt" cp "${SWISRC}" "$workdir/mnt/${SWIDST}" umount "$workdir/mnt" fi diff --git a/builds/amd64/installer/legacy/builds/boot-config b/builds/amd64/installer/legacy/builds/boot-config index dfefb733..40fb0d31 100644 --- a/builds/amd64/installer/legacy/builds/boot-config +++ b/builds/amd64/installer/legacy/builds/boot-config @@ -1,4 +1,4 @@ NETDEV=ma1 NETAUTO=dhcp BOOTMODE=SWI -SWI=flash2::latest +SWI=images::latest diff --git a/builds/any/installer/legacy/fit/builds/boot-config b/builds/any/installer/legacy/fit/builds/boot-config index dfefb733..40fb0d31 100644 --- a/builds/any/installer/legacy/fit/builds/boot-config +++ b/builds/any/installer/legacy/fit/builds/boot-config @@ -1,4 +1,4 @@ NETDEV=ma1 NETAUTO=dhcp BOOTMODE=SWI -SWI=flash2::latest +SWI=images::latest diff --git a/builds/any/installer/legacy/fit/builds/fit-install-lib b/builds/any/installer/legacy/fit/builds/fit-install-lib index 504cc0bc..11c89540 100644 --- a/builds/any/installer/legacy/fit/builds/fit-install-lib +++ b/builds/any/installer/legacy/fit/builds/fit-install-lib @@ -1,3 +1,4 @@ +# -*- sh -*- ###################################################################### # # lib.sh @@ -122,11 +123,12 @@ installer_partition_format() { local blockdev=$1 local partno=$2 local mkfs=$3 + local options=$4 local partition="$1$2" installer_say "Format ${partition}..." installer_create_device_file ${blockdev} ${partno} - "${mkfs}" "${installer_df}" + "${mkfs}" ${options} "${installer_df}" installer_say "Format ${partition} complete." rm "${installer_df}" } @@ -158,26 +160,60 @@ installer_umount_blockdev() { # installer_blockdev_format # # The block device name. -# The size of the first partition. -# The size of the second partition. -# [Optional] The size of the third partition. -# If p3size is unset, the remainder of the device will be used -# for the third partition. +# The size of the boot partition. +# The size of the config partition. +# The size of the image partition. +# [Optional] The size of the data partition. +# If p4size is unset, the remainder of the device will be used +# for the data partition. # ############################################################ +ONL_CONFIG_TARBALL=/tmp/onl_config.tgz +ONL_CONFIG_MOUNTPOINT=/mnt/onl_config_partition installer_blockdev_format() { local blockdev=$1 local partition1size=$2 local partition2size=$3 local partition3size=$4 + local partition4size=$5 + + onl_config_partition=$(blkid | grep ONL-CONFIG | awk '{print $1}' | tr -d ':') + + # + # If an ONL-CONFIG partition exists, we need to save and restore its contents. + # + if [ -n "$onl_config_partition" ]; then + installer_say "Preserving the contents of the existing ONL-CONFIG partition..." + rm -rf $ONL_CONFIG_MOUNTPOINT + mkdir -p $ONL_CONFIG_MOUNTPOINT + echo mount "$onl_config_partition" $ONL_CONFIG_MOUNTPOINT + mount "$onl_config_partition" $ONL_CONFIG_MOUNTPOINT + tar -C $ONL_CONFIG_MOUNTPOINT -cvzf $ONL_CONFIG_TARBALL . + umount $ONL_CONFIG_MOUNTPOINT + fi + + installer_umount_blockdev ${blockdev} - installer_say "Formatting ${blockdev} as ${partition1size}:${partition2size}:${partition3size}." - echo -e "o\nn\np\n1\n\n+${partition1size}\nn\np\n2\n\n+${partition2size}\nn\np\n3\n\n${partition3size}\np\nw\n" | fdisk /dev/${blockdev} - installer_partition_format ${blockdev} 1 mkdosfs - installer_partition_format ${blockdev} 2 mkdosfs - installer_partition_format ${blockdev} 3 mkdosfs + installer_say "Formatting ${blockdev} as ${partition1size}:${partition2size}:${partition3size}:${partition4size}." + echo -e "o\nn\np\n1\n\n+${partition1size}\nn\np\n2\n\n+${partition2size}\nn\np\n3\n\n+${partition3size}\nn\np\n4\n\n${partition4size}\np\nw\n" | fdisk /dev/${blockdev} + installer_partition_format ${blockdev} 1 mkfs.ext2 "-L ONL-BOOT" + installer_partition_format ${blockdev} 2 mkfs.ext2 "-L ONL-CONFIG" + installer_partition_format ${blockdev} 3 mkfs.ext2 "-L ONL-IMAGES" + installer_partition_format ${blockdev} 4 mkfs.ext2 "-L ONL-DATA" + + if [ -f $ONL_CONFIG_TARBALL ]; then + installer_say "Restoring the contents of the existing ONL-CONFIG partition..." + installer_create_device_file ${blockdev} 2 + mkdir -p "${installer_df}.mount" + mount "${installer_df}" "${installer_df}.mount" + tar -C "${installer_df}.mount" -xvzf $ONL_CONFIG_TARBALL + umount "${installer_df}.mount" + rm "${installer_df}" + rmdir "${installer_df}.mount" + rm $ONL_CONFIG_TARBALL + fi } ############################################################ @@ -311,15 +347,16 @@ installer_standard_blockdev_install () { local p1size=$2 local p2size=$3 local p3size=$4 + local p4size=$5 # Standard 3-partition format for loader, /mnt/flash, and /mnt/flash2 - installer_blockdev_format "${blockdev}" "${p1size}" "${p2size}" "${p3size}" + installer_blockdev_format "${blockdev}" "${p1size}" "${p2size}" "${p3size}" "${p4size}" # Copy the platform loader to the first partition. installer_platform_loader "${blockdev}" 1 # Set the boot-config file - installer_platform_bootconfig "${blockdev}" 2 + installer_platform_bootconfig "${blockdev}" 1 # Copy the packaged SWI to the third partition. installer_platform_swi "${blockdev}" 3 diff --git a/builds/any/installer/legacy/fit/builds/fit-installer.sh b/builds/any/installer/legacy/fit/builds/fit-installer.sh index eedf721c..fa1f31c8 100644 --- a/builds/any/installer/legacy/fit/builds/fit-installer.sh +++ b/builds/any/installer/legacy/fit/builds/fit-installer.sh @@ -110,7 +110,7 @@ fw_setenv_f_s "${envf}" installer_say "Install finished. Rebooting to Open Network Linux." sleep 3 reboot -exit +exit 0 # Do not add any additional whitespace after this point. PAYLOAD_FOLLOWS diff --git a/builds/any/rootfs/jessie/common/overlay/etc/mtab.yml b/builds/any/rootfs/jessie/common/overlay/etc/mtab.yml new file mode 100644 index 00000000..f29f2a11 --- /dev/null +++ b/builds/any/rootfs/jessie/common/overlay/etc/mtab.yml @@ -0,0 +1,19 @@ +mounts: + ONL-IMAGES: + mount: r + dir: /mnt/onl/images + fsck: true + + ONL-DATA: + mount: w + dir: /mnt/onl/data + + ONL-CONFIG: + mount: r + dir: /mnt/onl/config + fsck: true + + ONL-BOOT: + mount: false + dir: /mnt/onl/boot + fsck: false diff --git a/builds/any/rootfs/wheezy/common/overlay/etc/mtab.yml b/builds/any/rootfs/wheezy/common/overlay/etc/mtab.yml new file mode 100644 index 00000000..f29f2a11 --- /dev/null +++ b/builds/any/rootfs/wheezy/common/overlay/etc/mtab.yml @@ -0,0 +1,19 @@ +mounts: + ONL-IMAGES: + mount: r + dir: /mnt/onl/images + fsck: true + + ONL-DATA: + mount: w + dir: /mnt/onl/data + + ONL-CONFIG: + mount: r + dir: /mnt/onl/config + fsck: true + + ONL-BOOT: + mount: false + dir: /mnt/onl/boot + fsck: false diff --git a/packages/base/all/boot.d/src/50.initdev b/packages/base/all/boot.d/src/50.initdev index 6a0292a2..9fbc1152 100755 --- a/packages/base/all/boot.d/src/50.initdev +++ b/packages/base/all/boot.d/src/50.initdev @@ -12,6 +12,8 @@ if [ -d /sys/class/ubi ]; then fi ( cd /sys/class/net; for d in *; do /sbin/initnetdev $d add; done ) -initmounts - +log_action_end_msg 0 + +log_action_begin_msg "Mounting filesystems" +initmounts -q log_action_end_msg 0 diff --git a/packages/base/all/initrds/loader-initrd-files/PKG.yml b/packages/base/all/initrds/loader-initrd-files/PKG.yml index cdb7a5ac..2fc41557 100644 --- a/packages/base/all/initrds/loader-initrd-files/PKG.yml +++ b/packages/base/all/initrds/loader-initrd-files/PKG.yml @@ -26,8 +26,6 @@ packages: summary: Open Network Linux System Loader Common Initscripts files: - src/bin/initblockdev : /sbin/ - src/bin/initmounts : /sbin/ src/bin/initnetdev : /sbin/ changelog: Change changes changes., diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/banner b/packages/base/all/initrds/loader-initrd-files/src/bin/banner index 54165d40..bcd344c0 100755 --- a/packages/base/all/initrds/loader-initrd-files/src/bin/banner +++ b/packages/base/all/initrds/loader-initrd-files/src/bin/banner @@ -23,9 +23,9 @@ field "$ONL_PLATFORM" " Platform: $ONL_PLATFORM" field "MA1_ADDR" " ma1: $MA1_ADDR" echo "*" echo "************************************************************" -if [ -f /mnt/flash/boot-config ]; then +if [ -f /etc/onl/boot-config ]; then msg_info "boot-config" - cat /mnt/flash/boot-config + cat /etc/onl/boot-config else if [ -f /bin/boot-config.py ]; then diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/boot b/packages/base/all/initrds/loader-initrd-files/src/bin/boot index 1791ed36..63ca5ec7 100755 --- a/packages/base/all/initrds/loader-initrd-files/src/bin/boot +++ b/packages/base/all/initrds/loader-initrd-files/src/bin/boot @@ -49,7 +49,7 @@ Usage: $0 [-h|--help] [-t|--testonly] [--rootfs ROOTFS] --cache LOCATION [SWI] format of the SWI argument: DEV:PATH - /mnt/DEV/PATH + /mnt/onl/DEV/PATH Loads a SWI file from local storage device DEV (e.g. flash). http://[USER:PASSWORD@]SERVER[:PORT]/PATH ftp://[USER:PASSWORD@]SERVER[:PORT]/PATH @@ -111,18 +111,18 @@ case "${SWI}" in fi ;; *) - # Parse dev:file or dev:/file or /mnt/dev/file - parselocal='s#\(\([^:/]*\):/\?\|/mnt/\([^/]*\)/\)\?\(.*\)#dev="\2\3" file="\4"#p' + # Parse dev:file or dev:/file or /mnt/onl/dev/file + parselocal='s#\(\([^:/]*\):/\?\|/mnt/onl/\([^/]*\)/\)\?\(.*\)#dev="\2\3" file="\4"#p' eval $(echo "${SWI}" | sed -n "${parselocal}") if [ "${dev}" ] ; then # Wait for /mnt/dev to show up - waitforblockdev "/mnt/${dev}" + : else # Assume file is relative, parse absolutified file eval $(realpath "${file}" | sed -n "${parselocal}") SWI="${dev}:${file}" fi - swipath="/mnt/${dev}/${file}" + swipath="/mnt/onl/${dev}/${file}" [ -f "${swipath}" ] || { echo "${SWI} not found or not a file"; exit 1; } ;; esac diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/sysinit b/packages/base/all/initrds/loader-initrd-files/src/bin/sysinit index 216ad7e0..6c255b85 100755 --- a/packages/base/all/initrds/loader-initrd-files/src/bin/sysinit +++ b/packages/base/all/initrds/loader-initrd-files/src/bin/sysinit @@ -53,7 +53,6 @@ while read -r l; do esac done - # Populate platform-specific settings . /lib/platform-detect @@ -62,46 +61,23 @@ if [ ! -f /etc/onl/abort ]; then # Tell kernel to invoke mdev when devices are added or removed echo /sbin/mdev >/proc/sys/kernel/hotplug - - # Initialize any block and net devices already present - ( cd /sys/class/block; for d in *; do initblockdev $d add; done ) - if [ -d /sys/class/ubi ]; then - ( cd /sys/class/ubi; for d in *; do initblockdev $d add; done ) - fi + # Initialize net devices ( cd /sys/class/net; for d in *; do initnetdev $d add; done ) # Initialize platform mounts - initmounts - - # Perform recovery if necessary; reboot automatically - if /bin/recover; then - initmounts - else - restoreconsole - echo "Recovery failed." - echo "Press CR now to exit sysinit and access the loader shell." - echo "Otherwise, the system will reboot in 3s." - if read -t 3 prompt; then - trap - EXIT - exit - fi - reboot -f - fi - + initmounts -q if [ -f /etc/issue ]; then cat /etc/issue fi - waitforblockdev /mnt/flash - sleep 1 # wait for external block devices to be mounted - [ ! -f /mnt/flash/boot-config ] || cat /mnt/flash/boot-config >>/etc/onl/boot-config + [ ! -f /mnt/onl/boot/boot-config ] || cat /mnt/onl/boot/boot-config >>/etc/onl/boot-config # # Initialize the /mnt/flash/boot area. # - mkdir -p /mnt/flash/boot - rm -rf /mnt/flash/boot/* + #mkdir -p /mnt/data/boot + #rm -rf /mnt/flash/boot/* fi diff --git a/packages/base/all/initrds/loader-initrd-files/src/bootmodes/swi b/packages/base/all/initrds/loader-initrd-files/src/bootmodes/swi index d1fa5d96..7d6a3fd7 100755 --- a/packages/base/all/initrds/loader-initrd-files/src/bootmodes/swi +++ b/packages/base/all/initrds/loader-initrd-files/src/bootmodes/swi @@ -14,11 +14,11 @@ if [ ! "${SWI}" ]; then exit 200 fi -if [ "${SWI}" = "flash2::latest" ]; then - # Boot the latest (by mtime) SWI in the flash2 partition. - SWI=`ls /mnt/flash2/*.swi -t | head -n1` +if [ "${SWI}" = "images::latest" ]; then + # Boot the latest (by mtime) SWI in the images partition. + SWI=`ls /mnt/onl/images/*.swi -t | head -n1` if [ -z "${SWI}" ]; then - msg_error "No SWI available in /mnt/flash2. SWI booting cannot continue." + msg_error "No SWI available in /mnt/onl/images. SWI booting cannot continue." exit 200 fi fi diff --git a/packages/base/all/initrds/loader-initrd-files/src/etc/mtab.yml b/packages/base/all/initrds/loader-initrd-files/src/etc/mtab.yml new file mode 100644 index 00000000..291e1996 --- /dev/null +++ b/packages/base/all/initrds/loader-initrd-files/src/etc/mtab.yml @@ -0,0 +1,19 @@ +mounts: + ONL-IMAGES: + mount: w + dir: /mnt/onl/images + fsck: true + + ONL-DATA: + mount: w + dir: /mnt/onl/data + + ONL-CONFIG: + mount: r + dir: /mnt/onl/config + fsck: true + + ONL-BOOT: + mount: r + dir: /mnt/onl/boot + fsck: false diff --git a/packages/base/all/initrds/loader-initrd-files/src/etc/rootperms b/packages/base/all/initrds/loader-initrd-files/src/etc/rootperms index 8d76e780..bf95a0a5 100644 --- a/packages/base/all/initrds/loader-initrd-files/src/etc/rootperms +++ b/packages/base/all/initrds/loader-initrd-files/src/etc/rootperms @@ -13,21 +13,16 @@ /etc/passwd f 644 0 0 - - - - - /bin/autoboot f 755 0 0 - - - - - /bin/boot f 755 0 0 - - - - - -/bin/discoverbootconf f 755 0 0 - - - - - /bin/help f 755 0 0 - - - - - /bin/ifget f 755 0 0 - - - - - /bin/ifup f 755 0 0 - - - - - -/bin/initblockdev f 755 0 0 - - - - - /bin/initnetdev f 755 0 0 - - - - - /bin/login f 755 0 0 - - - - - /bin/netconf f 755 0 0 - - - - - -/bin/recover f 755 0 0 - - - - - /bin/swiinfo f 755 0 0 - - - - - /bin/switchroot f 755 0 0 - - - - - /bin/sysinit f 755 0 0 - - - - - /bin/udhcpc f 755 0 0 - - - - - -/bin/waitforblockdev f 755 0 0 - - - - - -/bin/wipe f 755 0 0 - - - - - /bin/zcip f 755 0 0 - - - - - /lib/udhcpc-script f 755 0 0 - - - - - /lib/zcip-script f 755 0 0 - - - - - diff --git a/packages/base/all/vendor-config-onl/PKG.yml b/packages/base/all/vendor-config-onl/PKG.yml index 82a3d46d..794948a1 100644 --- a/packages/base/all/vendor-config-onl/PKG.yml +++ b/packages/base/all/vendor-config-onl/PKG.yml @@ -13,3 +13,17 @@ packages: src/bin : /usr/bin changelog: Changes + + + - name: onl-vendor-config-onl-loader + version: 1.0.0 + arch: all + copyright: Copyright 2013, 2014, 2015 Big Switch Networks + maintainer: support@bigswitch.com + summary: ONL Base Configuration Package (Loader) + + files: + src/python/onl : /usr/lib/python2.7/onl + src/bin/initmounts : /bin/initmounts + + changelog: Changes diff --git a/packages/base/all/vendor-config-onl/src/bin/initmounts b/packages/base/all/vendor-config-onl/src/bin/initmounts new file mode 100755 index 00000000..a2ccaecd --- /dev/null +++ b/packages/base/all/vendor-config-onl/src/bin/initmounts @@ -0,0 +1,3 @@ +#!/usr/bin/python +from onl.mounts import OnlMountManager +OnlMountManager.main() diff --git a/packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py b/packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py new file mode 100755 index 00000000..eaaea1ff --- /dev/null +++ b/packages/base/all/vendor-config-onl/src/python/onl/mounts/__init__.py @@ -0,0 +1,153 @@ +#!/usr/bin/python +import os +import sys +import platform +import subprocess +import logging +import time +import json +import yaml + +class OnlMountManager(object): + def __init__(self, mdata, logger): + + if os.path.exists(mdata): + mdata = yaml.load(open(mdata, "r")); + + self.mdata = mdata + self.logger = logger + + # Needed to avoid ugly warnings from fsck + if not os.path.exists('/etc/mtab'): + open("/etc/mtab", 'w').close(); + + + def checkmount(self, directory): + with open("/proc/mounts") as f: + return directory in f.read() + + def mount(self, device, directory, mode='r', timeout=5): + self.logger.debug("Mounting %s -> %s %s" % (device, directory, mode)) + try: + subprocess.check_call("mount -%s %s %s" % (mode, device, directory), shell=True) + except subrocess.CalledProcessError, e: + self.logger("Mount failed: '%s'" % e.output) + return False + + # If requested, wait for the mount to complete. + while(timeout > 0): + if self.checkmount(directory): + break + time.sleep(1) + timeout-=1 + + if self.checkmount(directory): + self.logger.info("%s is now mounted @ %s" % (device, directory)) + return True + else: + self.logger.info("%s failed to report in /proc/mounts." % (directory)) + + + + def mountall(self, all_=False, fsck=None, timeout=5): + for (k, v) in self.mdata['mounts'].iteritems(): + + # + # Make the mount point for future use. + # + if not os.path.isdir(v['dir']): + self.logger.debug("Make directory '%s'..." % v['dir']) + os.makedirs(v['dir']) + + # + # Get the partition device. + # The timeout logic is here to handle waiting for the + # block devices to arrive at boot. + # + while timeout > 0: + try: + v['device'] = subprocess.check_output("blkid -L %s" % k, shell=True).strip() + break + except subprocess.CalledProcessError: + self.logger.debug("Block label %s does not yet exist..." % k) + time.sleep(1) + timeout -= 1 + + if 'device' not in v: + self.logger.error("Timeout waiting for block label %s after %d seconds." % (k, timeout)) + continue; + + self.logger.debug("%s @ %s" % (k, v['device'])) + + # + # If its currently mounted we should unmount first. + # + if self.checkmount(v['device']): + self.logger.info("%s is currently mounted." % (k)) + try: + out = subprocess.check_output("umount %s" % v['device'], shell=True) + self.logger.info("%s now unmounted." % (k)) + except subprocess.CalledProcessError,e: + self.logger.error("Could not unmount %s @ %s: " % (k, v['device'], e.output)) + continue + # + # FS Checks + # + if fsck is not None: + # Override fsck setting with given value + self.logger.debug("Overriding fsck settings for %s with %s" % (k, fsck)) + v['fsck'] = fsck + + if v.get('fsck', False): + try: + self.logger.info("Running fsck on %s [ %s ]..." % (k, v['device'])) + cmd = "fsck.ext4 -p %s" % (v['device']) + self.logger.debug(cmd) + try: + out = subprocess.check_output(cmd, shell=True) + self.logger.info("%s [ %s ] is clean." % (v['device'], k)) + except subprocess.CalledProcessError, e: + self.logger.error("fsck failed: %s" % e.output) + except subprocess.CalledProcessError, e: + # Todo - recovery options + raise + + + if all_: + v['mount'] = 'w' + + mount = v.get('mount', None) + if mount: + if mount in ['r', 'w']: + self.mount(v['device'], v['dir'], mode=mount, timeout=v.get('timeout', 5)) + else: + self.logger("Mount %s has an invalid mount mode (%s)" % (k, mount)) + + + @staticmethod + def main(): + import argparse + + logging.basicConfig() + + ap = argparse.ArgumentParser(description="ONL Mount Manager."); + ap.add_argument("--mtab", default="/etc/mtab.yml") + ap.add_argument("--rw", action='store_true') + ap.add_argument("--verbose", "-v", action='store_true') + ap.add_argument("--quiet", "-q", action='store_true') + + ops = ap.parse_args(); + + logger = logging.getLogger("initmounts") + if ops.verbose: + logger.setLevel(logging.DEBUG) + elif ops.quiet: + logger.setLevel(logging.ERROR) + else: + logger.setLevel(logging.INFO) + + mm = OnlMountManager(ops.mtab, logger) + if ops.rw: + mm.mountall(all_=True, fsck=False) + else: + mm.mountall() diff --git a/packages/base/any/initrds/loader/builds/Makefile b/packages/base/any/initrds/loader/builds/Makefile index 23bc0fbb..50eea529 100644 --- a/packages/base/any/initrds/loader/builds/Makefile +++ b/packages/base/any/initrds/loader/builds/Makefile @@ -22,6 +22,7 @@ $(TARGET): $(ONLPM) --copy-file onl-buildroot-initrd:$(ARCH) onl-buildroot-initrd-$(ARCH).cpio.gz . sudo rm -rf $(ROOT) && mkdir $(ROOT) $(ONLPM) --sudo --force --extract-dir onl-loader-initrd-files:all $(ROOT) + $(ONLPM) --sudo --force --extract-dir onl-vendor-config-onl-loader:all $(ROOT) $(ONLPM) --sudo $(foreach p,$(PLATFORM_PACKAGES),--extract-dir $(p) $(ROOT)) $(ONL)/tools/sjson.py --kj version $(ONL)/make/version-onl.json --kl platforms $(PLATFORMS) --kv arch $(ARCH) --out manifest.json sudo mkdir -p $(ROOT)/etc/onl/loader && sudo cp manifest.json $(ROOT)/etc/onl/loader diff --git a/packages/base/any/kernels/legacy/linux-3.9.6 b/packages/base/any/kernels/legacy/linux-3.9.6 index ea892415..0106373d 160000 --- a/packages/base/any/kernels/legacy/linux-3.9.6 +++ b/packages/base/any/kernels/legacy/linux-3.9.6 @@ -1 +1 @@ -Subproject commit ea892415c55dade0a10e3b870ca0504befd8695a +Subproject commit 0106373d79ecf4df3f8867c214ce180f4993c442 diff --git a/packages/platforms-closed b/packages/platforms-closed index 51991fb3..3880b54f 160000 --- a/packages/platforms-closed +++ b/packages/platforms-closed @@ -1 +1 @@ -Subproject commit 51991fb381ff842d9a197fb3ab4ca4a77fc12366 +Subproject commit 3880b54fe9480edb6e8c2df7714d83e4e6aaf774 diff --git a/packages/platforms/accton/armel/arm-accton-as4610-54/platform-config/r0/src/lib/install/arm-accton-as4610-54-r0.sh b/packages/platforms/accton/armel/arm-accton-as4610-54/platform-config/r0/src/lib/install/arm-accton-as4610-54-r0.sh index d27c964b..753d8c9e 100644 --- a/packages/platforms/accton/armel/arm-accton-as4610-54/platform-config/r0/src/lib/install/arm-accton-as4610-54-r0.sh +++ b/packages/platforms/accton/armel/arm-accton-as4610-54/platform-config/r0/src/lib/install/arm-accton-as4610-54-r0.sh @@ -1,7 +1,7 @@ # The loader is installed in the fat partition of the first USB storage device -platform_bootcmd="usb start; usbiddev; fatload usb 0:1 70000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 70000000#$ONL_PLATFORM" +platform_bootcmd="usb start; usbiddev; ext2load usb 0:1 70000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 70000000#$ONL_PLATFORM" platform_installer() { # Standard installation to usb storage - installer_standard_blockdev_install sda 128M 128M "" + installer_standard_blockdev_install sda 128M 128M 1024M "" } diff --git a/packages/platforms/accton/powerpc/powerpc-accton-as4600-54t/platform-config/r0/src/lib/install/powerpc-accton-as4600-54t-r0.sh b/packages/platforms/accton/powerpc/powerpc-accton-as4600-54t/platform-config/r0/src/lib/install/powerpc-accton-as4600-54t-r0.sh index 3056a782..e9bef0b1 100644 --- a/packages/platforms/accton/powerpc/powerpc-accton-as4600-54t/platform-config/r0/src/lib/install/powerpc-accton-as4600-54t-r0.sh +++ b/packages/platforms/accton/powerpc/powerpc-accton-as4600-54t/platform-config/r0/src/lib/install/powerpc-accton-as4600-54t-r0.sh @@ -20,9 +20,9 @@ ############################################################ # The loader is installed in the fat partition of the first USB storage device -platform_bootcmd="usb start; fatload usb 0:1 0x10000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM" +platform_bootcmd="usb start; ext2load usb 0:1 0x10000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM" platform_installer() { # Standard installation to usb storage - installer_standard_blockdev_install sda 128M 128M "" + installer_standard_blockdev_install sda 32M 32M 448M "" } diff --git a/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/platform-config/r0/src/lib/install/powerpc-accton-as5610-52x-r0.sh b/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/platform-config/r0/src/lib/install/powerpc-accton-as5610-52x-r0.sh index 3056a782..bb545142 100644 --- a/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/platform-config/r0/src/lib/install/powerpc-accton-as5610-52x-r0.sh +++ b/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/platform-config/r0/src/lib/install/powerpc-accton-as5610-52x-r0.sh @@ -20,9 +20,9 @@ ############################################################ # The loader is installed in the fat partition of the first USB storage device -platform_bootcmd="usb start; fatload usb 0:1 0x10000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM" +platform_bootcmd="usb start; ext2load usb 0:1 0x10000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM" platform_installer() { # Standard installation to usb storage - installer_standard_blockdev_install sda 128M 128M "" + installer_standard_blockdev_install sda 128M 128M 768M "" } diff --git a/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/platform-config/r0/src/lib/install/powerpc-accton-as5710-54x-r0.sh b/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/platform-config/r0/src/lib/install/powerpc-accton-as5710-54x-r0.sh index 2eb0276f..029244c5 100644 --- a/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/platform-config/r0/src/lib/install/powerpc-accton-as5710-54x-r0.sh +++ b/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/platform-config/r0/src/lib/install/powerpc-accton-as5710-54x-r0.sh @@ -19,13 +19,9 @@ # ############################################################ -# The loader must be written raw to the first partition. -platform_loader_raw=1 - -# The loader is installed in the fat partition of the first USB storage device -platform_bootcmd="usb start; usbboot 0x10000000 0:1; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM" +platform_bootcmd="usb start; ext2load usb 0:1 0x10000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM" platform_installer() { # Standard installation to usb storage - installer_standard_blockdev_install sda 128M 128M "" -} \ No newline at end of file + installer_standard_blockdev_install sda 128M 128M 1024M "" +} diff --git a/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/platform-config/r0b/src/lib/install/powerpc-accton-as5710-54x-r0b.sh b/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/platform-config/r0b/src/lib/install/powerpc-accton-as5710-54x-r0b.sh index 2eb0276f..029244c5 100644 --- a/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/platform-config/r0b/src/lib/install/powerpc-accton-as5710-54x-r0b.sh +++ b/packages/platforms/accton/powerpc/powerpc-accton-as5710-54x/platform-config/r0b/src/lib/install/powerpc-accton-as5710-54x-r0b.sh @@ -19,13 +19,9 @@ # ############################################################ -# The loader must be written raw to the first partition. -platform_loader_raw=1 - -# The loader is installed in the fat partition of the first USB storage device -platform_bootcmd="usb start; usbboot 0x10000000 0:1; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM" +platform_bootcmd="usb start; ext2load usb 0:1 0x10000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM" platform_installer() { # Standard installation to usb storage - installer_standard_blockdev_install sda 128M 128M "" -} \ No newline at end of file + installer_standard_blockdev_install sda 128M 128M 1024M "" +} diff --git a/packages/platforms/accton/powerpc/powerpc-accton-as6700-32x/platform-config/r0/src/lib/install/powerpc-accton-as6700-32x-r0.sh b/packages/platforms/accton/powerpc/powerpc-accton-as6700-32x/platform-config/r0/src/lib/install/powerpc-accton-as6700-32x-r0.sh index 1686a0c9..bb545142 100644 --- a/packages/platforms/accton/powerpc/powerpc-accton-as6700-32x/platform-config/r0/src/lib/install/powerpc-accton-as6700-32x-r0.sh +++ b/packages/platforms/accton/powerpc/powerpc-accton-as6700-32x/platform-config/r0/src/lib/install/powerpc-accton-as6700-32x-r0.sh @@ -20,10 +20,9 @@ ############################################################ # The loader is installed in the fat partition of the first USB storage device -platform_bootcmd="usb start; fatload usb 0:1 0x10000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM" +platform_bootcmd="usb start; ext2load usb 0:1 0x10000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM" platform_installer() { # Standard installation to usb storage - installer_standard_blockdev_install sda 128M 128M "" + installer_standard_blockdev_install sda 128M 128M 768M "" } -echo $platform_bootcmd diff --git a/packages/platforms/accton/powerpc/powerpc-accton-as6700-32x/platform-config/r1/src/lib/install/powerpc-accton-as6700-32x-r1.sh b/packages/platforms/accton/powerpc/powerpc-accton-as6700-32x/platform-config/r1/src/lib/install/powerpc-accton-as6700-32x-r1.sh index 82127e06..bb545142 100644 --- a/packages/platforms/accton/powerpc/powerpc-accton-as6700-32x/platform-config/r1/src/lib/install/powerpc-accton-as6700-32x-r1.sh +++ b/packages/platforms/accton/powerpc/powerpc-accton-as6700-32x/platform-config/r1/src/lib/install/powerpc-accton-as6700-32x-r1.sh @@ -20,9 +20,9 @@ ############################################################ # The loader is installed in the fat partition of the first USB storage device -platform_bootcmd="usb start; fatload usb 0:1 0x10000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM" +platform_bootcmd="usb start; ext2load usb 0:1 0x10000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM" platform_installer() { # Standard installation to usb storage - installer_standard_blockdev_install sda 128M 128M "" -} \ No newline at end of file + installer_standard_blockdev_install sda 128M 128M 768M "" +} diff --git a/packages/platforms/quanta/powerpc/powerpc-quanta-lb9/platform-config/r0/src/lib/install/powerpc-quanta-lb9-r0.sh b/packages/platforms/quanta/powerpc/powerpc-quanta-lb9/platform-config/r0/src/lib/install/powerpc-quanta-lb9-r0.sh index 5f9df9f4..0b7ebb4f 100644 --- a/packages/platforms/quanta/powerpc/powerpc-quanta-lb9/platform-config/r0/src/lib/install/powerpc-quanta-lb9-r0.sh +++ b/packages/platforms/quanta/powerpc/powerpc-quanta-lb9/platform-config/r0/src/lib/install/powerpc-quanta-lb9-r0.sh @@ -19,14 +19,10 @@ # ############################################################ -# The loader must be written raw to the first partition. -platform_loader_raw=1 - # The bootcommand is to read the loader directly from the first partition and execute it. -platform_bootcmd="diskboot 0x10000000 0:1 ; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM" +platform_bootcmd="ext2load ide 0:1 0x10000000 powerpc-quanta-lb9-r0.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM" platform_installer() { # Standard installation on the CF card. - installer_standard_blockdev_install sda 128M 128M "" + installer_standard_blockdev_install sda 128M 128M 1024M "" } - diff --git a/packages/platforms/quanta/powerpc/powerpc-quanta-ly2/platform-config/r0/src/lib/install/powerpc-quanta-ly2-r0.sh b/packages/platforms/quanta/powerpc/powerpc-quanta-ly2/platform-config/r0/src/lib/install/powerpc-quanta-ly2-r0.sh index 75de0afa..72f4a223 100644 --- a/packages/platforms/quanta/powerpc/powerpc-quanta-ly2/platform-config/r0/src/lib/install/powerpc-quanta-ly2-r0.sh +++ b/packages/platforms/quanta/powerpc/powerpc-quanta-ly2/platform-config/r0/src/lib/install/powerpc-quanta-ly2-r0.sh @@ -20,10 +20,9 @@ ############################################################ # The bootcommand is to read the loader directly from the first partition and execute it. -platform_bootcmd="mmc part 0; fatload mmc 0:1 0x10000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM" +platform_bootcmd="mmc part 0; ext2load mmc 0:1 0x10000000 $ONL_PLATFORM.itb; setenv bootargs console=\$consoledev,\$baudrate onl_platform=$ONL_PLATFORM; bootm 0x10000000#$ONL_PLATFORM" platform_installer() { # Standard installation on the CF card. - installer_standard_blockdev_install mmcblk0 128M 128M "" + installer_standard_blockdev_install mmcblk0 128M 128M 1024M "" } - diff --git a/sm/bigcode b/sm/bigcode index 334f99fa..a5e6bc1d 160000 --- a/sm/bigcode +++ b/sm/bigcode @@ -1 +1 @@ -Subproject commit 334f99fa416195624ea49cdc94b84e9e33902f0c +Subproject commit a5e6bc1d768a40a527e853e6c789c5a9eaf5159d