uvol: unbreak build and adapt to updated ucode

* Fix build which was broken by a wrong path in the Makefile.

Adapt to ucode commit 4618807 ("main: rework CLI frontend"):
 * ucode now no longer needs the {% %} around each code file, remove
   that and safe one level of indentation.
 * ARGV now no longer includes ucode executable and script itself

Fixes: 6350c7bc6 ("uvol: replace with re-write in ucode")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
Daniel Golle 2022-03-31 21:41:17 +01:00
parent 8324c1fe06
commit 22d202e3a5
No known key found for this signature in database
GPG key ID: 5A8F39C31C3217CA
6 changed files with 932 additions and 943 deletions

View file

@ -67,7 +67,7 @@ define Package/autopart/install
endef endef
define Package/uvol/install define Package/uvol/install
$(INSTALL_DIR) $(1)/etc/init.d $(1)/usr/uvol/backends $(1)/usr/sbin $(1)/etc/uci-defaults $(INSTALL_DIR) $(1)/etc/init.d $(1)/usr/lib/uvol/backends $(1)/usr/sbin $(1)/etc/uci-defaults
$(INSTALL_BIN) ./files/uvol.init $(1)/etc/init.d/uvol $(INSTALL_BIN) ./files/uvol.init $(1)/etc/init.d/uvol
$(INSTALL_DATA) ./files/blockdev_common.uc $(1)/usr/lib/uvol/ $(INSTALL_DATA) ./files/blockdev_common.uc $(1)/usr/lib/uvol/
$(INSTALL_DATA) ./files/uci.uc $(1)/usr/lib/uvol/ $(INSTALL_DATA) ./files/uci.uc $(1)/usr/lib/uvol/

View file

@ -1,6 +1,6 @@
{%
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
// Helper functions used to identify the boot device // Helper functions used to identify the boot device
// adapted from /lib/functions.sh // adapted from /lib/functions.sh
let cmdline_get_var = function(var) { let cmdline_get_var = function(var) {
let cmdline = fs.open("/proc/cmdline", "r"); let cmdline = fs.open("/proc/cmdline", "r");
@ -78,6 +78,7 @@
ord(bduuid, 7), ord(bduuid, 6), ord(bduuid, 7), ord(bduuid, 6),
ord(bduuid, 8), ord(bduuid, 9), ord(bduuid, 8), ord(bduuid, 9),
ord(bduuid, 10), ord(bduuid, 11), ord(bduuid, 12), ord(bduuid, 13), ord(bduuid, 14), ord(bduuid, 15)); ord(bduuid, 10), ord(bduuid, 11), ord(bduuid, 12), ord(bduuid, 13), ord(bduuid, 14), ord(bduuid, 15));
if (uuidarg == uuid) { if (uuidarg == uuid) {
uevent = sprintf("/sys/class/block/%s/uevent", bd); uevent = sprintf("/sys/class/block/%s/uevent", bd);
break; break;
@ -120,4 +121,3 @@
blockdev_common = {}; blockdev_common = {};
blockdev_common.get_partition = get_partition; blockdev_common.get_partition = get_partition;
blockdev_common.get_bootdev = get_bootdev; blockdev_common.get_bootdev = get_bootdev;
%}

View file

@ -1,4 +1,3 @@
{%
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
// LVM2 backend for uvol // LVM2 backend for uvol
// (c) 2022 Daniel Golle <daniel@makrotopia.org> // (c) 2022 Daniel Golle <daniel@makrotopia.org>
@ -464,4 +463,3 @@
backend.create = lvm_create; backend.create = lvm_create;
backend.remove = lvm_remove; backend.remove = lvm_remove;
backend.write = lvm_write; backend.write = lvm_write;
%}

View file

@ -1,4 +1,3 @@
{%
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
// UBI backend for uvol // UBI backend for uvol
// (c) 2022 Daniel Golle <daniel@makrotopia.org> // (c) 2022 Daniel Golle <daniel@makrotopia.org>
@ -375,4 +374,3 @@
backend.create = ubi_create; backend.create = ubi_create;
backend.remove = ubi_remove; backend.remove = ubi_remove;
backend.write = ubi_write; backend.write = ubi_write;
%}

View file

@ -1,4 +1,3 @@
{%
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
// UCI tools for uvol // UCI tools for uvol
// (c) 2022 Daniel Golle <daniel@makrotopia.org> // (c) 2022 Daniel Golle <daniel@makrotopia.org>
@ -136,4 +135,3 @@ uvol_uci = {
return 0; return 0;
} }
}; };
%}

View file

@ -1,13 +1,9 @@
#!/usr/bin/ucode #!/usr/bin/ucode
{%
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
// uvol - storage volume manager for OpenWrt // uvol - storage volume manager for OpenWrt
// (c) 2022 Daniel Golle <daniel@makrotopia.org> // (c) 2022 Daniel Golle <daniel@makrotopia.org>
function help() { let help_output = "uvol storage volume manager
%}
uvol storage volume manager
syntax: uvol command ... syntax: uvol command ...
commands: commands:
@ -29,8 +25,11 @@ commands:
1 - volume is not ready for use 1 - volume is not ready for use
2 - volume doesn'y exist 2 - volume doesn'y exist
write volname size write to volume from stdin, size in bytes write volname size write to volume from stdin, size in bytes
{% "
}
function help() {
printf("%s", help_output);
);
let fs = require("fs"); let fs = require("fs");
let uci = require("uci"); let uci = require("uci");
@ -56,7 +55,6 @@ commands:
type(current_backend.priority) == "int" && type(current_backend.priority) == "int" &&
backend.priority > current_backend.priority) backend.priority > current_backend.priority)
continue; continue;
if (type(current_backend.init) == "function" && if (type(current_backend.init) == "function" &&
current_backend.init(ctx)) { current_backend.init(ctx)) {
backend = current_backend; backend = current_backend;
@ -70,8 +68,6 @@ commands:
exit(2); exit(2);
} }
shift(ARGV);
shift(ARGV);
let cmd = shift(ARGV); let cmd = shift(ARGV);
if (!cmd || cmd == "-h" || cmd == "help") { if (!cmd || cmd == "-h" || cmd == "help") {
@ -126,5 +122,4 @@ commands:
printf("%s\n", legacy_output(backend[cmd])); printf("%s\n", legacy_output(backend[cmd]));
} }
return 0; exit(0);
%}