From 3a631ce73bb0f0b174b6414d9a2eb33fe171de7f Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sat, 20 Jun 2009 21:34:33 +0000 Subject: [PATCH] luci-0.9: merge r4880-r4881 --- contrib/package/freifunk-watchdog/Makefile | 4 +- .../freifunk-watchdog/files/sysupgrade.hook | 7 --- contrib/package/sysupgrade-atheros/Makefile | 55 +++++++++++++++++++ .../files/lib/upgrade/platform.sh | 32 +++++++++++ 4 files changed, 88 insertions(+), 10 deletions(-) delete mode 100644 contrib/package/freifunk-watchdog/files/sysupgrade.hook create mode 100644 contrib/package/sysupgrade-atheros/Makefile create mode 100644 contrib/package/sysupgrade-atheros/files/lib/upgrade/platform.sh diff --git a/contrib/package/freifunk-watchdog/Makefile b/contrib/package/freifunk-watchdog/Makefile index 4876a94de..e3ff67401 100644 --- a/contrib/package/freifunk-watchdog/Makefile +++ b/contrib/package/freifunk-watchdog/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=freifunk-watchdog -PKG_RELEASE:=3 +PKG_RELEASE:=4 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) PKG_BUILD_DEPENDS := uci @@ -48,8 +48,6 @@ define Package/freifunk-watchdog/install $(INSTALL_BIN) ./files/freifunk-watchdog.init $(1)/etc/init.d/freifunk-watchdog $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_BIN) $(PKG_BUILD_DIR)/ffwatchd $(1)/usr/sbin/ - $(INSTALL_DIR) $(1)/lib/upgrade - $(INSTALL_DATA) ./files/sysupgrade.hook $(1)/lib/upgrade/kill-ffwatchd.sh endef $(eval $(call BuildPackage,freifunk-watchdog)) diff --git a/contrib/package/freifunk-watchdog/files/sysupgrade.hook b/contrib/package/freifunk-watchdog/files/sysupgrade.hook deleted file mode 100644 index e124c39c5..000000000 --- a/contrib/package/freifunk-watchdog/files/sysupgrade.hook +++ /dev/null @@ -1,7 +0,0 @@ -kill_freifunk_watchdog() { - v "Terminating ffwatchd..." - killall ffwatchd - killall crond -} - -export sysupgrade_pre_upgrade="${sysupgrade_pre_upgrade:+$sysupgrade_pre_upgrade }kill_freifunk_watchdog" diff --git a/contrib/package/sysupgrade-atheros/Makefile b/contrib/package/sysupgrade-atheros/Makefile new file mode 100644 index 000000000..6b52ee138 --- /dev/null +++ b/contrib/package/sysupgrade-atheros/Makefile @@ -0,0 +1,55 @@ +# +# Copyright (C) 2009 Jo-Philipp Wich +# +# This is free software, licensed under the Apache 2.0 license. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=sysupgrade-atheros +PKG_RELEASE:=1 + +PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) + +include $(INCLUDE_DIR)/package.mk + +define Package/sysupgrade-atheros + SECTION:=luci + CATEGORY:=LuCI + SUBMENU:=Freifunk + TITLE:=Experimental sysupgrade support for Atheros SoC + DEPENDS:=+base-files +endef + +define Package/sysupgrade-atheros/description + This package implements experimental sysupgrade support for Atheros SoC devices + like the classic Fonera or the D-Link DIR-300. + See https://lists.openwrt.org/pipermail/openwrt-devel/2009-June/004499.html for details. +endef + +define Build/Prepare + mkdir -p $(PKG_BUILD_DIR) +endef + +define Build/Configure +endef + +define Build/Compile +endef + +define Package/sysupgrade-atheros/postinst +#!/bin/sh +[ -n "$${IPKG_INSTROOT}" ] || { + if ! grep -q /etc/firewall.freifunk /etc/config/firewall; then + uci add firewall include >/dev/null + uci set firewall.@include[-1].path=/etc/firewall.freifunk + uci commit firewall + fi +} +endef + +define Package/sysupgrade-atheros/install + $(CP) ./files/* $(1)/ +endef + +$(eval $(call BuildPackage,sysupgrade-atheros)) diff --git a/contrib/package/sysupgrade-atheros/files/lib/upgrade/platform.sh b/contrib/package/sysupgrade-atheros/files/lib/upgrade/platform.sh new file mode 100644 index 000000000..87a324810 --- /dev/null +++ b/contrib/package/sysupgrade-atheros/files/lib/upgrade/platform.sh @@ -0,0 +1,32 @@ +platform_check_image() { + [ "$ARGC" -gt 1 ] && return 1 + + case "$(get_magic_word "$1")" in + # Freifunk .img files + 4646) return 0;; + *) + echo "Invalid image. Use Freifunk .img files on this platform" + return 1 + ;; + esac +} + +platform_do_upgrade() { + local kern_length=$((0x$(dd if="$1" bs=2 skip=1 count=4 2>/dev/null)/65536)) + local kern_name=$(dd if="$1" bs=2 skip=5 count=8 2>/dev/null); kern_name="${kern_name%% *}" + local root_length=$((0x$(dd if="$1" bs=2 skip=13 count=4 2>/dev/null)/65536)) + local root_name=$(dd if="$1" bs=2 skip=17 count=8 2>/dev/null); root_name="${root_name%% *}" + + local append="" + [ -f "$CONF_TAR" -a "$SAVE_CONFIG" -eq 1 ] && append="-j $CONF_TAR" + + if [ -n "$kern_name" -a -n "$root_name" ] && \ + [ ${kern_length:-0} -gt 0 -a ${root_length:-0} -gt ${kern_length:-0} ]; + then + dd if="$1" bs=65536 skip=1 count=$kern_length 2>/dev/null | \ + mtd -e $kern_name write - $kern_name + + dd if="$1" bs=65536 skip=$((1+$kern_length)) count=$root_length 2>/dev/null | \ + mtd -e $root_name $append write - $root_name + fi +} -- 2.25.1