gluon-autoupdater: new branch specification

It is now possible to specific multiple branches like this:

config branch stable
  option url ...
  list pubkey ...
  ...

config branch testing
  ...

and select one in autoupdater.settings:

config autoupdater settings
  option branch "stable"
This commit is contained in:
Nils Schneider 2013-10-02 13:33:47 +02:00
parent baf6d14160
commit edcc573976
8 changed files with 87 additions and 51 deletions

View File

@ -1,8 +1,8 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=gluon-autoupdater
PKG_VERSION:=0.3.2.99
PKG_RELEASE:=0.1
PKG_VERSION:=0.1
PKG_RELEASE:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/package.mk
define Package/gluon-autoupdater
SECTION:=gluon
CATEGORY:=Gluon
DEPENDS:=+ecdsautils +gluon-cron +gluon-release
DEPENDS:=+ecdsautils +gluon-cron +gluon-release +gluon-location
TITLE:=Automatically update firmware
endef
@ -23,13 +23,13 @@ define Build/Configure
endef
define Build/Compile
$(GLUON_CONFIGURE) autoupdater.pl > $(PKG_BUILD_DIR)/autoupdater.sh
$(GLUON_CONFIGURE) invariant.pl > $(PKG_BUILD_DIR)/invariant.sh
endef
define Package/gluon-autoupdater/install
$(CP) ./files/* $(1)/
$(INSTALL_DIR) $(1)/lib/gluon/upgrade/autoupdater/initial
$(INSTALL_BIN) $(PKG_BUILD_DIR)/autoupdater.sh $(1)/lib/gluon/upgrade/autoupdater/initial/010-autoupdater
$(INSTALL_DIR) $(1)/lib/gluon/upgrade/autoupdater/invariant
$(INSTALL_BIN) $(PKG_BUILD_DIR)/invariant.sh $(1)/lib/gluon/upgrade/autoupdater/invariant/010-autoupdater
endef
$(eval $(call BuildPackage,gluon-autoupdater))

View File

@ -1,23 +0,0 @@
my $cfg = $CONFIG->{autoupdater};
print <<'END';
#/bin/sh
uci -q batch <<EOF
delete autoupdater.default
set autoupdater.default=autoupdater
END
for (qw(enabled branch url probability good_signatures)) {
print 'set autoupdater.default.' . $_ . '=' . $cfg->{$_} . "\n";
}
for (@{$cfg->{pubkeys}}) {
print 'add_list autoupdater.default.pubkey=' . $_ . "\n";
}
print <<END;
commit autoupdater
EOF
END

View File

@ -1,6 +1,8 @@
config autoupdater default
config autoupdater settings
option enabled 1
option branch "stable"
config branch stable
option url 'http://[fdef:ffc0:3dd7::8]/~freifunk/firmware/autoupdate'
# The updater will run once per hour and perform an update with a certain

View File

@ -0,0 +1,3 @@
#/bin/sh
uci -q delete autoupdater.settings

View File

@ -0,0 +1,3 @@
#/bin/sh
uci -q delete autoupdater.settings

View File

@ -1,11 +1,13 @@
#!/bin/sh
if test $(uci get autoupdater.default.enabled) != 1; then
if test $(uci get autoupdater.settings.enabled) != 1; then
echo "autoupdater is disabled"
exit 0
fi
PROBABILITY=$(uci get autoupdater.default.probability)
BRANCH=$(uci get autoupdater.settings.branch)
PROBABILITY=$(uci get autoupdater.${BRANCH}.probability)
if test "a$1" != "a-f"; then
echo | awk "END{srand();exit rand() > $PROBABILITY}"
@ -15,10 +17,9 @@ if test "a$1" != "a-f"; then
fi
fi
BASE=$(uci get autoupdater.default.url)
PUBKEYS=$(uci get autoupdater.default.pubkey)
GOOD_SIGNATURES=$(uci get autoupdater.default.good_signatures)
BRANCH=$(uci get autoupdater.default.branch)
BASE=$(uci get autoupdater.${BRANCH}.url)
PUBKEYS=$(uci get autoupdater.${BRANCH}.pubkey)
GOOD_SIGNATURES=$(uci get autoupdater.${BRANCH}.good_signatures)
VERSION_FILE=/lib/gluon/release

View File

@ -0,0 +1,44 @@
my $cfg = $CONFIG->{autoupdater};
print <<'END';
#/bin/sh
uci -q get autoupdater.settings || {
uci -q batch <<EOF
set autoupdater.settings=autoupdater
END
for (qw(enabled branch)) {
print "set autoupdater.settings.$_=$cfg->{$_}\n";
}
print <<'END';
EOF
}
uci -q batch <<EOF
END
foreach my $name (sort keys $cfg->{branches}) {
my $branch = $cfg->{branches}->{$name};
print <<END;
delete autoupdater.$name
set autoupdater.$name=branch
END
for (qw(url probability good_signatures)) {
print "set autoupdater.$name.$_=$branch->{$_}\n";
}
for (@{$branch->{pubkeys}}) {
print "add_list autoupdater.$name.pubkey=$_\n";
}
}
print <<END;
commit autoupdater
EOF
END

View File

@ -0,0 +1,6 @@
#!/bin/sh
OLD_CFG=/etc/config/config_mode
NEW_CFG=/etc/config/configmode
[ -f $OLD_CFG ] && mv $OLD_CFG $NEW_CFG