Skip to content

Commit f9fae6b

Browse files
committed
owut: allow user to ignore removed default packages
Add a mechanism for ignoring missing defaults when doing the default package analysis. Any packages in the ignored list will be flagged as "user ignored" and not be mentioned in the missing-defaults warnings. Signed-off-by: Eric Fahlgren <[email protected]>
1 parent 17a884e commit f9fae6b

File tree

2 files changed

+48
-29
lines changed

2 files changed

+48
-29
lines changed

files/owut

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -146,24 +146,25 @@ ap.ArgActions["rc"] = function(self, params) {
146146
let arg_defs = proto([
147147
ap.DEFAULT_HELP,
148148
ap.DEFAULT_VERSION,
149-
{ name: "command", position: 0, one_of: commands, action: "store", help: "Sub-command to execute" },
150-
{ name: "version_to", short: "-V", long: "--version-to", action: "store", nargs: 1, default: null, help: "Specify the target version, defaults to installed version." },
151-
{ name: "rev_code", short: "-R", long: "--rev-code", action: "rc", nargs: 1, default: null, help: "Specify a 'version_code', literal 'none' allowed, defaults to latest build." },
152-
{ name: "verbosity", short: "-v", long: "--verbose", action: "inc", default: 0, help: "Print various diagnostics. Repeat for even more output." },
153-
{ name: "verbosity", short: "-q", long: "--quiet", action: "dec", default: 0, help: "Reduce verbosity. Repeat for total silence."},
154-
{ name: "keep", short: "-k", long: "--keep", action: "set", default: false, help: "Save all downloaded working files." },
155-
{ name: "force", long: "--force", action: "set", default: false, help: "Force a build even when there are downgrades or no changes." },
156-
{ name: "add", short: "-a", long: "--add", action: "storex", nargs: 1, help: "New packages to add to build list." },
157-
{ name: "remove", short: "-r", long: "--remove", action: "storex", nargs: 1, help: "Installed packages to remove from build list." },
158-
{ name: "init_script", short: "-I", long: "--init-script", action: "store", nargs: 1, default: null, help: "Path to uci-defaults script to run on first boot ('-' use stdin)." },
159-
{ name: "fstype", short: "-F", long: "--fstype", action: "enum", nargs: 1, default: null, one_of: _fstypes, help: `Desired root file system type (${join(", ", _fstypes)}).` },
160-
{ name: "rootfs_size", short: "-S", long: "--rootfs-size", action: "store_int", nargs: 1, default: null, lower: _fslo, upper: _fshi, help: `DANGER: See wiki before using! Root file system size in MB (${_fslo}-${_fshi}).` },
161-
{ name: "image", short: "-i", long: "--image", action: "store", nargs: 1, default: "/tmp/firmware.bin", help: "Image name for download, verify, install and upgrade." },
162-
{ name: "format", short: "-f", long: "--format", action: "enum", nargs: 1, default: null, one_of: _list_fmts, help: `Format for 'list' output (${join(", ", _list_fmts)}).` },
163-
{ name: "pre_install", short: "-p", long: "--pre-install", action: "store", nargs: 1, default: null, help: "Script to exec just prior to launching final sysupgrade." },
164-
{ name: "poll_interval", short: "-T", long: "--poll-interval", action: "store_int", nargs: 1, default: 2000, help: "Poll interval for build monitor, in milliseconds." },
165-
166-
{ name: "device", long: "--device", action: "store", nargs: 1, default: null }, // Undocumented: For testing foreign devices.
149+
{ name: "command", position: 0, one_of: commands, action: "store", help: "Sub-command to execute" },
150+
{ name: "version_to", short: "-V", long: "--version-to", action: "store", nargs: 1, default: null, help: "Specify the target version, defaults to installed version." },
151+
{ name: "rev_code", short: "-R", long: "--rev-code", action: "rc", nargs: 1, default: null, help: "Specify a 'version_code', literal 'none' allowed, defaults to latest build." },
152+
{ name: "verbosity", short: "-v", long: "--verbose", action: "inc", default: 0, help: "Print various diagnostics. Repeat for even more output." },
153+
{ name: "verbosity", short: "-q", long: "--quiet", action: "dec", default: 0, help: "Reduce verbosity. Repeat for total silence."},
154+
{ name: "keep", short: "-k", long: "--keep", action: "set", default: false, help: "Save all downloaded working files." },
155+
{ name: "force", long: "--force", action: "set", default: false, help: "Force a build even when there are downgrades or no changes." },
156+
{ name: "add", short: "-a", long: "--add", action: "storex", nargs: 1, help: "New packages to add to build list." },
157+
{ name: "remove", short: "-r", long: "--remove", action: "storex", nargs: 1, help: "Installed packages to remove from build list." },
158+
{ name: "ignored_defaults", long: "--ignored-defaults", action: "storex", nargs: 1, help: "List of explicitly ignored default package names." },
159+
{ name: "init_script", short: "-I", long: "--init-script", action: "store", nargs: 1, default: null, help: "Path to uci-defaults script to run on first boot ('-' use stdin)." },
160+
{ name: "fstype", short: "-F", long: "--fstype", action: "enum", nargs: 1, default: null, one_of: _fstypes, help: `Desired root file system type (${join(", ", _fstypes)}).` },
161+
{ name: "rootfs_size", short: "-S", long: "--rootfs-size", action: "store_int", nargs: 1, default: null, lower: _fslo, upper: _fshi, help: `DANGER: See wiki before using! Root file system size in MB (${_fslo}-${_fshi}).` },
162+
{ name: "image", short: "-i", long: "--image", action: "store", nargs: 1, default: "/tmp/firmware.bin", help: "Image name for download, verify, install and upgrade." },
163+
{ name: "format", short: "-f", long: "--format", action: "enum", nargs: 1, default: null, one_of: _list_fmts, help: `Format for 'list' output (${join(", ", _list_fmts)}).` },
164+
{ name: "pre_install", short: "-p", long: "--pre-install", action: "store", nargs: 1, default: null, help: "Script to exec just prior to launching final sysupgrade." },
165+
{ name: "poll_interval", short: "-T", long: "--poll-interval", action: "store_int", nargs: 1, default: 2000, help: "Poll interval for build monitor, in milliseconds." },
166+
167+
{ name: "device", long: "--device", action: "store", nargs: 1, default: null }, // Undocumented: For testing foreign devices.
167168
], ap.ArgParser);
168169

169170
arg_defs.set_prog_info(`owut - OpenWrt Upgrade Tool ${VERSION} (${sourcepath()})`);
@@ -927,6 +928,17 @@ function collect_defaults(board, device)
927928
packages.default = sort(defaults);
928929
}
929930

