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 <dedeckeh@gmail.com>
Cc: Felix Fietkau <nbd@nbd.name>
Cc: Andre Valentin <avalentin@marcant.net>
Cc: Matthias Schiffer <mschiffer@universe-factory.net>
Cc: Jo-Philipp Wich <jo@mein.io>
Cc: Steven Barth <steven@midlink.org>
Cc: Daniel Golle <dgolle@allnet.de>
Cc: John Crispin <john@phrozen.org>

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
Adrian Schmutzler 2020-02-24 16:57:38 +01:00 committed by CN_SZTL
parent 6bda55870e
commit ba7e451bc5
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
21 changed files with 218 additions and 49 deletions

View File

@ -9,7 +9,6 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=om-watchdog
PKG_RELEASE:=2
PKG_VERSION:=1
include $(INCLUDE_DIR)/package.mk

View File

@ -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

View File

@ -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

View File

@ -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() {

View File

@ -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 <dedeckeh@gmail.com>
TITLE:=IP in IP Tunnel config support
DEPENDS:= +kmod-ipip +resolveip
PKGARCH:=all
endef
define Package/ipip/description

View File

@ -47,8 +47,6 @@ proto_ipip_setup() {
fi
}
[ -z "$zone" ] && zone="wan"
proto_init_update "ipip-$cfg" 1
proto_add_tunnel

View File

@ -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 <avalentin@marcant.net>
PKGARCH:=all
endef
define Package/vti

View File

@ -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

View File

@ -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 <avalentin@marcant.net>
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))

View File

@ -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
}

View File

@ -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 <dedeckeh@gmail.com>

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

View File

@ -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)

View File

@ -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 </proc/meminfo
}
zram_size() # in megabytes
zram_getsize() # in megabytes
{
local zram_size="$( uci -q get system.@system[0].zram_size_mb )"
local ram_size="$( ram_size )"
local ram_size="$( ram_getsize )"
if [ -z "$zram_size" ]; then
# e.g. 6mb for 16mb-routers or 61mb for 128mb-routers
@ -106,18 +110,70 @@ zram_comp_streams()
fi
}
#print various stats info about zram swap device
zram_stats()
{
local zdev="/sys/block/$( basename "$1" )"
printf "\nGathering stats info for zram device \"$( basename "$1" )\"\n\n"
printf "Z-RAM\n-----\n"
printf "%-25s - %s\n" "Block device" $zdev
awk '{ printf "%-25s - %d MiB\n", "Device size", $1/1024/1024 }' <$zdev/disksize
printf "%-25s - %s\n" "Compression algo" "$(cat $zdev/comp_algorithm)"
printf "%-25s - %s\n" "Compression streams" "$( cat $zdev/max_comp_streams)"
awk 'BEGIN { fmt = "%-25s - %.2f %s\n"
fmt2 = "%-25s - %d\n"
print "\nDATA\n----" }
{ printf fmt, "Original data size", $1/1024/1024, "MiB"
printf fmt, "Compressed data size", $2/1024/1024, "MiB"
printf fmt, "Compress ratio", $1/$2, ""
print "\nMEMORY\n------"
printf fmt, "Memory used, total", $3/1024/1024, "MiB"
printf fmt, "Allocator overhead", ($3-$2)/1024/1024, "MiB"
printf fmt, "Allocator efficiency", $2/$3*100, "%"
printf fmt, "Maximum memory ever used", $5/1024/1024, "MiB"
printf fmt, "Memory limit", $4/1024/1024, "MiB"
print "\nPAGES\n-----"
printf fmt2, "Same pages count", $6
printf fmt2, "Pages compacted", $7 }' <$zdev/mm_stat
awk '{ printf "%-25s - %d\n", "Free pages discarded", $4 }' <$zdev/io_stat
}
zram_compact()
{
# compact zram device (reduce memory allocation overhead)
local zdev="/sys/block/$( basename "$1" )"
local old_mem_used=$(awk '{print $3}' <$zdev/mm_stat)
local old_overhead=$(awk '{print $3-$2}' <$zdev/mm_stat)
echo 1 > $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
}