Merge ~fourdollars/pc-enablement/+git/oem-scripts:master into ~oem-solutions-engineers/pc-enablement/+git/oem-scripts:master

Proposed by Shih-Yuan Lee
Status: Merged
Approved by: Shih-Yuan Lee
Approved revision: 181c9f8261ed8ec531a24990f7a2441e9eed6575
Merged at revision: 81ea3aa8aa449a6e65b58b867a9eb4b78ed1ec5b
Proposed branch: ~fourdollars/pc-enablement/+git/oem-scripts:master
Merge into: ~oem-solutions-engineers/pc-enablement/+git/oem-scripts:master
Diff against target: 253 lines (+110/-13)
4 files modified
debian/changelog (+8/-0)
debian/tests/oem-meta-packages (+12/-5)
mir-bug (+71/-2)
oem-meta-packages (+19/-6)
Reviewer Review Type Date Requested Status
Yuan-Chen Cheng (community) Approve
Review via email: mp+406227@code.launchpad.net

Description of the change

./mir-bug -q check 1891988 --json ~/projects/oem-hw-info/platform-info/somerville/fossa-beric-tgl.json
...
diff --git a/debian/control b/debian/control
index 0a41830..271e6f9 100644
--- a/debian/control
+++ b/debian/control
@@ -12,6 +12,6 @@ Architecture: all
 Depends: ${misc:Depends}, ubuntu-oem-keyring
 XB-Modaliases: ${modaliases}
 XB-Ubuntu-OEM-Kernel-Flavour: oem
-Description: hardware support for Somerville Beric-Tgl platform
- This is a metapackage for Somerville Beric-Tgl platform. It installs
+Description: hardware support for Dell Inspiron 3501, Vostro 3400/3500
+ This is a metapackage for Dell Inspiron 3501, Vostro 3400/3500. It installs
  packages needed to support this hardware fully.
...

$ ./mir-bug -q check 1925019 --json ~/projects/oem-hw-info/platform-info/stella.cmit/fossa-rattata.json
...
diff --git a/debian/control b/debian/control
index 07aa4b2..fd6d608 100644
--- a/debian/control
+++ b/debian/control
@@ -12,6 +12,6 @@ Architecture: all
 Depends: ${misc:Depends}, ubuntu-oem-keyring
 XB-Modaliases: ${modaliases}
 XB-Ubuntu-OEM-Kernel-Flavour: oem
-Description: hardware support for Stella Cmit Rattata platform
- This is a metapackage for Stella Cmit Rattata platform. It installs
+Description: hardware support for HP ProBook 440 G8 Notebook PC
+ This is a metapackage for HP ProBook 440 G8 Notebook PC. It installs
  packages needed to support this hardware fully.
...

$ ./mir-bug -q check 1924726 --json ~/projects/oem-hw-info/platform-info/sutton.newell/fossa-aelfwine.json
...
diff --git a/debian/control b/debian/control
index af0527e..8172068 100644
--- a/debian/control
+++ b/debian/control
@@ -12,14 +12,13 @@ Architecture: all
 Depends: ${misc:Depends}, ubuntu-oem-keyring, linux-oem-20.04b | linux-oem-20.04, oem-sutton.newell-meta
 XB-Modaliases: ${modaliases}
 XB-Ubuntu-OEM-Kernel-Flavour: oem
-Description: hardware support for Sutton Newell Aelfwine platform
- This is a metapackage for Sutton Newell Aelfwine platform. It installs
+Description: hardware support for Lenovo ThinkPad T14s Gen 2, X13 Gen 2
+ This is a metapackage for Lenovo ThinkPad T14s Gen 2, X13 Gen 2. It installs
  packages needed to support this hardware fully.

 Package: oem-sutton.newell-factory-aelfwine-meta
 Architecture: all
 Depends: ${misc:Depends}, oem-sutton.newell-factory-meta
-Suggests: lenovo-doc-aelfwine
-Description: hardware support for Sutton Newell Aelfwine platform (factory)
- This is a factory metapackage for Sutton Newell Aelfwine platform.
+Description: hardware support for Lenovo ThinkPad T14s Gen 2, X13 Gen 2 (factory)
+ This is a factory metapackage for Lenovo ThinkPad T14s Gen 2, X13 Gen 2.
  It installs packages needed to support this hardware fully. (factory)
