Hello community, here is the log from the commit of package efibootmgr for openSUSE:Factory checked in at 2017-03-11 15:18:26 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/efibootmgr (Old) and /work/SRC/openSUSE:Factory/.efibootmgr.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "efibootmgr" Sat Mar 11 15:18:26 2017 rev:27 rq:477152 version:14 Changes: -------- --- /work/SRC/openSUSE:Factory/efibootmgr/efibootmgr.changes 2016-08-25 09:52:18.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.efibootmgr.new/efibootmgr.changes 2017-03-11 15:18:27.433570842 +0100 @@ -1,0 +2,25 @@ +Fri Mar 3 20:46:25 UTC 2017 - [email protected] + +- Update to 14 plus upstream fixes. (fate#322108) + (0001-Don-t-use-fshort-wchar-when-building-63.patch, + 0002-Remove-extra-const-keywords-gcc-7-gripes-about.patch, + 0003-Add-support-for-parsing-optional-data-as-ucs2.patch) +- Forward port and refresh SLE patches + (efibootmgr-derhat.diff, MARM-sanitize-set_mirror.diff + efibootmgr-delete-multiple.diff) +- Drop upstreamed patches + (efibootmgr-check-boot-order.diff, + efibootmgr-fix-efivar-0.24.patch, + efibootmgr-fix-usage-of-efi_loadopt_path-again.patch, + MARM-add-m-and-M-options.diff, + MARM-extend-man-for-M-option.diff, + MARM-fix-insufficient-validation-check-of-M-option.diff, + MARM-introduce-man-for-m-and-M-option.diff) + +------------------------------------------------------------------- +Thu Feb 16 12:49:42 UTC 2017 - [email protected] + +- Build on all archs. There is no reason not to. (boo#1025520) +- Depend on new enough efivar. Build fails otherwise. + +------------------------------------------------------------------- @@ -7,0 +33,11 @@ +Thu Jul 14 11:11:15 UTC 2016 - [email protected] + +- Add support for Memory Address Range Mirroring. + [fate#320999, bsc#987599] + (add MARM-add-m-and-M-options.diff, + MARM-fix-insufficient-validation-check-of-M-option.diff, + MARM-introduce-man-for-m-and-M-option.diff, + MARM-extend-man-for-M-option.diff, + MARM-sanitize-set_mirror.diff) + +------------------------------------------------------------------- @@ -13,0 +50,12 @@ +Tue Sep 15 16:44:37 UTC 2015 - [email protected] + +- Properly latch long to short option for delete. [bsc#945705] + (efibootmgr-delete-multiple.diff) + +------------------------------------------------------------------- +Fri Jul 24 14:24:00 UTC 2015 - [email protected] + +- Refresh for SLE12. [bsc#929677] + (efibootmgr-gcc-Wall.diff, efibootmgr-delete-multiple.diff) + +------------------------------------------------------------------- @@ -28,0 +77,22 @@ +Wed Mar 11 15:26:59 UTC 2015 - [email protected] + +- Allow disk/partition as selector for delete as well. [bsc#870211] + (efibootmgr-delete-multiple.diff) +- Remove version number from patches. + (add efibootmgr-derhat.diff, efibootmgr-fail-visibly.diff, + efibootmgr-gcc-Wall.diff, efibootmgr-set_boot_order.diff, + efibootmgr-write-unique-id-once.diff; + drop efibootmgr-0.6.0-check-boot-order.diff, + efibootmgr-0.6.0-delete-by-uuid.diff, efibootmgr-0.6.0-derhat.diff, + efibootmgr-0.6.0-fail-visibly.diff, efibootmgr-0.6.0-gcc-Wall.diff, + efibootmgr-0.6.0-set_boot_order.diff, + efibootmgr-0.6.0-write-unique-id-once.diff) +Note: this entry reflects obsoleted, SLE-only changes! + +------------------------------------------------------------------- +Fri Jan 30 10:47:13 UTC 2015 - [email protected] + +- Introduce partition UUID as selector for delete. [bsc#870211] + (efibootmgr-0.6.0-delete-by-uuid.diff) + +------------------------------------------------------------------- @@ -58 +128 @@ -- Enable for aarch64 +- Enable for aarch64 (fate#318444) Old: ---- efibootmgr-0.12.tar.bz2 efibootmgr-check-boot-order.diff efibootmgr-fix-efivar-0.24.patch efibootmgr-fix-usage-of-efi_loadopt_path-again.patch New: ---- 0001-Don-t-use-fshort-wchar-when-building-63.patch 0002-Remove-extra-const-keywords-gcc-7-gripes-about.patch 0003-Add-support-for-parsing-optional-data-as-ucs2.patch MARM-sanitize-set_mirror.diff efibootmgr-14.tar.bz2 efibootmgr-delete-multiple.diff ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ efibootmgr.spec ++++++ --- /var/tmp/diff_new_pack.VEy9mw/_old 2017-03-11 15:18:28.029486513 +0100 +++ /var/tmp/diff_new_pack.VEy9mw/_new 2017-03-11 15:18:28.029486513 +0100 @@ -1,7 +1,7 @@ # # spec file for package efibootmgr # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,23 +17,25 @@ Name: efibootmgr -Version: 0.12 +Version: 14 Release: 0 Summary: EFI Boot Manager License: GPL-2.0+ Group: System/Boot Url: https://github.com/rhinstaller/efibootmgr -Source: https://github.com/rhinstaller/efibootmgr/releases/download/efibootmgr-%{version}/efibootmgr-%{version}.tar.bz2 -Patch1: %{name}-derhat.diff -Patch2: %{name}-check-boot-order.diff -Patch3: %{name}-fix-efivar-0.24.patch -Patch4: %{name}-fix-usage-of-efi_loadopt_path-again.patch -BuildRequires: efivar-devel +Source: https://github.com/rhinstaller/efibootmgr/releases/download/14/efibootmgr-14.tar.bz2 +Patch1: 0001-Don-t-use-fshort-wchar-when-building-63.patch +Patch2: 0002-Remove-extra-const-keywords-gcc-7-gripes-about.patch +Patch3: 0003-Add-support-for-parsing-optional-data-as-ucs2.patch +Patch4: %{name}-derhat.diff +Patch5: MARM-sanitize-set_mirror.diff +Patch6: %{name}-delete-multiple.diff +BuildRequires: efivar-devel >= 31 BuildRequires: pciutils-devel BuildRequires: pkg-config +BuildRequires: popt-devel BuildRequires: zlib-devel BuildRoot: %{_tmppath}/%{name}-%{version}-build -ExclusiveArch: ia64 x86_64 i586 aarch64 %description The EFI Boot Manager allows the user to edit the Intel Extensible @@ -47,6 +49,8 @@ %patch2 -p1 %patch3 -p1 %patch4 -p1 +%patch5 -p1 +%patch6 -p1 %build LOADER="grub.efi" # default loader @@ -58,19 +62,16 @@ (SUSE*|SLE*) VENDOR="SUSE";; (*) VENDOR="linux";; esac -make %{?_smp_mflags} EXTRA_CFLAGS="%{optflags}" \ +make %{?_smp_mflags} CFLAGS="%{optflags} -flto" \ OS_VENDOR="$VENDOR" EFI_LOADER="$LOADER" %install -install -d %{buildroot}%{_sbindir} -make install BINDIR=%{buildroot}%{_sbindir} -install -d %{buildroot}%{_mandir}/man8 -install -m 644 src/man/man8/efibootmgr.8 %{buildroot}%{_mandir}/man8 +make DESTDIR=%{buildroot} sbindir=%{_sbindir} install %files %defattr(-, root, root) %doc README COPYING -%{_sbindir}/efibootmgr +%{_sbindir}/efiboot* %{_mandir}/man8/*.gz %changelog ++++++ 0001-Don-t-use-fshort-wchar-when-building-63.patch ++++++ >From 3466fd05c8c6f1052e0426d64eed40f8a88fd78f Mon Sep 17 00:00:00 2001 From: steve-mcintyre <[email protected]> Date: Fri, 6 Jan 2017 18:18:47 +0000 Subject: [PATCH 1/4] Don't use -fshort-wchar when building (#63) It's not needed and is causing build failures with gcc 6. Closes Debian bug #849651 Signed-off-by: Steve McIntyre <[email protected]> --- Make.defaults | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Make.defaults b/Make.defaults index 50f1f4d..0ac50ef 100644 --- a/Make.defaults +++ b/Make.defaults @@ -26,7 +26,7 @@ clang_cflags = gcc_cflags = cflags = $(CFLAGS) $(SUBDIR_CFLAGS) \ -Werror -Wall -Wextra -Wsign-compare -Wstrict-aliasing \ - -std=gnu11 -fshort-wchar -fPIC \ + -std=gnu11 -fPIC \ -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -DLOCALEDIR=\"$(localedir)\" \ -DEFIBOOTMGR_VERSION="\"$(VERSION)\"" \ $(if $(findstring clang,$(CC)),$(clang_cflags),) \ -- 2.6.6 ++++++ 0002-Remove-extra-const-keywords-gcc-7-gripes-about.patch ++++++ >From 3217ab97776a6493099014f9a4820cbd39f1393a Mon Sep 17 00:00:00 2001 From: Peter Jones <[email protected]> Date: Mon, 6 Feb 2017 16:34:54 -0500 Subject: [PATCH 2/4] Remove extra const keywords gcc 7 gripes about. Signed-off-by: Peter Jones <[email protected]> --- src/efibootdump.c | 2 +- src/efibootmgr.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/efibootdump.c b/src/efibootdump.c index 6ff8360..30a1943 100644 --- a/src/efibootdump.c +++ b/src/efibootdump.c @@ -39,7 +39,7 @@ print_boot_entry(efi_load_option *loadopt, size_t data_size) uint8_t *optional_data = NULL; size_t optional_data_len = 0; uint16_t pathlen; - const unsigned char const *desc; + const unsigned char *desc; char *raw; size_t raw_len; diff --git a/src/efibootmgr.c b/src/efibootmgr.c index 493f2cf..90a0998 100644 --- a/src/efibootmgr.c +++ b/src/efibootmgr.c @@ -221,7 +221,7 @@ warn_duplicate_name(list_t *var_list) list_t *pos; var_entry_t *entry; efi_load_option *load_option; - const unsigned char const *desc; + const unsigned char *desc; list_for_each(pos, var_list) { entry = list_entry(pos, var_entry_t, list); @@ -873,7 +873,7 @@ show_vars(const char *prefix) { list_t *pos; var_entry_t *boot; - const unsigned char const *description; + const unsigned char *description; efi_load_option *load_option; efidp dp = NULL; unsigned char *optional_data = NULL; -- 2.6.6 ++++++ 0003-Add-support-for-parsing-optional-data-as-ucs2.patch ++++++ >From c444d8c19de7ea28a0eb4ac4639d6d99d982ca31 Mon Sep 17 00:00:00 2001 From: "Martin T. H. Sandsmark" <[email protected]> Date: Fri, 30 Dec 2016 14:33:27 +0100 Subject: [PATCH 3/4] Add support for parsing optional data as ucs2 --- src/efibootmgr.8 | 2 +- src/efibootmgr.c | 62 +++++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 49 insertions(+), 15 deletions(-) diff --git a/src/efibootmgr.8 b/src/efibootmgr.8 index 9208608..20a20b8 100644 --- a/src/efibootmgr.8 +++ b/src/efibootmgr.8 @@ -106,7 +106,7 @@ Boot Manager timeout, in \fIseconds\fR\&. Delete Timeout variable. .TP \fB-u | --unicode | --UCS-2 \fR -pass extra command line arguments as UCS-2 (default is +Handle extra command line arguments as UCS-2 (default is ASCII) .TP \fB-v | --verbose\fR diff --git a/src/efibootmgr.c b/src/efibootmgr.c index 90a0998..20d71e2 100644 --- a/src/efibootmgr.c +++ b/src/efibootmgr.c @@ -868,6 +868,36 @@ err: return rc; } +#define ev_bits(val, mask, shift) \ + (((val) & ((mask) << (shift))) >> (shift)) + +static inline char * +ucs2_to_utf8(const uint16_t * const chars, ssize_t limit) +{ + ssize_t i, j; + char *ret; + + ret = alloca(limit * 6 + 1); + if (!ret) + return NULL; + memset(ret, 0, limit * 6 +1); + + for (i=0, j=0; chars[i] && i < (limit >= 0 ? limit : i+1); i++,j++) { + if (chars[i] <= 0x7f) { + ret[j] = chars[i]; + } else if (chars[i] > 0x7f && chars[i] <= 0x7ff) { + ret[j++] = 0xc0 | ev_bits(chars[i], 0x1f, 6); + ret[j] = 0x80 | ev_bits(chars[i], 0x3f, 0); + } else if (chars[i] > 0x7ff) { + ret[j++] = 0xe0 | ev_bits(chars[i], 0xf, 12); + ret[j++] = 0x80 | ev_bits(chars[i], 0x3f, 6); + ret[j] = 0x80| ev_bits(chars[i], 0x3f, 0); + } + } + ret[j] = '\0'; + return strdup(ret); +} + static void show_vars(const char *prefix) { @@ -928,19 +958,23 @@ show_vars(const char *prefix) if (rc < 0) error(21, "Could not parse optional data"); - rc = unparse_raw_text(NULL, 0, optional_data, - optional_data_len); - if (rc < 0) - error(22, "Could not parse optional data"); - rc += 1; - text_path_len = rc; - text_path = calloc(1, rc); - if (!text_path) - error(23, "Could not parse optional data"); - rc = unparse_raw_text(text_path, text_path_len, - optional_data, optional_data_len); - if (rc < 0) - error(24, "Could not parse device path"); + if (opts.unicode) { + text_path = ucs2_to_utf8((uint16_t*)optional_data, optional_data_len/2); + } else { + rc = unparse_raw_text(NULL, 0, optional_data, + optional_data_len); + if (rc < 0) + error(22, "Could not parse optional data"); + rc += 1; + text_path_len = rc; + text_path = calloc(1, rc); + if (!text_path) + error(23, "Could not parse optional data"); + rc = unparse_raw_text(text_path, text_path_len, + optional_data, optional_data_len); + if (rc < 0) + error(24, "Could not parse device path"); + } printf("%s", text_path); free(text_path); } @@ -1211,7 +1245,7 @@ usage() printf("\t-q | --quiet be quiet\n"); printf("\t-t | --timeout seconds set boot manager timeout waiting for user input.\n"); printf("\t-T | --delete-timeout delete Timeout.\n"); - printf("\t-u | --unicode | --UCS-2 pass extra args as UCS-2 (default is ASCII)\n"); + printf("\t-u | --unicode | --UCS-2 handle extra args as UCS-2 (default is ASCII)\n"); printf("\t-v | --verbose print additional information\n"); printf("\t-V | --version return version and exit\n"); printf("\t-w | --write-signature write unique sig to MBR if needed\n"); -- 2.6.6 ++++++ MARM-sanitize-set_mirror.diff ++++++ >From d89633f608177283e9ae0f16c7065768e64da0ca Mon Sep 17 00:00:00 2001 From: Raymund Will <[email protected]> Date: Mon, 13 Feb 2017 15:33:52 +0100 Subject: [PATCH] efibootmgr: sanitize `set/get_mirror()` References: bsc#987599 get_mirror() - don't short-circuit the assignment of values in case of version mismatch as `show_mirror()` happily tries to use them nevertheless - move redundant warning (from `show_mirror()`s PoV) to `set_mirror()` - add missing `free(data)` set_mirror() - skip obsolete second assignment of `data` - avoid potentially "uninitialized" access to `above/below4g` by protecting it with `opts.set_mirror_hi/_lo` respectively, thus simplifying the code down the line Note: this will prevent unnecessary write-operations! Signed-off-by: Raymund Will <[email protected]> --- src/efibootmgr.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/efibootmgr.c b/src/efibootmgr.c index 20d71e2..15659c6 100644 --- a/src/efibootmgr.c +++ b/src/efibootmgr.c @@ -1106,12 +1106,12 @@ get_mirror(int which, int *below4g, int *above4g, int *mirrorstatus) if (rc == 0) { abm = (ADDRESS_RANGE_MIRROR_VARIABLE_DATA *)data; if (!which && abm->mirror_version != MIRROR_VERSION) { - warningx("** Warning ** : unrecognised version for memory mirror i/f"); - return 2; + rc = 2; } *below4g = abm->mirror_memory_below_4gb; *above4g = abm->mirror_amount_above_4gb; *mirrorstatus = abm->mirror_status; + free(data); } else { cond_warning(opts.verbose >= 2, "Could not read variable '%s'", name); @@ -1130,14 +1130,19 @@ set_mirror(int below4g, int above4g) uint32_t attributes; int oldbelow4g, oldabove4g; - if ((s = get_mirror(0, &oldbelow4g, &oldabove4g, &status)) == 0) { - if (oldbelow4g == below4g && oldabove4g == above4g) - return 0; - } else { - warningx("** Warning ** : platform does not support memory mirror"); + if ((s = get_mirror(0, &oldbelow4g, &oldabove4g, &status)) != 0) { + if (s == 2) + warningx("** Warning ** : unrecognised version for memory mirror i/f"); + else + warningx("** Warning ** : platform does not support memory mirror"); return s; } + below4g = opts.set_mirror_lo ? below4g : oldbelow4g; + above4g = opts.set_mirror_hi ? above4g : oldabove4g; + if (oldbelow4g == below4g && oldabove4g == above4g) + return 0; + data = (uint8_t *)&abm; data_size = sizeof (abm); attributes = EFI_VARIABLE_NON_VOLATILE @@ -1145,10 +1151,9 @@ set_mirror(int below4g, int above4g) | EFI_VARIABLE_RUNTIME_ACCESS; abm.mirror_version = MIRROR_VERSION; - abm.mirror_amount_above_4gb = opts.set_mirror_hi ? above4g : oldabove4g; - abm.mirror_memory_below_4gb = opts.set_mirror_lo ? below4g : oldbelow4g; + abm.mirror_amount_above_4gb = above4g; + abm.mirror_memory_below_4gb = below4g; abm.mirror_status = 0; - data = (uint8_t *)&abm; rc = efi_set_variable(ADDRESS_RANGE_MIRROR_VARIABLE_GUID, ADDRESS_RANGE_MIRROR_VARIABLE_REQUEST, data, data_size, attributes, 0644); -- 2.6.6 ++++++ efibootmgr-0.12.tar.bz2 -> efibootmgr-14.tar.bz2 ++++++ ++++ 7364 lines of diff (skipped) ++++++ efibootmgr-delete-multiple.diff ++++++ >From 21741160071c83e4ae6b9fa268947abfd0d3405f Mon Sep 17 00:00:00 2001 From: Raymund Will <[email protected]> Date: Fri, 3 Mar 2017 18:47:44 +0100 Subject: [PATCH] Extended Delete References: bsc#870211, bsc#945705 Delete boot entries not only by number. but alse based on - partition UUID, optionally restricted by loader or - disk and partition, again optionally restricted by loader. This does unfortunately require an API-change of efivar! Signed-off-by: Raymund Will <[email protected]> --- src/efibootmgr.c | 187 ++++++++++++++++++++++++++++++++++++++++++++++- src/include/efibootmgr.h | 3 +- 2 files changed, 185 insertions(+), 5 deletions(-) diff --git a/src/efibootmgr.c b/src/efibootmgr.c index 20d71e2..93663cb 100644 --- a/src/efibootmgr.c +++ b/src/efibootmgr.c @@ -608,6 +608,146 @@ delete_var(const char *prefix, uint16_t num) return 0; } +static int +delete_by_uuid(const char *prefix, char *uuid_str, char *loader) +{ + int count = 0; + list_t *pos, *tmp; + var_entry_t *entry; + const unsigned char *description; + efi_load_option *load_option; + efidp path = NULL; + char text_path[1024]; + + list_for_each_safe(pos, tmp, &entry_list) { + uint16_t pathlen; + ssize_t rc; + + entry = list_entry(pos, var_entry_t, list); + load_option = (efi_load_option *)entry->data; + pathlen = efi_loadopt_pathlen(load_option, + entry->data_size); + path = efi_loadopt_path(load_option, entry->data_size); + rc = efidp_format_device_path(text_path, 1024, + path, pathlen); + + if (rc < 0 || rc > 1024) + error(20, "Could not parse device path"); + + if (strlen(text_path) == 0) + continue; + if (strcasestr(text_path, uuid_str) == NULL) + continue; + if (loader && strcasestr(text_path, loader) == NULL) + continue; + /* found! */ + if (opts.verbose) { + description = efi_loadopt_desc(load_option, + entry->data_size); + printf("Delete %s%04X %s\t%s\n", + prefix, entry->num, description, text_path); + } + if (delete_var(prefix, entry->num) != 0) + return -1; + count++; + } + if (count==0) { + /* Nothing changed => exit early */ + exit(0); + } + return 0; +} + +static int +delete_by_dpl(const char *prefix, char *disk, uint32_t part, char *loader) +{ + int fd, rc; + uint64_t start, size; + efi_guid_t signature; + char sigstr[40]; + char *sigstrp = sigstr; + uint8_t mbr_type, signature_type; + + if (disk == NULL && part == 0 && loader == NULL) + errx(42, "Cowardly refusing to delete ALL %s entries.", + prefix); + if (disk == NULL) { + /* foreach d in gpt_disks + * delete_by_dpl(prefix, d, part, loader) + */ + errx(42, "Future extension."); + } + if (part == 0) { + /* foreach p in partions_on_gpt_disk + * delete_by_dpl(prefix, disk, p, loader) + */ + errx(42, "Future extension."); + } + memset((char *)&signature, 0, sizeof(signature)); + + fd = open(disk, O_RDONLY|O_DIRECT); + if (fd == -1) + error(42, "Could not open disk %s", disk); + rc = efi_disk_get_partition_info(fd, part, &start, &size, + (uint8_t*)&signature, &mbr_type, &signature_type); + close(fd); + + if (rc) + return -1; + if (mbr_type != 0x02) { + errx(42, "Cowardly refusing non-GPT disk %s", disk); + } + + efi_guid_to_str(&signature, &sigstrp); + + if (opts.verbose && !loader) { + printf("About to delete all entries referring to UUID %s\n", + sigstr); + } else if ( opts.delete != 15) { + printf("About to delete all entries referring to loader %s\n" + " on UUID %s\n", + loader, sigstr); + } + return delete_by_uuid(prefix,sigstr,loader); +} + +/* verbatim copy of same function in efivar/src/creator.c */ +static char * +tilt_slashes(char *s) +{ + char *p; + for (p = s; *p; p++) + if (*p == '/') + *p = '\\'; + return s; +} + +static int +check_uuid(const char *s) +{ + /* algorithm derived from efivar/src/guid.h */ + size_t len = 36; + unsigned int i; + if (strlen(s) != len) + return -1; + for (i = 0; i < len; i++) { + if (i == 8 || i == 13 || i == 18 || i == 23) { + if (s[i] != '-') + return -1; + continue; + } + if (s[i] >= '0' && s[i] <= '9') + continue; + /* "| 0x20" is tolower() without having to worry about + * locale concerns, since we know everything here must + * be within traditional ascii space. */ + if ((s[i] | 0x20) >= 'a' && (s[i] | 0x20) <= 'f') + continue; + return -1; + } + return 0; +} + static void set_var_nums(const char *prefix, list_t *list) { @@ -1215,7 +1355,9 @@ usage() printf("\t-a | --active sets bootnum active\n"); printf("\t-A | --inactive sets bootnum inactive\n"); printf("\t-b | --bootnum XXXX modify BootXXXX (hex)\n"); - printf("\t-B | --delete-bootnum delete bootnum\n"); + printf("\t-B | --delete-bootnum delete bootnum (specified with -b)\n"); + printf("\t --delete delete entry by bootnum (-b), by UUID (-P)\n"); + printf("\t or by disk+partition[+file] (-d -p -l)\n"); printf("\t-c | --create create new variable bootnum and add to bootorder\n"); printf("\t-C | --create-only create new variable bootnum and do not add to bootorder\n"); printf("\t-D | --remove-dups remove duplicate values from BootOrder\n"); @@ -1242,6 +1384,7 @@ usage() printf("\t-o | --bootorder XXXX,YYYY,ZZZZ,... explicitly set BootOrder (hex)\n"); printf("\t-O | --delete-bootorder delete BootOrder\n"); printf("\t-p | --part part (defaults to 1) containing loader\n"); + printf("\t-P | --part-uuid UUID select all variables for given partition UUID\n"); printf("\t-q | --quiet be quiet\n"); printf("\t-t | --timeout seconds set boot manager timeout waiting for user input.\n"); printf("\t-T | --delete-timeout delete Timeout.\n"); @@ -1267,6 +1410,7 @@ set_default_opts() opts.label = (unsigned char *)"Linux"; opts.disk = "/dev/sda"; opts.part = 1; + opts.part_uuid = NULL; } static void @@ -1288,6 +1432,7 @@ parse_opts(int argc, char **argv) {"delete-bootnum", no_argument, 0, 'B'}, {"create", no_argument, 0, 'c'}, {"create-only", no_argument, 0, 'C'}, + {"delete", no_argument, 0, 2}, {"remove-dups", no_argument, 0, 'D'}, {"disk", required_argument, 0, 'd'}, {"iface", required_argument, 0, 'i'}, @@ -1320,7 +1465,7 @@ parse_opts(int argc, char **argv) }; c = getopt_long (argc, argv, - "AaBb:cCDd:e:E:gH:i:l:L:M:m:n:No:Op:qt:TuU:v::Vw" + "AaBb:cCDd:e:E:gH:i:l:L:M:m:n:No:Op:P:qt:TuU:v::Vw" "@:hry", long_options, &option_index); if (c == -1) @@ -1368,11 +1513,16 @@ parse_opts(int argc, char **argv) opts.create = 1; opts.no_order = 1; break; + case 2: + opts.delete |= 1; + break; case 'D': opts.deduplicate = 1; break; case 'd': opts.disk = optarg; + if (opts.delete) + opts.delete |= 2; break; case 'e': rc = sscanf(optarg, "%u", &num); @@ -1410,6 +1560,9 @@ parse_opts(int argc, char **argv) break; case 'l': opts.loader = optarg; + tilt_slashes(opts.loader); + if (opts.delete) + opts.delete |= 8; break; case 'L': opts.label = (unsigned char *)optarg; @@ -1474,6 +1627,17 @@ parse_opts(int argc, char **argv) else errorx(37, "invalid numeric value %s\n", optarg); + if (opts.delete) + opts.delete |= 4; + break; + case 'P': + if ((rc=check_uuid(optarg)) < 0) { + fprintf(stderr, + "malformed partition UUID: %s (%d)\n", + optarg, rc); + exit(1); + } + opts.part_uuid = optarg; break; case 'q': opts.quiet = 1; @@ -1595,9 +1759,24 @@ main(int argc, char **argv) set_var_nums(prefices[mode], &entry_list); if (opts.delete) { - if (opts.num == -1) + if (opts.part_uuid) { + ret = delete_by_uuid(prefices[mode], opts.part_uuid, + (opts.delete & 8) ? opts.loader : NULL); + if (ret < 0) + error(42, "Could not delete variable(s)"); + } else if (opts.delete & 2) { + ret = delete_by_dpl(prefices[mode], + (opts.delete & 2) ? opts.disk : NULL, + (opts.delete & 4) ? opts.part : 0, + (opts.delete & 8) ? opts.loader : NULL); + if (ret < 0) + error(42, "Could not delete variable(s)"); + } else if (opts.delete > 1) + errorx(3, "Disk and partition must be specified " + "(see the --delete option)."); + else if (opts.num == -1) errorx(3, "You must specify an entry to delete " - "(see the -b option)."); + "(e.g. with the -b option)."); else { ret = delete_var(prefices[mode], opts.num); if (ret < 0) diff --git a/src/include/efibootmgr.h b/src/include/efibootmgr.h index d692d0c..d2d90dc 100644 --- a/src/include/efibootmgr.h +++ b/src/include/efibootmgr.h @@ -60,6 +60,7 @@ typedef struct { int keep_old_entries; char *testfile; char *extra_opts_file; + char *part_uuid; uint32_t part; int edd_version; uint32_t edd10_devicenum; @@ -70,7 +71,7 @@ typedef struct { int below4g; int above4g; int deduplicate; - unsigned int delete:1; + unsigned int delete:4; unsigned int delete_order:1; unsigned int delete_bootnext:1; unsigned int quiet:1; -- 2.6.6 ++++++ efibootmgr-derhat.diff ++++++ --- /var/tmp/diff_new_pack.VEy9mw/_old 2017-03-11 15:18:28.197462743 +0100 +++ /var/tmp/diff_new_pack.VEy9mw/_new 2017-03-11 15:18:28.201462177 +0100 @@ -8,45 +8,46 @@ and used as default without '--loader'. Simply use - make OS_VENDOR=redhat EFI_LOADER=grub.efi -to get the previous value. :) + make OS_VENDOR=<vendor> EFI_LOADER=<loader>.efi +to get the desired value. :) Signed-off-by: Raymund Will <[email protected]> --- - Makefile | 4 ++++ - src/efibootmgr/efibootmgr.c | 12 ++++++++---- - 2 files changed, 12 insertions(+), 4 deletions(-) + Make.defaults | 4 ++++ + src/efibootmgr.c | 9 +++++---- + 2 files changed, 9 insertions(+), 4 deletions(-) -Index: efibootmgr-0.12/Makefile -=================================================================== ---- efibootmgr-0.12.orig/Makefile -+++ efibootmgr-0.12/Makefile -@@ -1,5 +1,8 @@ - default: all +diff --git a/Make.defaults b/Make.defaults +index 0ac50ef..7ca17e3 100644 +--- a/Make.defaults ++++ b/Make.defaults +@@ -9,6 +9,9 @@ localedir ?= $(datadir)/locale/ + PCDIR ?= $(libdir)/pkgconfig + DESTDIR ?= -+ OS_VENDOR := vendor -+ EFI_LOADER := boot.efi ++OS_VENDOR := redhat ++EFI_LOADER := grub.efi + - SIGNING_KEY := pjones - RELEASE_MAJOR := 0 - RELEASE_MINOR := 12 -@@ -8,6 +11,7 @@ - RELEASE_STRING := $(RELEASE_NAME)-$(RELEASE_MAJOR).$(RELEASE_MINOR) - - CFLAGS = $(EXTRA_CFLAGS) -DEFIBOOTMGR_VERSION=\"$(RELEASE_MAJOR).$(RELEASE_MINOR)\" \ -+ -DDEFAULT_LOADER=\"\\\\efi\\\\$(OS_VENDOR)\\\\$(EFI_LOADER)\" \ - -Wsign-compare -Wall -Werror -g -D_FILE_OFFSET_BITS=64 \ - -I/usr/include/efivar - -Index: efibootmgr-0.12/src/efibootmgr/efibootmgr.c -=================================================================== ---- efibootmgr-0.12.orig/src/efibootmgr/efibootmgr.c -+++ efibootmgr-0.12/src/efibootmgr/efibootmgr.c + INSTALL ?= install + CROSS_COMPILE ?= + PKG_CONFIG = $(CROSS_COMPILE)pkg-config +@@ -29,6 +32,7 @@ cflags = $(CFLAGS) $(SUBDIR_CFLAGS) \ + -std=gnu11 -fPIC \ + -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -DLOCALEDIR=\"$(localedir)\" \ + -DEFIBOOTMGR_VERSION="\"$(VERSION)\"" \ ++ -DDEFAULT_LOADER=\"\\\\efi\\\\$(OS_VENDOR)\\\\$(EFI_LOADER)\" \ + $(if $(findstring clang,$(CC)),$(clang_cflags),) \ + $(if $(findstring gcc,$(CC)),$(gcc_cflags),) \ + $(call pkg-config-cflags) +diff --git a/src/efibootmgr.c b/src/efibootmgr.c +index 20d71e2..825435e 100644 +--- a/src/efibootmgr.c ++++ b/src/efibootmgr.c @@ -1,5 +1,6 @@ /* - efibootmgr.c - Manipulates EFI variables as exported in /proc/efi/vars -+ efibootmgr.c - Manipulates EFI variables as exported in -+ /sys/firmware/efi/vars (previously was /proc/efi/vars) ++ efibootmgr.c - Manipulates EFI variables as exported in /sys/firmware/efi/ ++ efivars or vars (previously /proc/efi/vars) Copyright (C) 2001-2004 Dell, Inc. <[email protected]> @@ -55,34 +56,28 @@ - This must tie the EFI_DEVICE_PATH to /boot/efi/EFI/redhat/grub.efi -+ This must tie the EFI_DEVICE_PATH to /boot/efi/efi/<vendor>/<loader>.efi ++ This must tie the EFI_DEVICE_PATH to /boot/efi/EFI/<vendor>/<loader>.efi The EFI_DEVICE_PATH will look something like: ACPI device path, length 12 bytes Hardware Device Path, PCI, length 6 bytes -@@ -58,6 +59,9 @@ - #define EFIBOOTMGR_VERSION "unknown (fix Makefile!)" - #endif - -+#ifndef DEFAULT_LOADER -+#define DEFAULT_LOADER "unknown (fix Makefile!)" -+#endif - - typedef struct _var_entry { - char *name; -@@ -985,7 +989,7 @@ usage() +@@ -1233,7 +1234,7 @@ usage() printf("\t --ip-port <local>,<remote> set local and remote IP ports\n"); printf("\t --ip-origin { {dhcp|static} | { static|stateless|stateful} }\n"); #endif - printf("\t-l | --loader name (defaults to \\EFI\\redhat\\grub.efi)\n"); -+ printf("\t-l | --loader name (defaults to \""DEFAULT_LOADER"\")\n"); ++ printf("\t-l | --loader name (defaults to \""DEFAULT_LOADER"\")\n"); printf("\t-L | --label label Boot manager display label (defaults to \"Linux\")\n"); - printf("\t-n | --bootnext XXXX set BootNext to XXXX (hex)\n"); - printf("\t-N | --delete-bootnext delete BootNext\n"); -@@ -1013,6 +1017,7 @@ set_default_opts() + printf("\t-m | --mirror-below-4G t|f mirror memory below 4GB\n"); + printf("\t-M | --mirror-above-4G X percentage memory to mirror above 4GB\n"); +@@ -1263,7 +1264,7 @@ set_default_opts() + opts.active = -1; /* Don't set it */ opts.timeout = -1; /* Don't set it */ opts.edd10_devicenum = 0x80; - opts.loader = "\\EFI\\redhat\\grub.efi"; -+ opts.loader = DEFAULT_LOADER; +- opts.loader = "\\EFI\\redhat\\grub.efi"; ++ opts.loader = DEFAULT_LOADER; opts.label = (unsigned char *)"Linux"; opts.disk = "/dev/sda"; opts.part = 1; +-- +2.6.6 +
