From ba7e451bc5c192c3708e01a31350da787e486053 Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Mon, 24 Feb 2020 16:57:38 +0100 Subject: [PATCH] package: drop PKG_VERSION for purely local packages In the package guidelines, PKG_VERSION is supposed to be used as "The upstream version number that we're downloading", while PKG_RELEASE is referred to as "The version of this package Makefile". Thus, the variables in a strict interpretation provide a clear distinction between "their" (upstream) version in PKG_VERSION and "our" (local OpenWrt trunk) version in PKG_RELEASE. For local (OpenWrt-only) packages, this implies that those will only need PKG_RELEASE defined, while PKG_VERSION does not apply following a strict interpretation. While the majority of "our" packages actually follow that scheme, there are also some that mix both variables or have one of them defined but keep them at "1". This is misleading and confusing, which can be observed by the fact that there typically either one of the variables is never bumped or the choice of the variable to increase depends on the person doing the change. Consequently, this patch aims at clarifying the situation by consistently using only PKG_RELEASE for "our" packages. To achieve that, PKG_VERSION is removed there, bumping PKG_RELEASE where necessary to ensure the resulting package version string is bigger than before. During adjustment, one has to make sure that the new resulting composite package version will not be considered "older" than the previous one. A useful tool for evaluating that is 'opkg compare-versions'. In principle, there are the following cases: 1. Sole PKG_VERSION replaced by sole PKG_RELEASE: In this case, the resulting version string does not change, it's just the value of the variable put in the file. Consequently, we do not bump the number in these cases so nobody is tempted to install the same package again. 2. PKG_VERSION and PKG_RELEASE replaced by sole PKG_RELEASE: In this case, the resulting version string has been "version-release", e.g. 1-3 or 1.0-3. For this case, the new PKG_RELEASE will just need to be higher than the previous PKG_VERSION. For the cases where PKG_VERSION has always sticked to "1", and PKG_RELEASE has been incremented, we take the most recent value of PKG_RELEASE. Apart from that, a few packages appear to have developed their own complex versioning scheme, e.g. using x.y.z number for PKG_VERSION _and_ a PKG_RELEASE (qos-scripts) or using dates for PKG_VERSION (adb-enablemodem, wwan). I didn't touch these few in this patch. Cc: Hans Dedecker Cc: Felix Fietkau Cc: Andre Valentin Cc: Matthias Schiffer Cc: Jo-Philipp Wich Cc: Steven Barth Cc: Daniel Golle Cc: John Crispin Signed-off-by: Adrian Schmutzler --- package/kernel/om-watchdog/Makefile | 1 - package/kernel/trelay/Makefile | 1 - package/network/config/gre/Makefile | 4 +- package/network/config/gre/files/gre.sh | 21 +++-- package/network/config/ipip/Makefile | 4 +- package/network/config/ipip/files/ipip.sh | 2 - package/network/config/vti/Makefile | 4 +- package/network/config/vti/files/vti.sh | 2 - package/network/config/xfrm/Makefile | 38 +++++++++ package/network/config/xfrm/files/xfrm.sh | 69 +++++++++++++++ package/network/ipv6/464xlat/Makefile | 2 +- package/network/ipv6/6in4/Makefile | 3 +- package/network/ipv6/6rd/Makefile | 3 +- package/network/ipv6/6to4/Makefile | 3 +- package/network/ipv6/ds-lite/Makefile | 3 +- package/network/ipv6/map/Makefile | 3 +- package/network/utils/rssileds/Makefile | 3 +- package/system/urandom-seed/Makefile | 13 ++- .../files/lib/preinit/81_urandom_seed | 0 package/system/zram-swap/Makefile | 3 +- package/system/zram-swap/files/zram.init | 85 +++++++++++++++++-- 21 files changed, 218 insertions(+), 49 deletions(-) create mode 100644 package/network/config/xfrm/Makefile create mode 100755 package/network/config/xfrm/files/xfrm.sh mode change 100755 => 100644 package/system/urandom-seed/files/lib/preinit/81_urandom_seed diff --git a/package/kernel/om-watchdog/Makefile b/package/kernel/om-watchdog/Makefile index 403069b816..a7e859dc8b 100644 --- a/package/kernel/om-watchdog/Makefile +++ b/package/kernel/om-watchdog/Makefile @@ -9,7 +9,6 @@ include $(TOPDIR)/rules.mk PKG_NAME:=om-watchdog PKG_RELEASE:=2 -PKG_VERSION:=1 include $(INCLUDE_DIR)/package.mk diff --git a/package/kernel/trelay/Makefile b/package/kernel/trelay/Makefile index 258cbb184a..72d41aa60c 100644 --- a/package/kernel/trelay/Makefile +++ b/package/kernel/trelay/Makefile @@ -9,7 +9,6 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=trelay -PKG_VERSION:=0.1 PKG_RELEASE:=2 include $(INCLUDE_DIR)/package.mk diff --git a/package/network/config/gre/Makefile b/package/network/config/gre/Makefile index a7e8612c6c..b16dd72cde 100644 --- a/package/network/config/gre/Makefile +++ b/package/network/config/gre/Makefile @@ -8,8 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=gre -PKG_VERSION:=1 -PKG_RELEASE:=9 +PKG_RELEASE:=12 PKG_LICENSE:=GPL-2.0 include $(INCLUDE_DIR)/package.mk @@ -24,6 +23,7 @@ define Package/gre TITLE:=Generic Routing Encapsulation config support DEPENDS:=+kmod-gre +IPV6:kmod-gre6 +resolveip PROVIDES:=grev4 grev6 + PKGARCH:=all endef define Package/gre/description diff --git a/package/network/config/gre/files/gre.sh b/package/network/config/gre/files/gre.sh index ca11e87cfd..eb3df5b48c 100755 --- a/package/network/config/gre/files/gre.sh +++ b/package/network/config/gre/files/gre.sh @@ -13,10 +13,9 @@ gre_generic_setup() { local local="$3" local remote="$4" local link="$5" - local mtu ttl tos zone ikey okey icsum ocsum iseqno oseqno multicast - json_get_vars mtu ttl tos zone ikey okey icsum ocsum iseqno oseqno multicast + local mtu ipv6 ttl tos zone ikey okey icsum ocsum iseqno oseqno multicast + json_get_vars mtu ipv6 ttl tos zone ikey okey icsum ocsum iseqno oseqno multicast - [ -z "$zone" ] && zone="wan" [ -z "$multicast" ] && multicast=1 proto_init_update "$link" 1 @@ -24,6 +23,7 @@ gre_generic_setup() { proto_add_tunnel json_add_string mode "$mode" json_add_int mtu "${mtu:-1280}" + json_add_boolean ipv6 "${ipv6:-1}" [ -n "$df" ] && json_add_boolean df "$df" [ -n "$ttl" ] && json_add_int ttl "$ttl" [ -n "$tos" ] && json_add_string tos "$tos" @@ -57,7 +57,7 @@ gre_setup() { local remoteip local ipaddr peeraddr - json_get_vars df ipaddr peeraddr tunlink + json_get_vars df ipaddr peeraddr tunlink nohostroute [ -z "$peeraddr" ] && { proto_notify_error "$cfg" "MISSING_PEER_ADDRESS" @@ -77,7 +77,9 @@ gre_setup() { break done - ( proto_add_host_dependency "$cfg" "$peeraddr" "$tunlink" ) + if [ "${nohostroute}" != "1" ]; then + ( proto_add_host_dependency "$cfg" "$peeraddr" "$tunlink" ) + fi [ -z "$ipaddr" ] && { local wanif="$tunlink" @@ -134,7 +136,7 @@ grev6_setup() { local remoteip6 local ip6addr peer6addr weakif - json_get_vars ip6addr peer6addr tunlink weakif encaplimit + json_get_vars ip6addr peer6addr tunlink weakif encaplimit nohostroute [ -z "$peer6addr" ] && { proto_notify_error "$cfg" "MISSING_PEER_ADDRESS" @@ -154,7 +156,9 @@ grev6_setup() { break done - ( proto_add_host_dependency "$cfg" "$peer6addr" "$tunlink" ) + if [ "${nohostroute}" != "1" ]; then + ( proto_add_host_dependency "$cfg" "$peer6addr" "$tunlink" ) + fi [ -z "$ip6addr" ] && { local wanif="$tunlink" @@ -245,6 +249,7 @@ gre_generic_init_config() { available=1 proto_config_add_int "mtu" + proto_config_add_boolean "ipv6" proto_config_add_int "ttl" proto_config_add_string "tos" proto_config_add_string "tunlink" @@ -263,6 +268,7 @@ proto_gre_init_config() { proto_config_add_string "ipaddr" proto_config_add_string "peeraddr" proto_config_add_boolean "df" + proto_config_add_boolean "nohostroute" } proto_gretap_init_config() { @@ -276,6 +282,7 @@ proto_grev6_init_config() { proto_config_add_string "peer6addr" proto_config_add_string "weakif" proto_config_add_string "encaplimit" + proto_config_add_boolean "nohostroute" } proto_grev6tap_init_config() { diff --git a/package/network/config/ipip/Makefile b/package/network/config/ipip/Makefile index 9bdb13c6bc..c262182558 100644 --- a/package/network/config/ipip/Makefile +++ b/package/network/config/ipip/Makefile @@ -8,8 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ipip -PKG_VERSION:=1 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_LICENSE:=GPL-2.0 include $(INCLUDE_DIR)/package.mk @@ -20,6 +19,7 @@ define Package/ipip MAINTAINER:=Hans Dedecker TITLE:=IP in IP Tunnel config support DEPENDS:= +kmod-ipip +resolveip + PKGARCH:=all endef define Package/ipip/description diff --git a/package/network/config/ipip/files/ipip.sh b/package/network/config/ipip/files/ipip.sh index f1c94d6eed..15b1c978e3 100755 --- a/package/network/config/ipip/files/ipip.sh +++ b/package/network/config/ipip/files/ipip.sh @@ -47,8 +47,6 @@ proto_ipip_setup() { fi } - [ -z "$zone" ] && zone="wan" - proto_init_update "ipip-$cfg" 1 proto_add_tunnel diff --git a/package/network/config/vti/Makefile b/package/network/config/vti/Makefile index 0a4657c94e..ffac77ab91 100644 --- a/package/network/config/vti/Makefile +++ b/package/network/config/vti/Makefile @@ -8,8 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=vti -PKG_VERSION:=1 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_LICENSE:=GPL-2.0 include $(INCLUDE_DIR)/package.mk @@ -18,6 +17,7 @@ define Package/vti/Default SECTION:=net CATEGORY:=Network MAINTAINER:=Andre Valentin + PKGARCH:=all endef define Package/vti diff --git a/package/network/config/vti/files/vti.sh b/package/network/config/vti/files/vti.sh index 0443800a0c..ebfd9d41e1 100755 --- a/package/network/config/vti/files/vti.sh +++ b/package/network/config/vti/files/vti.sh @@ -16,8 +16,6 @@ vti_generic_setup() { local mtu zone ikey json_get_vars mtu zone ikey okey - [ -z "$zone" ] && zone="wan" - proto_init_update "$link" 1 proto_add_tunnel diff --git a/package/network/config/xfrm/Makefile b/package/network/config/xfrm/Makefile new file mode 100644 index 0000000000..1b3b99adb0 --- /dev/null +++ b/package/network/config/xfrm/Makefile @@ -0,0 +1,38 @@ + +include $(TOPDIR)/rules.mk + +PKG_NAME:=xfrm +PKG_RELEASE:=2 +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk + +define Package/xfrm/Default + SECTION:=net + CATEGORY:=Network + MAINTAINER:=Andre Valentin + PKGARCH:=all +endef + +define Package/xfrm +$(call Package/xfrm/Default) + TITLE:=XFRM IPsec Tunnel Interface config support + DEPENDS:=+kmod-xfrm-interface +endef + +define Package/xfrm/description + XFRM IPsec Tunnel Interface config support (IPv4 and IPv6) in /etc/config/network. +endef + +define Build/Compile +endef + +define Build/Configure +endef + +define Package/xfrm/install + $(INSTALL_DIR) $(1)/lib/netifd/proto + $(INSTALL_BIN) ./files/xfrm.sh $(1)/lib/netifd/proto/xfrm.sh +endef + +$(eval $(call BuildPackage,xfrm)) diff --git a/package/network/config/xfrm/files/xfrm.sh b/package/network/config/xfrm/files/xfrm.sh new file mode 100755 index 0000000000..1bd1958726 --- /dev/null +++ b/package/network/config/xfrm/files/xfrm.sh @@ -0,0 +1,69 @@ +#!/bin/sh + +[ -n "$INCLUDE_ONLY" ] || { + . /lib/functions.sh + . /lib/functions/network.sh + . ../netifd-proto.sh + init_proto "$@" +} + +proto_xfrm_setup() { + local cfg="$1" + local mode="xfrm" + + local tunlink ifid mtu zone + json_get_vars tunlink ifid mtu zone + + [ -z "$tunlink" ] && { + proto_notify_error "$cfg" NO_TUNLINK + proto_block_restart "$cfg" + exit + } + + [ -z "$ifid" ] && { + proto_notify_error "$cfg" NO_IFID + proto_block_restart "$cfg" + exit + } + + ( proto_add_host_dependency "$cfg" '' "$tunlink" ) + + proto_init_update "$cfg" 1 + + proto_add_tunnel + json_add_string mode "$mode" + json_add_int mtu "${mtu:-1280}" + + json_add_string link "$tunlink" + + json_add_object 'data' + [ -n "$ifid" ] && json_add_int ifid "$ifid" + json_close_object + + proto_close_tunnel + + proto_add_data + [ -n "$zone" ] && json_add_string zone "$zone" + proto_close_data + + proto_send_update "$cfg" +} + +proto_xfrm_teardown() { + local cfg="$1" +} + +proto_xfrm_init_config() { + no_device=1 + available=1 + + proto_config_add_int "mtu" + proto_config_add_string "tunlink" + proto_config_add_string "zone" + proto_config_add_int "ifid" +} + + +[ -n "$INCLUDE_ONLY" ] || { + [ -f /lib/modules/$(uname -r)/xfrm_interface.ko -o -d /sys/module/xfrm_interface ] && add_protocol xfrm +} diff --git a/package/network/ipv6/464xlat/Makefile b/package/network/ipv6/464xlat/Makefile index f4dce2e77d..c792323235 100644 --- a/package/network/ipv6/464xlat/Makefile +++ b/package/network/ipv6/464xlat/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=464xlat -PKG_VERSION:=12 +PKG_RELEASE:=12 PKG_SOURCE_DATE:=2018-01-16 PKG_MAINTAINER:=Hans Dedecker diff --git a/package/network/ipv6/6in4/Makefile b/package/network/ipv6/6in4/Makefile index 8ff4730e74..08696ef7a8 100644 --- a/package/network/ipv6/6in4/Makefile +++ b/package/network/ipv6/6in4/Makefile @@ -8,8 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=6in4 -PKG_VERSION:=25 -PKG_RELEASE:=1 +PKG_RELEASE:=26 PKG_LICENSE:=GPL-2.0 include $(INCLUDE_DIR)/package.mk diff --git a/package/network/ipv6/6rd/Makefile b/package/network/ipv6/6rd/Makefile index 47f20414fc..9836ae9361 100644 --- a/package/network/ipv6/6rd/Makefile +++ b/package/network/ipv6/6rd/Makefile @@ -8,8 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=6rd -PKG_VERSION:=9 -PKG_RELEASE:=4 +PKG_RELEASE:=10 PKG_LICENSE:=GPL-2.0 include $(INCLUDE_DIR)/package.mk diff --git a/package/network/ipv6/6to4/Makefile b/package/network/ipv6/6to4/Makefile index 32d7b325aa..dfb66aaae2 100644 --- a/package/network/ipv6/6to4/Makefile +++ b/package/network/ipv6/6to4/Makefile @@ -8,8 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=6to4 -PKG_VERSION:=12 -PKG_RELEASE:=2 +PKG_RELEASE:=13 PKG_LICENSE:=GPL-2.0 include $(INCLUDE_DIR)/package.mk diff --git a/package/network/ipv6/ds-lite/Makefile b/package/network/ipv6/ds-lite/Makefile index 198b6ebcc7..502da366a9 100644 --- a/package/network/ipv6/ds-lite/Makefile +++ b/package/network/ipv6/ds-lite/Makefile @@ -8,8 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ds-lite -PKG_VERSION:=7 -PKG_RELEASE:=4 +PKG_RELEASE:=8 PKG_LICENSE:=GPL-2.0 include $(INCLUDE_DIR)/package.mk diff --git a/package/network/ipv6/map/Makefile b/package/network/ipv6/map/Makefile index f05f216a4c..5d0e0bbd3d 100644 --- a/package/network/ipv6/map/Makefile +++ b/package/network/ipv6/map/Makefile @@ -8,8 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=map -PKG_VERSION:=4 -PKG_RELEASE:=13 +PKG_RELEASE:=5 PKG_LICENSE:=GPL-2.0 include $(INCLUDE_DIR)/package.mk diff --git a/package/network/utils/rssileds/Makefile b/package/network/utils/rssileds/Makefile index 7a59314693..892b9f2c51 100644 --- a/package/network/utils/rssileds/Makefile +++ b/package/network/utils/rssileds/Makefile @@ -8,8 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=rssileds -PKG_VERSION:=0.2 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_LICNESE:=GPL-2.0+ include $(INCLUDE_DIR)/package.mk diff --git a/package/system/urandom-seed/Makefile b/package/system/urandom-seed/Makefile index 6bde2e0b8a..7cb7c72038 100644 --- a/package/system/urandom-seed/Makefile +++ b/package/system/urandom-seed/Makefile @@ -1,20 +1,17 @@ include $(TOPDIR)/rules.mk PKG_NAME:=urandom-seed -PKG_VERSION:=1.0 -PKG_RELEASE:=1 -PKG_LICENSE:=GPL-2.0 - -PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) +PKG_RELEASE:=2 +PKG_LICENSE:=GPL-2.0-only include $(INCLUDE_DIR)/package.mk -define Package/$(PKG_NAME) +define Package/urandom-seed SECTION:=base CATEGORY:=Base system DEPENDS:=+getrandom TITLE:=/etc/urandom.seed handling for OpenWrt - URL:=http://openwrt.org/ + URL:=https://openwrt.org/ endef define Build/Prepare @@ -25,7 +22,7 @@ define Build/Compile/Default endef Build/Compile = $(Build/Compile/Default) -define Package/$(PKG_NAME)/install +define Package/urandom-seed/install $(CP) ./files/* $(1)/ endef diff --git a/package/system/urandom-seed/files/lib/preinit/81_urandom_seed b/package/system/urandom-seed/files/lib/preinit/81_urandom_seed old mode 100755 new mode 100644 diff --git a/package/system/zram-swap/Makefile b/package/system/zram-swap/Makefile index 87ffaae068..4422c351ea 100644 --- a/package/system/zram-swap/Makefile +++ b/package/system/zram-swap/Makefile @@ -8,8 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=zram-swap -PKG_VERSION:=1.1 -PKG_RELEASE:=2 +PKG_RELEASE:=5 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) diff --git a/package/system/zram-swap/files/zram.init b/package/system/zram-swap/files/zram.init index 9df9d7d22b..a6126e578f 100755 --- a/package/system/zram-swap/files/zram.init +++ b/package/system/zram-swap/files/zram.init @@ -2,17 +2,21 @@ START=15 -ram_size() +EXTRA_COMMANDS="compact status" +EXTRA_HELP=" compact trigger compaction for all Z-RAM swap dev's + status print out status information & statistics about Z-RAM swap devices" + +ram_getsize() { local line while read line; do case "$line" in MemTotal:*) set $line; echo "$2"; break ;; esac; done $zdev/compact + + # If not running interactively, than just return + [ -z "$PS1" ] && return 0 + + echo "" + echo "Compacting zram device $zdev" + awk -v old_mem="$old_mem_used" -v ovr="$old_overhead" 'BEGIN { fmt = "%-25s - %.1f %s\n" } + { printf fmt, "Memory usage reduced by ", (old_mem-$3)/1024/1024, "MiB" + printf fmt, "Overhead reduced by", (ovr-($3-$2))/ovr*100, "%" }' <$zdev/mm_stat +} + start() { - local zram_size="$( zram_size )" - local zram_dev - if [ $( grep -cs zram /proc/swaps ) -ne 0 ]; then logger -s -t zram_start -p daemon.notice "[OK] zram swap is already mounted" return 1 fi - zram_dev="$( zram_getdev )" + local zram_size="$( zram_getsize )" + local zram_dev="$( zram_getdev )" zram_applicable "$zram_dev" || return 1 + local zram_priority="$( uci -q get system.@system[0].zram_priority )" + zram_priority=${zram_priority:+-p $zram_priority} logger -s -t zram_start -p daemon.debug "activating '$zram_dev' for swapping ($zram_size MegaBytes)" @@ -144,3 +200,18 @@ stop() } done } +# show memory stats for all zram swaps +status() +{ + for zram_dev in $( grep zram /proc/swaps |awk '{print $1}' ); do { + zram_stats "$zram_dev" + } done +} + +# trigger compaction for all zram swaps +compact() +{ + for zram_dev in $( grep zram /proc/swaps |awk '{print $1}' ); do { + zram_compact "$zram_dev" + } done +}