summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--recipes-core/initscripts/initscripts-1.0/umountfs21
-rw-r--r--scripts/upgrade/README62
-rwxr-xr-xscripts/upgrade/install.sh148
-rw-r--r--scripts/upgrade/install_list.txt1
-rw-r--r--scripts/upgrade/local.conf16
-rw-r--r--scripts/upgrade/model1
6 files changed, 248 insertions, 1 deletions
diff --git a/recipes-core/initscripts/initscripts-1.0/umountfs b/recipes-core/initscripts/initscripts-1.0/umountfs
index 300de4f..17b44cf 100644
--- a/recipes-core/initscripts/initscripts-1.0/umountfs
+++ b/recipes-core/initscripts/initscripts-1.0/umountfs
@@ -106,6 +106,7 @@ flash_upgrade() {
local rootfs_file=rootfs.jffs2
local kernel_file=uImage.bin
local uboot_file=uboot.bin
+ local install_file=install.sh
if [ ! -d "${flash_dir}" ]; then
echo "${flash_dir} not present, skipping"
@@ -172,7 +173,7 @@ flash_upgrade() {
cd /var/volatile
# rootfs should always be flashed last, so always keep it last here
- local files=(${bootstrap_file} ${uboot_file} ${config_file} ${oem_file} ${kernel_file} ${rootfs_file})
+ local files=(${bootstrap_file} ${uboot_file} ${config_file} ${oem_file} ${kernel_file} ${rootfs_file} ${install_file})
local devs=(${bootstrap_mtd} ${uboot_mtd} ${config_mtd} ${oem_mtd} ${kernel_mtd} ${rootfs_mtd})
if [ -f "${upgrade_file}" ]; then
@@ -189,6 +190,7 @@ flash_upgrade() {
fi
echo "Checking MD5s"
+ ((upgrade_script=0))
# check md5sum
for (( i = 0; i < ${#files[@]}; i++ )); do
local file=${files[i]}
@@ -202,6 +204,11 @@ flash_upgrade() {
return
fi
fi
+ # Extract files early if we are going to
+ # execute the upgrade script.
+ if [[ ${file} == ${install_file} ]] ; then
+ ((upgrade_script=1))
+ fi
done
fi
@@ -237,6 +244,18 @@ flash_upgrade() {
err_leds
return 1
fi
+
+ # Run the upgrade script, if it exists, before we change
+ # flash-root to read-only
+ if ((upgrade_script == 1)) ; then
+ if (cd ${flash_dir};tar -xf ${upgrade_file}) ; then
+ exec ${flash_dir}/${install_file} ${flash_root}
+ else
+ echo "Extraction of ${upgrade_file} failed"
+ echo "Upgrade aborted"
+ umount_all
+ fi
+ fi
sync
sleep 2
mount -o remount,ro ${flash_root}
diff --git a/scripts/upgrade/README b/scripts/upgrade/README
new file mode 100644
index 0000000..6d5a1b6
--- /dev/null
+++ b/scripts/upgrade/README
@@ -0,0 +1,62 @@
+The upgrade scripts goes in a tarball with local.conf at the top level.
+
+The tree is a follows:
+.
+|-- install_list.txt
+|-- install_list.txt.md5
+|-- install.sh*
+|-- install.sh.md5
+|-- local.conf
+|-- local.conf.md5
+|-- model
+`-- repo/
+ |-- arm926ejste/
+ | |-- busybox_1.24.1-r0.mlinux2.mlinux2.1_arm926ejste.ipk
+ | |-- busybox-hwclock_1.24.1-r0.mlinux2.mlinux2.1_arm926ejste.ipk
+ | |-- busybox-ifplugd_1.24.1-r0.mlinux2.mlinux2.1_arm926ejste.ipk
+ | |-- busybox-syslog_1.24.1-r0.mlinux2.mlinux2.1_arm926ejste.ipk
+ | |-- busybox-udhcpc_1.24.1-r0.mlinux2.mlinux2.1_arm926ejste.ipk
+ | |-- initscripts_1.0-r155.3.40.0_arm926ejste.ipk
+ | |-- initscripts-functions_1.0-r155.3.40.0_arm926ejste.ipk
+ | |-- Packages
+ | |-- Packages.gz
+ | `-- Packages.stamps
+ `-- Packages
+
+
+
+install.sh gets executed if it exists by /etc/init.d/umountfs
+
+The files are placed in a tarball called upgrade.bin, and it
+should be located in either /var/volatile/flash-upgrade or
+/media/card/flash-upgrade to be compatible with umountfs.
+
+The file /var/volatile/do_flash_upgrade must exist and
+be owned by root for umountfs to execute the upgrade
+procedure.
+
+install_list.txt is a list of packages to
+install after the upgrade. If some packages
+have mutual dependencies on each other, they should
+be put on the same line.
+
+The file local.conf should contain a list of
+architectures with priorities, and a list of
+repositories.
+
+The md5sums are created as follows:
+
+cat install.sh | md5sum -c install.sh.md5
+md5sum install.sh >install.sh.md5
+md5sum local.conf >local.conf.md5
+
+model is from the part of the hardware
+version before the first hyphen.
+
+Example:
+
+MTCAP-0.1 Would be MTCAP
+MTCDT-0.0 Would be MTCDT
+MTCDTIP-0.1 Would be MTCDTIP
+
+
diff --git a/scripts/upgrade/install.sh b/scripts/upgrade/install.sh
new file mode 100755
index 0000000..4928d88
--- /dev/null
+++ b/scripts/upgrade/install.sh
@@ -0,0 +1,148 @@
+#!/bin/bash
+# This script works with a tar archvie
+# called upgrade.bin in either /var/volatile
+# or on the SD card.
+#
+# This is what the tar file upgrade file
+# should look like to create an ipk upgrade
+# file. IPK files should be in all,
+# arm926ejste, and mtcdt (for mtcdt)
+cat <<'!EOF' >/dev/null
+.
+|-- install_list.txt
+|-- install_list.txt.md5
+|-- install.sh*
+|-- install.sh.md5
+|-- local.conf
+|-- local.conf.md5
+|-- model
+|-- repo/
+| |-- arm926ejste/
+| | |-- busybox_1.24.1-r0.mlinux2.mlinux2.1_arm926ejste.ipk
+| | |-- busybox-hwclock_1.24.1-r0.mlinux2.mlinux2.1_arm926ejste.ipk
+| | |-- busybox-ifplugd_1.24.1-r0.mlinux2.mlinux2.1_arm926ejste.ipk
+| | |-- busybox-syslog_1.24.1-r0.mlinux2.mlinux2.1_arm926ejste.ipk
+| | |-- busybox-udhcpc_1.24.1-r0.mlinux2.mlinux2.1_arm926ejste.ipk
+| | |-- initscripts_1.0-r155.3.40.0_arm926ejste.ipk
+| | |-- initscripts-functions_1.0-r155.3.40.0_arm926ejste.ipk
+| | |-- Packages
+| | |-- Packages.gz
+| | `-- Packages.stamps
+| `-- Packages
+!EOF
+#
+# The tarball must be called upgrade.bin.
+#
+# The file /var/volatile/do_flash_upgrade must exist and
+# be owned by root.
+#
+# The tar file, upgrade.bin must be either in
+# /var/volatile/flash-upgrade or
+# /media/card/flash-upgrade
+#
+# Note that when this script is started, the
+# tar file is already unpacked, since this script
+# is in the tarball.
+
+# This script assumes that the rootfs and maybe /var
+# are writable. For MTR, we may need to set
+# root and var to read/write
+
+NAME=install.sh
+echo "$NAME starting"
+
+umount_all() {
+ if [[ $1 == "error" ]] ; then
+ echo "Cannot continue"
+ err_leds
+ sleep 10
+ fi
+ echo "Deactivating swap..."
+ swapoff -a
+
+ # We leave /proc mounted.
+ echo "Unmounting local filesystems..."
+ grep -q /mnt/ram /proc/mounts && mount -o remount,ro /mnt/ram
+ umount -f -a -r > /dev/null 2>&1
+
+ mount -o remount,ro /
+ ${up_dir}/upgrade-reboot
+
+ # Should not get here normally
+ echo "upgrade-reboot failed"
+ /sbin/reboot
+ exit 1
+}
+err_leds() {
+ led_dir=/sys/class/leds
+ # blink all programmable LEDs except status
+ leds=$(ls $led_dir/ | grep -v status)
+ nleds=$(echo "$leds" | wc -w)
+
+ # turn LEDs off
+ for led in $leds; do
+ echo "timer" > $led_dir/$led/trigger
+ echo 0 > $led_dir/$led/delay_off
+ done
+
+ int=200
+ total=$(( int * (nleds+1) ))
+ on=$(( total - int ))
+ off=$(( total - on ))
+
+ # make a pattern
+ for led in $leds; do
+ echo "$on" > $led_dir/$led/delay_on
+ echo "$off" > $led_dir/$led/delay_off
+ done
+ sleep 5
+}
+flash_dir="$1"
+up_dir="${flash_dir}/flash-upgrade"
+if ! [[ -d ${up_dir} ]] ; then
+ echo "\"${up_dir}\" is not present"
+ umount_all error
+fi
+echo "ls -l ${flash_dir}"
+ls -l ${flash_dir}
+echo "ls -l ${up_dir}"
+ls -l "${up_dir}"
+cd "${up_dir}"
+if ! md5sum -c local.conf.md5 >/dev/null ; then
+ echo "md5sum of local.conf is bad"
+ umount_all error
+fi
+
+# opkg needs /tmp, so recreate it.
+# On a Conduit, this is always /var/volatile
+mkdir -m 01777 /var/volatile/tmp
+localcnf="${up_dir}/local.conf"
+echo "Local configuration file: ${localcnf}"
+echo mounts ...
+cat /proc/mounts
+echo "Update package list ... /usr/bin/opkg -f ${localcnf} update"
+/usr/bin/opkg -f "${localcnf}" update
+echo "List upgradable packages ... /usr/bin/opkg -f ${localcnf} list-upgradable"
+/usr/bin/opkg -f "${localcnf}" list-upgradable
+echo "Do package upgrade /usr/bin/opkg -f ${localcnf} upgrade"
+/usr/bin/opkg -f "${localcnf}" upgrade
+pkglist_file="install_list.txt"
+if [[ -r ${pkglist_file} ]] ; then
+ if ! md5sum -c ${pkglist_file}.md5 ; then
+ echo "md5sum bad on ${pkglist_file}"
+ umount_all error
+ fi
+ OIFS="${IFS}"
+ IFS=$'\n'
+ for p in $(cat ${pkglist_file}) ; do
+ echo /usr/bin/opkg -f "${localcnf}" install $p
+ /usr/bin/opkg -f "${localcnf}" install $p
+ done
+ IFS="${OIFS}"
+fi
+echo "Rebooting..."
+
+umount_all ok
+echo "upgrade-reboot failed"
+exit 1
+
diff --git a/scripts/upgrade/install_list.txt b/scripts/upgrade/install_list.txt
new file mode 100644
index 0000000..2e46397
--- /dev/null
+++ b/scripts/upgrade/install_list.txt
@@ -0,0 +1 @@
+busybox-ifplugd
diff --git a/scripts/upgrade/local.conf b/scripts/upgrade/local.conf
new file mode 100644
index 0000000..d623c37
--- /dev/null
+++ b/scripts/upgrade/local.conf
@@ -0,0 +1,16 @@
+# Set mtcap instead of mtcdt for mtcap
+arch all 1
+arch any 6
+arch noarch 11
+arch arm 16
+arch armv4 21
+arch armv4t 26
+arch armv5 31
+arch armv5t 36
+arch armv5e 41
+arch armv5te 46
+arch arm926ejste 51
+arch arm926ejse 56
+arch mtcdt 61
+
+src/gz mlinux-arm926ejste file://var/volatile/flash-upgrade/repo/arm926ejste
diff --git a/scripts/upgrade/model b/scripts/upgrade/model
new file mode 100644
index 0000000..31dce8c
--- /dev/null
+++ b/scripts/upgrade/model
@@ -0,0 +1 @@
+MTCDT