diff options
author | Katze Miau <miaukatzemiau@priveasy.de> | 2011-12-08 14:02:50 (GMT) |
---|---|---|
committer | Katze Miau <miaukatzemiau@priveasy.de> | 2011-12-08 14:02:50 (GMT) |
commit | b49f8093246a1ad8b4f1998f48690cfc20d09e52 (patch) | |
tree | c1299683e2f570ce83ee654575fabcd916be80c7 | |
parent | a4fa439241252bb25559952aeffbffd7f6d9721f (diff) |
generate files/etc/{banner, firmware} from repository state
The new script ./name_firmware is used to generates two files in
openwrt/$REPO/files/ during `make image/...`:
- /etc/firmware (see documentation on firmware id)
- /etc/banner (login banner; generated from the template in
/files/common/etc/banner)
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | doc/overview.org | 14 | ||||
-rw-r--r-- | files/common/etc/banner | 13 | ||||
-rwxr-xr-x | name_firmware | 27 |
4 files changed, 51 insertions, 4 deletions
@@ -64,6 +64,7 @@ image/%: config/$$(REPO)-$$(PLATFORM)-$$(MODEL).config \ cp -a files/common openwrt/$(REPO)/files [ -d files/$(PLATFORM) ] && rsync -a files/$(PLATFORM)/ openwrt/$(REPO)/files/ [ -d files/$(PLATFORM)-$(MODEL) ] && rsync -a files/$(PLATFORM)-$(MODEL)/ openwrt/$(REPO)/files/ + ./name_firmware openwrt/$(REPO) cd openwrt/$(REPO) && $(MAKE) -j$(NUMPROC) mkdir -p $@ rsync -a openwrt/$(REPO)/bin/$(PLATFORM)/ $@/ diff --git a/doc/overview.org b/doc/overview.org index 78bf230..40fe441 100644 --- a/doc/overview.org +++ b/doc/overview.org @@ -103,12 +103,18 @@ digraph { verified Once this state is reached the update is performed. - + * Components ** Firmware ID - /etc/firmware stores sha256 of the current firmware. If a node is - intensively modified after flashing the value is replaced (e.g. by - "custom"). + /etc/firmware stores a string identifying the current firmware. It + consists of + 1. the date of the git commit of the FFJ config + 2. a hash of the git commit of the FFJ config + 3. the OpenWRT major version + 4. the OpenWRT revision + + Example: + 2011-12-06_a4fa439-modified_backfire-29460 ** Router IDs - unique ID :: all routers use /proc/sys/kernel/random/boot_id as unique ID diff --git a/files/common/etc/banner b/files/common/etc/banner new file mode 100644 index 0000000..8ec5cc8 --- /dev/null +++ b/files/common/etc/banner @@ -0,0 +1,13 @@ +################################################################## +# ______ _ __ _ ___ # +# | ___| (_)/ _| | | |_ | # +# | |_ _ __ ___ _| |_ _ _ _ __ | | __ | | ___ _ __ __ _ # +# | _| '__/ _ \ | _| | | | '_ \| |/ / | |/ _ \ '_ \ / _' | # +# | | | | | __/ | | | |_| | | | | < /\__/ / __/ | | | (_| | # +# |_| |_| \___|_|_| \__,_|_| |_|_|\_\ \____/ \___|_| |_|\__,_| # +# # +# * OpenWRT $VWRT # +# * FFJ config $VGIT # +# * Gebaut am $HDATE # +# * http://www.freifunk-jena.de # +################################################################## diff --git a/name_firmware b/name_firmware new file mode 100755 index 0000000..bf062d3 --- /dev/null +++ b/name_firmware @@ -0,0 +1,27 @@ +#!/bin/bash -e + +[ -d "$1" ] || { + echo "Usage: $0 target-repo"; + exit 1; +} + +REPO=$1 +OB=$1/files/etc/banner +OF=$1/files/etc/firmware + +HDATE="$(date +'%d.%m.%Y %H:%M')" +VGIT=$( + git log --format=format:%cd_%h --date=short | head -n1 | tr -d "\n"; + [ -n "$$(git status --porcelain)" ] && echo -n "-modified"; +) +VWRT=$(basename $REPO)-$(cd $REPO; svn info | grep Revision | cut -f2 -d' ') +MACHINE="$USER @ $HOST" + +# firmware id +echo "${VGIT}_$VWRT" > $OF + +# banner +sed < files/common/etc/banner > $OB \ +'s/$VWRT.\{'$(($(echo -n "$VWRT"|wc -c) - 5))'\}/'"$VWRT"'/ +s/$VGIT.\{'$(($(echo -n "$VGIT"|wc -c) - 5))'\}/'"$VGIT"'/ +s/$HDATE.\{'$(($(echo -n "$HDATE"|wc -c) - 6))'\}/'"$HDATE"'/' |