...

To post a comment you must log in.
Revision history for this message
Shih-Yuan Lee (fourdollars) wrote :

[BOT]
$ cat oem-scripts-1.5-181c9f8-in-docker-focal-summary.log
autopkgtest-collect-credentials PASS
autopkgtest-oem-scripts-auto PASS
pkg-somerville-meta PASS
pkg-stella-meta PASS
pkg-sutton-meta PASS
bug-bind PASS
get-private-ppa PASS
jq-lp PASS
launchpad-api PASS
lp-bug PASS
oem-meta-packages PASS
pkg-list PASS
review-merge-proposal PASS
run-autopkgtest PASS
setup-apt-dir PASS
mir-bug SKIP exit status 77 and marked as skippable
git-url-insteadof-setting PASS
recovery-from-iso.sh PASS
mir-bug-verification PASS
https://paste.ubuntu.com/p/MmhYx3PgBN/ oem-scripts-1.5-181c9f8-in-docker-focal-complete.log

Revision history for this message
Yuan-Chen Cheng (ycheng-twn) wrote :

I am not a fan of re-use variable like this

+ if args.json:
+ args.json = json.load(args.json)

other look good. Up to the author to change it or not.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 676969f..9180f60 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,11 @@
6+oem-scripts (1.5) UNRELEASED; urgency=medium
7+
8+ * oem-meta-packages: Make the '--output' of the 'collect' subcommand
9+ unnecessary.
10+ * mir-bug: Make it able to read the product names from the platform json.
11+
12+ -- Shih-Yuan Lee (FourDollars) <sylee@canonical.com> Mon, 19 Jul 2021 18:09:17 +0800
13+
14 oem-scripts (1.4) focal; urgency=medium
15
16 * debian/tests/mir-bug-verification: Workaround for update-grub in Linux
17diff --git a/debian/tests/oem-meta-packages b/debian/tests/oem-meta-packages
18index de367d5..65466a7 100644
19--- a/debian/tests/oem-meta-packages
20+++ b/debian/tests/oem-meta-packages
21@@ -24,7 +24,7 @@ cat > platforms.json << ENDLINE
22 "Customer": "Dell",
23 "Group": "N/A",
24 "Codename": "fossa-beric-icl",
25- "Platform": "Bullseye N3 15 ICL-U(SMB0) ",
26+ "Platform": "Bullseye N3 15 ICL-U(SMB0)",
27 "MarketName": "Inspiron 3501",
28 "PlatformLPTag": "fossa-beric-icl"
29 }
30@@ -35,10 +35,17 @@ export LAUNCHPAD_API="https://api.launchpad.net/"
31
32 oem-meta-packages --quiet list
33
34-oem-meta-packages --quiet collect --json platforms.json -o meta-info.json
35-jq -r < meta-info.json
36-oem-meta-packages --quiet collect --meta oem-somerville-beric-icl-meta -o meta-info.json
37-jq -r < meta-info.json
38+oem-meta-packages --quiet collect --json platforms.json # --output meta-info.json (by default)
39+if [ "x$(jq -r '."oem-somerville-beric-icl-meta".new_desc' < meta-info.json)" != "xDell Inspiron 3501, Vostro 3401/3501" ]; then
40+ jq -S -M < meta-info.json
41+ exit 1
42+fi
43+
44+oem-meta-packages --quiet collect --meta oem-somerville-beric-icl-meta # --output oem-somerville-beric-icl-meta.json (by default)
45+if [ "x$(jq -r '."oem-somerville-beric-icl-meta".oem.git.market_name' < oem-somerville-beric-icl-meta.json)" != "xInspiron 3501, Vostro 3401/3501" ]; then
46+ jq -S -M < oem-somerville-beric-icl-meta.json
47+ exit 1
48+fi
49
50 oem-meta-packages --dry-run update --json meta-info.json
51
52diff --git a/mir-bug b/mir-bug
53index 37f38fc..f954f62 100755
54--- a/mir-bug
55+++ b/mir-bug
56@@ -19,6 +19,7 @@
57 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
58
59 import argparse
60+import collections
61 import difflib
62 import json
63 import lazr
64@@ -100,6 +101,11 @@ update.add_argument(
65 action="store_true",
66 help="Update the bug to Fix Committed, also affects 'Ubuntu', and subscribe 'ubuntu-sponsors' and 'ubuntu-desktop'.",
67 )
68+update.add_argument(
69+ "--json",
70+ help="Specify the platform json file to read the information.",
71+ type=argparse.FileType("r", encoding="UTF-8"),
72+)
73
74 check = subparsers.add_parser(
75 "check", help="[-h] [--ready] [--skip] [--tz=UTC-8] bugNumber"
76@@ -120,6 +126,11 @@ check.add_argument(
77 action="store_true",
78 help="Check if the bug is Fix Committed, also affects 'Ubuntu', and subscribe 'ubuntu-sponsors' and 'ubuntu-desktop'.",
79 )
80+check.add_argument(
81+ "--json",
82+ help="Specify the platform json file to read the information.",
83+ type=argparse.FileType("r", encoding="UTF-8"),
84+)
85
86 collect = subparsers.add_parser("collect", help="[-h] [--ubuntu-certified] jsonFile")
87 collect.add_argument(
88@@ -197,6 +208,38 @@ Please use "oem-metapackage-mir-check" in lp:ubuntu-archive-tools to verify this
89 pattern = re.compile(r".*\[MIR\]\W*oem-([^-]*)-(.*)-meta\W*")
90
91
92+# Python 3.9 supports this.
93+def remove_prefix(s, prefix):
94+ return s[len(prefix) :] if s.startswith(prefix) else s
95+
96+
97+def _grouping_market_names(market_names: list, maxsplit=1) -> str:
98+ # Remove empty item
99+ while "" in market_names:
100+ market_names.remove("")
101+ tmp = collections.defaultdict(list)
102+ space_in_model = False
103+ try:
104+ for market_name in sorted(market_names):
105+ if maxsplit == 1:
106+ name, model = market_name.split(maxsplit=maxsplit)
107+ tmp[name].append(model)
108+ if " " in model:
109+ space_in_model = True
110+ elif maxsplit == 2:
111+ brand, name, model = market_name.split(maxsplit=maxsplit)
112+ tmp[brand + " " + name].append(model)
113+ if " " in model:
114+ space_in_model = True
115+ except ValueError:
116+ return ", ".join(sorted(market_names))
117+
118+ if space_in_model:
119+ return ", ".join(f"{name} {', '.join(models)}" for name, models in tmp.items())
120+ else:
121+ return ", ".join(f"{name} {'/'.join(models)}" for name, models in tmp.items())
122+
123+
124 def create_bug(lp, oemCodename, platformCodename, deviceName):
125 info("Creating bug...")
126 tempList = oemCodename.split(".")
127@@ -963,6 +1006,28 @@ def check_and_update_git_repo(
128 kernel_flavour, kernel_meta, market_name, ids = _get_items_from_git(
129 project, branch, pkg_name
130 )
131+
132+ if args.json:
133+ if group == "cmit":
134+ new_market_name = _grouping_market_names(
135+ args.json["productnames"], maxsplit=2
136+ )
137+ new_market_name = remove_prefix(new_market_name, "HP ")
138+ else:
139+ new_market_name = _grouping_market_names(args.json["productnames"])
140+ if market_name is None:
141+ market_name = new_market_name
142+ if market_name != new_market_name:
143+ if args.skip or not update:
144+ warning(
145+ f"You may need to use '{new_market_name}' instead of '{market_name}'?"
146+ )
147+ elif yes_or_ask(
148+ yes,
149+ f"Do you want to use '{new_market_name}' instead of '{market_name}'?",
150+ ):
151+ market_name = new_market_name
152+
153 if kernel_flavour == "default":
154 if kernel_meta is None:
155 kernel_meta = "linux-generic-hwe-20.04"
156@@ -970,7 +1035,7 @@ def check_and_update_git_repo(
157 pass
158 else:
159 critical(
160- f"{pkg_name}'s {branch} branch has unexpected kernel_flavour=${kernel_flavour}, kernel_meta={kernel_meta}."
161+ f"{pkg_name}'s {branch} branch has unexpected kernel_flavour={kernel_flavour}, kernel_meta={kernel_meta}."
162 )
163 exit(1)
164 elif kernel_flavour == "oem":
165@@ -980,7 +1045,7 @@ def check_and_update_git_repo(
166 pass
167 else:
168 critical(
169- f"{pkg_name}'s {branch} branch has unexpected kernel_flavour=${kernel_flavour}, kernel_meta={kernel_meta}."
170+ f"{pkg_name}'s {branch} branch has unexpected kernel_flavour={kernel_flavour}, kernel_meta={kernel_meta}."
171 )
172 exit(1)
173
174@@ -1142,8 +1207,12 @@ if args.subcommand:
175 if args.subcommand == "create":
176 create_bug(lp, args.oemCodename, args.platformCodename, args.deviceName)
177 elif args.subcommand == "update":
178+ if args.json:
179+ args.json = json.load(args.json)
180 update_bug(lp, args.bugNumber, args.yes)
181 elif args.subcommand == "check":
182+ if args.json:
183+ args.json = json.load(args.json)
184 check_bug(lp, args.bugNumber)
185 elif args.subcommand == "collect":
186 collect_bugs(lp, args.json)
187diff --git a/oem-meta-packages b/oem-meta-packages
188index ad37f43..24d7d4b 100755
189--- a/oem-meta-packages
190+++ b/oem-meta-packages
191@@ -166,11 +166,11 @@ subparsers = parser.add_subparsers(dest="subcommand")
192
193 collect = subparsers.add_parser(
194 "collect",
195- help="[-h] --json platforms.json | --meta oem-qemu-meta -o|--output meta-info.json",
196+ help="[-h] --json platforms.json | --meta oem-qemu-meta [-o|--output meta-info.json]",
197 formatter_class=argparse.RawDescriptionHelpFormatter,
198 epilog="""
199 For example,
200- oem-meta-packages collect --json platforms.json --output meta-info.json
201+ oem-meta-packages collect --json platforms.json [--output meta-info.json]
202
203 platforms.json:
204
205@@ -204,7 +204,7 @@ platforms.json:
206 ...
207 ]
208
209-oem-meta-packages collect --meta oem-qemu-meta --output meta-info.json
210+oem-meta-packages collect --meta oem-qemu-meta [--output oem-qemu-meta.json]
211
212 Collect the information of OEM metapackages in PPAs and devel/staging archives.""",
213 )
214@@ -220,7 +220,6 @@ collect.add_argument(
215 collect.add_argument(
216 "-o",
217 "--output",
218- required=True,
219 help="Specify a filename to write the meta information.",
220 type=argparse.FileType("w", encoding="UTF-8"),
221 )
222@@ -322,6 +321,7 @@ update.add_argument(
223 )
224
225 args = parser.parse_args()
226+BASEDIR = os.getcwd()
227
228 setup_logging(debug=args.debug, quiet=args.quiet)
229
230@@ -2126,8 +2126,21 @@ elif args.subcommand == "collect":
231 else:
232 print("You need to use --json or --meta.")
233 exit(1)
234- args.output.write(json.dumps(pkgInfo, indent=4, sort_keys=True, cls=CustomEncoder))
235- args.output.write("\n")
236+ if args.output:
237+ args.output.write(
238+ json.dumps(pkgInfo, indent=4, sort_keys=True, cls=CustomEncoder) + "\n"
239+ )
240+ args.output.write("\n")
241+ elif args.json:
242+ with open(f"{BASEDIR}/meta-info.json", "w+") as f:
243+ f.write(
244+ json.dumps(pkgInfo, indent=4, sort_keys=True, cls=CustomEncoder) + "\n"
245+ )
246+ elif args.meta:
247+ with open(f"{BASEDIR}/{args.meta}.json", "w+") as f:
248+ f.write(
249+ json.dumps(pkgInfo, indent=4, sort_keys=True, cls=CustomEncoder) + "\n"
250+ )
251 elif args.subcommand == "staging-copy":
252 oem_scripts_config_ini = os.path.join(
253 os.environ["HOME"], ".config/oem-scripts/config.ini"

Subscribers

People subscribed via source and target branches