From 19b611f8abc0e3c1b90e6541741eeee7beaf74cb Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 31 Jan 2013 10:23:27 +0100 Subject: [PATCH] Add gluon-core package This is the most basic core of the Gluon framework. Most upgrade scripts will have to be rewritten and/or moved to other packages. --- package/gluon-core/Makefile | 35 ++++++++++ .../files/etc/uci-defaults/zzz-gluon-upgrade | 69 +++++++++++++++++++ .../core/0.3.1/010-freifunk-migrate-config | 16 +++++ .../core/0.3.1/011-freifunk-disable-services | 4 ++ .../core/0.3.1/012-freifunk-migrate-network | 18 +++++ .../0.3.1/013-freifunk-migrate-batman-adv | 17 +++++ .../gluon/upgrade/core/0.3.1/020-lff-wireless | 6 ++ .../gluon/upgrade/core/0.3.1/021-lff-fastd | 9 +++ .../0.3.2/010-freifunk-migrate-batman-adv | 5 ++ .../core/0.3.2/011-update-avahi-daemon-conf | 6 ++ .../core/0.3.2/020-lff-migrate-mesh-vpn | 33 +++++++++ .../upgrade/core/0.3.2/021-lff-migrate-peers | 11 +++ .../0.3.3/010-freifunk-migrate-batman-adv | 38 ++++++++++ .../upgrade/core/initial/010-freifunk-system | 40 +++++++++++ .../upgrade/core/initial/011-freifunk-network | 64 +++++++++++++++++ .../initial/012-freifunk-disable-services | 5 ++ .../upgrade/core/initial/020-lff-wireless | 25 +++++++ .../gluon-core/files/lib/upgrade/keep.d/gluon | 1 + 18 files changed, 402 insertions(+) create mode 100644 package/gluon-core/Makefile create mode 100755 package/gluon-core/files/etc/uci-defaults/zzz-gluon-upgrade create mode 100755 package/gluon-core/files/lib/gluon/upgrade/core/0.3.1/010-freifunk-migrate-config create mode 100755 package/gluon-core/files/lib/gluon/upgrade/core/0.3.1/011-freifunk-disable-services create mode 100755 package/gluon-core/files/lib/gluon/upgrade/core/0.3.1/012-freifunk-migrate-network create mode 100755 package/gluon-core/files/lib/gluon/upgrade/core/0.3.1/013-freifunk-migrate-batman-adv create mode 100755 package/gluon-core/files/lib/gluon/upgrade/core/0.3.1/020-lff-wireless create mode 100755 package/gluon-core/files/lib/gluon/upgrade/core/0.3.1/021-lff-fastd create mode 100755 package/gluon-core/files/lib/gluon/upgrade/core/0.3.2/010-freifunk-migrate-batman-adv create mode 100755 package/gluon-core/files/lib/gluon/upgrade/core/0.3.2/011-update-avahi-daemon-conf create mode 100755 package/gluon-core/files/lib/gluon/upgrade/core/0.3.2/020-lff-migrate-mesh-vpn create mode 100755 package/gluon-core/files/lib/gluon/upgrade/core/0.3.2/021-lff-migrate-peers create mode 100755 package/gluon-core/files/lib/gluon/upgrade/core/0.3.3/010-freifunk-migrate-batman-adv create mode 100755 package/gluon-core/files/lib/gluon/upgrade/core/initial/010-freifunk-system create mode 100755 package/gluon-core/files/lib/gluon/upgrade/core/initial/011-freifunk-network create mode 100755 package/gluon-core/files/lib/gluon/upgrade/core/initial/012-freifunk-disable-services create mode 100755 package/gluon-core/files/lib/gluon/upgrade/core/initial/020-lff-wireless create mode 100644 package/gluon-core/files/lib/upgrade/keep.d/gluon diff --git a/package/gluon-core/Makefile b/package/gluon-core/Makefile new file mode 100644 index 00000000..73034980 --- /dev/null +++ b/package/gluon-core/Makefile @@ -0,0 +1,35 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=gluon-core +PKG_VERSION:=0.3.2.99 +PKG_RELEASE:=1 + +PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) + +include $(INCLUDE_DIR)/package.mk + +define Package/gluon-core + SECTION:=gluon + CATEGORY:=Gluon + TITLE:=Base files of Gluon +endef + +define Package/gluon-core/description + The core of the Gluon community wifi mesh firmware framework +endef + +define Build/Prepare + mkdir -p $(PKG_BUILD_DIR) +endef + +define Build/Configure +endef + +define Build/Compile +endef + +define Package/gluon-core/install + $(CP) ./files/* $(1)/ +endef + +$(eval $(call BuildPackage,gluon-core)) diff --git a/package/gluon-core/files/etc/uci-defaults/zzz-gluon-upgrade b/package/gluon-core/files/etc/uci-defaults/zzz-gluon-upgrade new file mode 100755 index 00000000..3b9fc07d --- /dev/null +++ b/package/gluon-core/files/etc/uci-defaults/zzz-gluon-upgrade @@ -0,0 +1,69 @@ +#!/bin/sh + + +UPGRADE_DIR=/lib/gluon/upgrade +VERSION_DIR=/lib/gluon/version + + +version_of() { + opkg status "gluon-$1" | grep '^Version: ' | cut -d' ' -f 2 +} + +oldversion_of() { + oldversion="$(cat "$VERSION_DIR"/"$1" 2>/dev/null)" + + # Legacy support + if [ -z "$oldversion" ]; then oldversion="$(cat /etc/.freifunk_version_keep 2>/dev/null)"; fi + if [ -z "$oldversion" ]; then oldversion="$(cat /etc/.lff_version_keep 2>/dev/null)"; fi + if [ -z "$oldversion" ]; then oldversion="$(cat /etc/.kff_version_keep 2>/dev/null)"; fi + + echo "$oldversion" +} + +do_dir() { + if [ -d "$1" ]; then + local s + for s in "$1"/*; do "$s"; done + fi +} + + +version="$(version_of gluon-core)" + +oldversion="$(cat "$VERSION_FILE" 2>/dev/null)" +if [ -z "$oldversion" ]; then oldversion="$(cat "$VERSION_FILE_FREIFUNK" 2>/dev/null)"; fi +if [ -z "$oldversion" ]; then oldversion="$(cat "$VERSION_FILE_LFF" 2>/dev/null)"; fi +if [ -z "$oldversion" ]; then oldversion="$(cat "$VERSION_FILE_KFF" 2>/dev/null)"; fi + +( + cd "$UPGRADE_DIR" + + for component in *; do ( + local version="$(version_of "$component")" + if [ -z "$version" ]; then continue; fi + + cd "$component" + + local oldversion="$(oldversion_of "$component")" + if [ -z "$oldversion" ]; then + do_dir initial + else + local v + + for v in *; do + if [ "$v" = initial -o "$v" = invariant -o "$v" = version ]; then continue; fi + + # The return value of opkg compare-versions is negated + if ! opkg compare-versions "$v" '>>' "$oldversion"; then + do_dir "$v" + fi + done + fi + + do_dir invariant + + echo "$version" > "$VERSION_DIR"/"$component" + ) done +) + +rm -f "$VERSION_FILE_FREIFUNK" "$VERSION_FILE_LFF" "$VERSION_FILE_KFF" diff --git a/package/gluon-core/files/lib/gluon/upgrade/core/0.3.1/010-freifunk-migrate-config b/package/gluon-core/files/lib/gluon/upgrade/core/0.3.1/010-freifunk-migrate-config new file mode 100755 index 00000000..8f6d7026 --- /dev/null +++ b/package/gluon-core/files/lib/gluon/upgrade/core/0.3.1/010-freifunk-migrate-config @@ -0,0 +1,16 @@ +#!/bin/sh + + +[ -r /etc/config/ffhl ] || exit 0 + +cp /etc/config/ffhl /etc/config/config_mode +mv /etc/config/ffhl /etc/config/freifunk + +uci -q batch </dev/null || true +) + +rmdir -p /etc/fastd/ffhl-mesh-vpn/peers 2>/dev/null || true diff --git a/package/gluon-core/files/lib/gluon/upgrade/core/0.3.3/010-freifunk-migrate-batman-adv b/package/gluon-core/files/lib/gluon/upgrade/core/0.3.3/010-freifunk-migrate-batman-adv new file mode 100755 index 00000000..ba32c95b --- /dev/null +++ b/package/gluon-core/files/lib/gluon/upgrade/core/0.3.3/010-freifunk-migrate-batman-adv @@ -0,0 +1,38 @@ +#!/bin/sh + +. /lib/ar71xx.sh + +local board="$(ar71xx_board_name)" + +uci -q batch <