Message ID | 20191117225937.5599-1-hauke@hauke-m.de |
---|---|
State | Accepted |
Delegated to: | Hauke Mehrtens |
Headers | show |
Series | [OpenWrt-Devel] wireless-regdb: Make it build with python2 | expand |
Hi Hauke, Le dim. 17 nov. 2019 à 15:00, Hauke Mehrtens <hauke@hauke-m.de> a écrit : > > This backports a patch to build it work with python2 in addition to > python3. Why not make the scripts "/usr/bin/env python3" and require python 3 in 19.07 ? (I'm stuborn but I don't understand trying to keep python2 alive or using unversionned python) Cheers Etienne > > Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> > --- > > After this patch went into master I would like to backport all the > changes for wireless-regdb from master to OpenWrt 19.07. > There are already some changes to the regulatory rules in this database > and I would like to stay close to the current legal guidelines for > OpenWrt 19.07 as well. > > ...regdb-fix-compatibility-with-python2.patch | 58 +++++++++++++++++++ > 1 file changed, 58 insertions(+) > create mode 100644 package/firmware/wireless-regdb/patches/010-regdb-fix-compatibility-with-python2.patch > > diff --git a/package/firmware/wireless-regdb/patches/010-regdb-fix-compatibility-with-python2.patch b/package/firmware/wireless-regdb/patches/010-regdb-fix-compatibility-with-python2.patch > new file mode 100644 > index 0000000000..81f50f5dc0 > --- /dev/null > +++ b/package/firmware/wireless-regdb/patches/010-regdb-fix-compatibility-with-python2.patch > @@ -0,0 +1,58 @@ > +From 651e39dee8605995b736b6056c6f7dc5c5a9c948 Mon Sep 17 00:00:00 2001 > +From: Johannes Berg <johannes.berg@intel.com> > +Date: Thu, 22 Aug 2019 21:46:27 +0200 > +Subject: [PATCH] regdb: fix compatibility with python2 > + > +Various changes in the commit mentioned below broke > +compatibility with python2. Restore it in a way that > +makes it worth with both versions. > + > +Fixes: f3c4969c2485 ("wireless-regdb: make scripts compatible with Python 3") > +Signed-off-by: Johannes Berg <johannes.berg@intel.com> > +Signed-off-by: Seth Forshee <seth.forshee@canonical.com> > +--- > + db2bin.py | 2 +- > + db2fw.py | 2 +- > + dbparse.py | 3 +-- > + 3 files changed, 3 insertions(+), 4 deletions(-) > + > +--- a/db2bin.py > ++++ b/db2bin.py > +@@ -118,7 +118,7 @@ reg_country_ptr.set() > + for alpha2 in countrynames: > + coll = countries[alpha2] > + # struct regdb_file_reg_country > +- output.write(struct.pack('>BBxBI', alpha2[0], alpha2[1], coll.dfs_region, reg_rules_collections[coll.permissions])) > ++ output.write(struct.pack('>2sxBI', alpha2, coll.dfs_region, reg_rules_collections[coll.permissions])) > + > + > + if len(sys.argv) > 3: > +--- a/db2fw.py > ++++ b/db2fw.py > +@@ -85,7 +85,7 @@ countrynames = list(countries) > + countrynames.sort() > + for alpha2 in countrynames: > + coll = countries[alpha2] > +- output.write(struct.pack('>BB', alpha2[0], alpha2[1])) > ++ output.write(struct.pack('>2s', alpha2)) > + country_ptrs[alpha2] = PTR(output) > + output.write(b'\x00' * 4) > + > +--- a/dbparse.py > ++++ b/dbparse.py > +@@ -1,6 +1,5 @@ > + #!/usr/bin/env python > + > +-from builtins import bytes > + from functools import total_ordering > + import sys, math > + from math import ceil, log > +@@ -359,7 +358,7 @@ class DBParser(object): > + for cname in cnames: > + if len(cname) != 2: > + self._warn("country '%s' not alpha2" % cname) > +- cname = bytes(cname, 'ascii') > ++ cname = cname.encode('ascii') > + if not cname in self._countries: > + self._countries[cname] = Country(dfs_region, comments=self._comments) > + self._current_countries[cname] = self._countries[cname] > -- > 2.20.1 > > > _______________________________________________ > openwrt-devel mailing list > openwrt-devel@lists.openwrt.org > https://lists.openwrt.org/mailman/listinfo/openwrt-devel
On 18/11/19 08:42, Etienne Champetier wrote: > Hi Hauke, > > Le dim. 17 nov. 2019 à 15:00, Hauke Mehrtens <hauke@hauke-m.de> a écrit : >> This backports a patch to build it work with python2 in addition to >> python3. > Why not make the scripts "/usr/bin/env python3" and require python 3 in 19.07 ? > (I'm stuborn but I don't understand trying to keep python2 alive or > using unversionned python) > > Cheers > Etienne I read some discussion about this on a Github PR. Other scripts that were ported to python3 had issues with python3 later and had to be fixed. They decided that switching all python scripts to python3 in 19.07 release was too risky, especially because it is late already so they are just making sure they are run with python2. Scripts in master are migrated to python3 and will have a lot of time to find bugs and be fixed before next stable release. -Alberto
Hauke Mehrtens <hauke@hauke-m.de> [2019-11-17 23:59:37]: > This backports a patch to build it work with python2 in addition to > python3. > > Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> Acked-by: Petr Štetiar <ynezz@true.cz> > After this patch went into master I would like to backport all the > changes for wireless-regdb from master to OpenWrt 19.07. > There are already some changes to the regulatory rules in this database > and I would like to stay close to the current legal guidelines for > OpenWrt 19.07 as well. Makes sense. -- ynezz
diff --git a/package/firmware/wireless-regdb/patches/010-regdb-fix-compatibility-with-python2.patch b/package/firmware/wireless-regdb/patches/010-regdb-fix-compatibility-with-python2.patch new file mode 100644 index 0000000000..81f50f5dc0 --- /dev/null +++ b/package/firmware/wireless-regdb/patches/010-regdb-fix-compatibility-with-python2.patch @@ -0,0 +1,58 @@ +From 651e39dee8605995b736b6056c6f7dc5c5a9c948 Mon Sep 17 00:00:00 2001 +From: Johannes Berg <johannes.berg@intel.com> +Date: Thu, 22 Aug 2019 21:46:27 +0200 +Subject: [PATCH] regdb: fix compatibility with python2 + +Various changes in the commit mentioned below broke +compatibility with python2. Restore it in a way that +makes it worth with both versions. + +Fixes: f3c4969c2485 ("wireless-regdb: make scripts compatible with Python 3") +Signed-off-by: Johannes Berg <johannes.berg@intel.com> +Signed-off-by: Seth Forshee <seth.forshee@canonical.com> +--- + db2bin.py | 2 +- + db2fw.py | 2 +- + dbparse.py | 3 +-- + 3 files changed, 3 insertions(+), 4 deletions(-) + +--- a/db2bin.py ++++ b/db2bin.py +@@ -118,7 +118,7 @@ reg_country_ptr.set() + for alpha2 in countrynames: + coll = countries[alpha2] + # struct regdb_file_reg_country +- output.write(struct.pack('>BBxBI', alpha2[0], alpha2[1], coll.dfs_region, reg_rules_collections[coll.permissions])) ++ output.write(struct.pack('>2sxBI', alpha2, coll.dfs_region, reg_rules_collections[coll.permissions])) + + + if len(sys.argv) > 3: +--- a/db2fw.py ++++ b/db2fw.py +@@ -85,7 +85,7 @@ countrynames = list(countries) + countrynames.sort() + for alpha2 in countrynames: + coll = countries[alpha2] +- output.write(struct.pack('>BB', alpha2[0], alpha2[1])) ++ output.write(struct.pack('>2s', alpha2)) + country_ptrs[alpha2] = PTR(output) + output.write(b'\x00' * 4) + +--- a/dbparse.py ++++ b/dbparse.py +@@ -1,6 +1,5 @@ + #!/usr/bin/env python + +-from builtins import bytes + from functools import total_ordering + import sys, math + from math import ceil, log +@@ -359,7 +358,7 @@ class DBParser(object): + for cname in cnames: + if len(cname) != 2: + self._warn("country '%s' not alpha2" % cname) +- cname = bytes(cname, 'ascii') ++ cname = cname.encode('ascii') + if not cname in self._countries: + self._countries[cname] = Country(dfs_region, comments=self._comments) + self._current_countries[cname] = self._countries[cname]
This backports a patch to build it work with python2 in addition to python3. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> --- After this patch went into master I would like to backport all the changes for wireless-regdb from master to OpenWrt 19.07. There are already some changes to the regulatory rules in this database and I would like to stay close to the current legal guidelines for OpenWrt 19.07 as well. ...regdb-fix-compatibility-with-python2.patch | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 package/firmware/wireless-regdb/patches/010-regdb-fix-compatibility-with-python2.patch