931+
function parse_package_list(opt)
932+
{
933+
// Return array and null as-is, parse strings into array of string.
934+
// String separators are any of comma, space or newline sequences.
935+
// Allows use of either "list" or "option" in config file.
936+
if (type(opt) == "string") {
937+
opt = split(opt, /[,[:space:]]+/);
938+
}
939+
return opt;
940+
}
941+
930942
function apply_pkg_mods()
931943
{
932944
// 1) Handle 'overview.package_changes'.
@@ -969,13 +981,13 @@ function apply_pkg_mods()
969981
}
970982

971983
// Do removals first, so any conflicts are suppressed.
972-
for (let pkg in split(options.remove, /[,[:space:]]+/)) {
984+
for (let pkg in parse_package_list(options.remove)) {
973985
if (! pkg) continue;
974986
if (! remove_package(pkg)) {
975987
errors++;
976988
}
977989
}
978-
for (let pkg in split(options.add, /[,[:space:]]+/)) {
990+
for (let pkg in parse_package_list(options.add)) {
979991
if (! pkg) continue;
980992
if (! add_package(pkg)) {
981993
errors++;
@@ -1594,11 +1606,16 @@ function check_defaults()
15941606
// 1) missing from the installation or
15951607
// 2) modified/replaced by some other package.
15961608
1609+
let ignored = parse_package_list(options.ignored_defaults);
15971610
let changes = {};
1598-
let count = { retained: 0, replaced: 0, removed: 0 };
1611+
let count = { ignored: 0, retained: 0, replaced: 0, removed: 0 };
15991612
for (let pkg in packages.default) {
16001613
if (pkg in packages.non_upgradable) continue;
1601-
if (is_installed(pkg))
1614+
if (pkg in ignored) {
1615+
count.ignored++;
1616+
changes[pkg] = L.colorize(L.GREEN, "user ignored");
1617+
}
1618+
else if (is_installed(pkg))
16021619
count.retained++;
16031620
else {
16041621
changes[pkg] = what_provides(pkg);

files/owut.defaults

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ cat <<CONF >> "$conf_file"
1515
# '_' underscores. Use 'owut --help' to see more.
1616
1717
config owut 'owut'
18-
# option verbosity 0
19-
# option keep true
20-
# option init_script '/root/data/my-init-script.sh'
21-
# option image '/tmp/my-firmware-img.bin'
22-
# option rootfs_size 256
23-
# option pre_install '/etc/owut.d/pre-install.sh'
24-
# option poll_interval 10000 # In milliseconds
18+
# option verbosity 0
19+
# option keep true
20+
# option init_script '/root/data/my-init-script.sh'
21+
# option image '/tmp/my-firmware-img.bin'
22+
# option rootfs_size 256
23+
# option pre_install '/etc/owut.d/pre-install.sh'
24+
# option poll_interval 10000 # In milliseconds
25+
# list ignored_defaults 'kmod-drm-i915'
26+
# list ignored_defaults 'kmod-dwmac-intel'
2527
2628
CONF
2729
echo "Please see owut section of $conf_file for example options."

0 commit comments

Comments
 (0)