diff --git a/centos_pkg_dirs b/centos_pkg_dirs index 1f75a0fa2..887f68848 100644 --- a/centos_pkg_dirs +++ b/centos_pkg_dirs @@ -112,3 +112,4 @@ filesystem/filesystem-scripts utilities/branding config-files/io-scheduler tools/collector +grub/grubby diff --git a/grub/grubby/centos/build_srpm.data b/grub/grubby/centos/build_srpm.data new file mode 100644 index 000000000..ca7519660 --- /dev/null +++ b/grub/grubby/centos/build_srpm.data @@ -0,0 +1,2 @@ +COPY_LIST="" +TIS_PATCH_VER=3 diff --git a/grub/grubby/centos/meta_patches/0001-grubby-Update-package-versioning-for-TIS-format.patch b/grub/grubby/centos/meta_patches/0001-grubby-Update-package-versioning-for-TIS-format.patch new file mode 100644 index 000000000..2e0ef7bd4 --- /dev/null +++ b/grub/grubby/centos/meta_patches/0001-grubby-Update-package-versioning-for-TIS-format.patch @@ -0,0 +1,27 @@ +From aecf1e4686bbd50e96bea030bdf7ee4f4882fe5c Mon Sep 17 00:00:00 2001 +From: Scott Little +Date: Mon, 2 Oct 2017 17:23:24 -0400 +Subject: [PATCH 1/2] WRS: + 0001-grubby-Update-package-versioning-for-TIS-format.patch + +Conflicts: + SPECS/grubby.spec +--- + SPECS/grubby.spec | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/SPECS/grubby.spec b/SPECS/grubby.spec +index dd8fa7f..22bff31 100644 +--- a/SPECS/grubby.spec ++++ b/SPECS/grubby.spec +@@ -1,6 +1,6 @@ + Name: grubby + Version: 8.28 +-Release: 23%{?dist} ++Release: 23.el7%{?_tis_dist}.%{tis_patch_ver} + Summary: Command line tool for updating bootloader configs + Group: System Environment/Base + License: GPLv2+ +-- +1.9.1 + diff --git a/grub/grubby/centos/meta_patches/0002-grubby-Generic-name-for-Titanium.patch b/grub/grubby/centos/meta_patches/0002-grubby-Generic-name-for-Titanium.patch new file mode 100644 index 000000000..ba1707708 --- /dev/null +++ b/grub/grubby/centos/meta_patches/0002-grubby-Generic-name-for-Titanium.patch @@ -0,0 +1,26 @@ +From 3c4f2fef7d1d321a34a9777946879f187fdad2bc Mon Sep 17 00:00:00 2001 +From: Scott Little +Date: Mon, 2 Oct 2017 17:23:24 -0400 +Subject: [PATCH 2/2] WRS: 0002-grubby-Generic-name-for-Titanium.patch + +--- + SPECS/grubby.spec | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/SPECS/grubby.spec b/SPECS/grubby.spec +index 22bff31..882339a 100644 +--- a/SPECS/grubby.spec ++++ b/SPECS/grubby.spec +@@ -83,6 +83,9 @@ Patch0073: 0073-Fix-info-for-s390x-s390-1285601.patch + Patch0074: 0074-Add-s390-s390x-set-default-index-test-1285601.patch + Patch0075: 0075-Fix-setDefaultImage-for-s390-s390x-1285601.patch + ++# WRS Titanium patches ++Patch1000: 1000-Generic-name-for-Titanium.patch ++ + BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + BuildRequires: pkgconfig glib2-devel popt-devel + BuildRequires: libblkid-devel git +-- +1.9.1 + diff --git a/grub/grubby/centos/meta_patches/0003-grubby-add-multiboot2.patch b/grub/grubby/centos/meta_patches/0003-grubby-add-multiboot2.patch new file mode 100644 index 000000000..0c021e3e3 --- /dev/null +++ b/grub/grubby/centos/meta_patches/0003-grubby-add-multiboot2.patch @@ -0,0 +1,59 @@ +From 40211dceb45803c4bb4ff2afbc993f230872ad51 Mon Sep 17 00:00:00 2001 +From: Bin Qian +Date: Tue, 13 Feb 2018 23:02:49 -0500 +Subject: [PATCH 1/1] grubby add multiboot2 + +--- + SPECS/grubby.spec | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +diff --git a/SPECS/grubby.spec b/SPECS/grubby.spec +index 071463a..a3bb371 100644 +--- a/SPECS/grubby.spec ++++ b/SPECS/grubby.spec +@@ -85,6 +85,7 @@ Patch0075: 0075-Fix-setDefaultImage-for-s390-s390x-1285601.patch + + # WRS Titanium patches + Patch1000: 1000-Generic-name-for-Titanium.patch ++Patch1001: 1001-Add-support-for-updating-grub-cfg-with-multiboot-2.patch + + BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + BuildRequires: pkgconfig glib2-devel popt-devel +@@ -101,6 +102,10 @@ Requires: s390utils-base + Requires: uboot-tools + %endif + Requires: system-release ++BuildRequires: python-setuptools ++Requires: python-devel ++ ++%define pythonroot /usr/lib64/python2.7/site-packages + + %description + grubby is a command line tool for updating and displaying information about +@@ -140,6 +145,11 @@ mkdir -p $RPM_BUILD_ROOT/boot + echo " " >> $RPM_BUILD_ROOT/boot/boot.scr + %endif + ++install -d -m 0755 $RPM_BUILD_ROOT/%{pythonroot}/grubby ++install -m 644 grub_cfg_update.py $RPM_BUILD_ROOT/%{pythonroot}/grubby/grub_cfg_update.py ++install -m 644 __init__.py $RPM_BUILD_ROOT/%{pythonroot}/grubby/__init__.py ++install -m 500 grub-cfg-update $RPM_BUILD_ROOT/usr/sbin/grub-cfg-update ++ + %clean + rm -rf $RPM_BUILD_ROOT + +@@ -152,6 +162,11 @@ rm -rf $RPM_BUILD_ROOT + %{_prefix}/sbin/installkernel + %{_prefix}/sbin/new-kernel-pkg + %{_prefix}/sbin/grubby ++%{pythonroot}/grubby ++%{_prefix}/sbin/grub-cfg-update ++%{pythonroot}/grubby/grub_cfg_update.py ++%{pythonroot}/grubby/__init__.py ++ + %{_mandir}/man8/*.8* + /usr/libexec/grubby/prune_debug + %ghost %config(noreplace) %{_sysconfdir}/sysconfig/kernel +-- +1.8.3.1 + diff --git a/grub/grubby/centos/meta_patches/PATCH_ORDER b/grub/grubby/centos/meta_patches/PATCH_ORDER new file mode 100644 index 000000000..26c430d5b --- /dev/null +++ b/grub/grubby/centos/meta_patches/PATCH_ORDER @@ -0,0 +1,3 @@ +0001-grubby-Update-package-versioning-for-TIS-format.patch +0002-grubby-Generic-name-for-Titanium.patch +0003-grubby-add-multiboot2.patch diff --git a/grub/grubby/centos/patches/1000-Generic-name-for-Titanium.patch b/grub/grubby/centos/patches/1000-Generic-name-for-Titanium.patch new file mode 100644 index 000000000..57662b925 --- /dev/null +++ b/grub/grubby/centos/patches/1000-Generic-name-for-Titanium.patch @@ -0,0 +1,25 @@ +From 7d3bd33be8b2c9924a2987710f54f5c62853d86c Mon Sep 17 00:00:00 2001 +From: jmckenna +Date: Wed, 5 Apr 2017 09:35:06 -0400 +Subject: [PATCH] Use generic OS title for Titanium + +--- + new-kernel-pkg | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/new-kernel-pkg b/new-kernel-pkg +index 847e959..977ef2d 100755 +--- a/new-kernel-pkg ++++ b/new-kernel-pkg +@@ -166,6 +166,8 @@ set_title() { + fi + elif [ $ARCH = 's390' -o $ARCH = 's390x' ]; then + title=$(echo $version | sed 's/ /_/g') ++ elif [ -f /etc/build.info ]; then ++ title="Linux ($version)" + elif [ -f /etc/os-release ]; then + . /etc/os-release + title="$NAME ($version) $VERSION" +-- +1.9.1 + diff --git a/grub/grubby/centos/patches/1001-Add-support-for-updating-grub-cfg-with-multiboot-2.patch b/grub/grubby/centos/patches/1001-Add-support-for-updating-grub-cfg-with-multiboot-2.patch new file mode 100644 index 000000000..c91096dbb --- /dev/null +++ b/grub/grubby/centos/patches/1001-Add-support-for-updating-grub-cfg-with-multiboot-2.patch @@ -0,0 +1,263 @@ +From b2fc58bcd1f18cbc3e0b3d303e9f2132d0e36cd8 Mon Sep 17 00:00:00 2001 +From: Bin Qian +Date: Tue, 13 Feb 2018 22:48:54 -0500 +Subject: [PATCH 1/1] Add support for updating grub.cfg with multiboot 2 + +--- + Makefile | 5 +++ + __init__.py | 8 ++++ + grub-cfg-update | 17 ++++++++ + grub_cfg_update.py | 126 +++++++++++++++++++++++++++++++++++++++++++++++++++++ + new-kernel-pkg | 33 ++++++++++---- + 5 files changed, 181 insertions(+), 8 deletions(-) + create mode 100644 __init__.py + create mode 100644 grub-cfg-update + create mode 100644 grub_cfg_update.py + +diff --git a/Makefile b/Makefile +index e021f35..93fa41b 100644 +--- a/Makefile ++++ b/Makefile +@@ -56,6 +56,11 @@ install: all + install -m 755 grubby $(DESTDIR)$(PREFIX)/sbin ; \ + install -m 644 grubby.8 $(DESTDIR)/$(mandir)/man8 ; \ + fi ++ mkdir -p $(DESTDIR)/usr/lib64/python2.7/site-packages/grubby ++ install -m 644 grub_cfg_update.py $(DESTDIR)/usr/lib64/python2.7/site-packages/grubby/grub_cfg_update.py ++ install -m 644 __init__.py $(DESTDIR)/usr/lib64/python2.7/site-packages/grubby/__init__.py ++ install -m 500 grub-cfg-update $(DESTDIR)$(PREFIX)/sbin/grub-cfg-update ++ + + grubby:: $(OBJECTS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(grubby_LIBS) +diff --git a/__init__.py b/__init__.py +new file mode 100644 +index 0000000..5f30af6 +--- /dev/null ++++ b/__init__.py +@@ -0,0 +1,8 @@ ++#!/usr/bin/env python ++# ++# Copyright (c) 2018 Wind River Systems, Inc. ++# SPDX-License-Identifier: Apache-2.0 ++# ++# ++# ++# +\ No newline at end of file +diff --git a/grub-cfg-update b/grub-cfg-update +new file mode 100644 +index 0000000..5e457e9 +--- /dev/null ++++ b/grub-cfg-update +@@ -0,0 +1,17 @@ ++#!/usr/bin/env python ++ ++""" ++Copyright (c) 2018 Wind River Systems, Inc. ++ SPDX-License-Identifier: Apache-2.0 ++ ++ ++ ++""" ++ ++import sys ++ ++from grubby.grub_cfg_update import main ++ ++if __name__ == "__main__": ++ main() ++ +diff --git a/grub_cfg_update.py b/grub_cfg_update.py +new file mode 100644 +index 0000000..f5cd174 +--- /dev/null ++++ b/grub_cfg_update.py +@@ -0,0 +1,126 @@ ++#!/usr/bin/env python ++# ++# Copyright (c) 2018 Wind River Systems, Inc. ++# SPDX-License-Identifier: Apache-2.0 ++# ++# ++# ++# ++import sys ++import argparse ++import os.path ++import re ++import ntpath ++ ++ ++LINUX_KERNEL_RE = "^[ \t]*module2[ \t]{1,}/vmlinuz-[^ \n\t]*" ++INITRD_RE = "^[ \t]*module2[ \t]{1,}/initramfs-[^ \n\t]*" ++ ++ ++def is_title(line): ++ m = re.search('^[ ]*menuentry ', line) ++ if m: ++ return True ++ return False ++ ++ ++def update_title(line, ver): ++ m = re.search("Linux [^ \n\t']*", line) ++ if not m: ++ print "Title pattern not understandable, not updated" ++ return line ++ new_line = re.sub("Linux [^ \n\t']*", "Linux %s" % ver, line) ++ return new_line ++ ++ ++def is_kernel(line): ++ m = re.search(LINUX_KERNEL_RE, line) ++ if m: ++ return True ++ return False ++ ++ ++def update_kernel(line, kernel): ++ kernel_name = ntpath.basename(kernel) ++ new_line = re.sub(LINUX_KERNEL_RE, ++ " module2 /%s" % kernel_name, ++ line) ++ return new_line ++ ++ ++def is_initrd(line): ++ m = re.search(INITRD_RE, line) ++ if m: ++ return True ++ return False ++ ++ ++def update_initrd(line, initrd): ++ initrd_name = ntpath.basename(initrd) ++ new_line = re.sub(INITRD_RE, ++ " module2 /%s" % initrd_name, ++ line) ++ return new_line ++ ++ ++def convert_line(line, version): ++ pattern = "^[ \t]*echo[ \t]*['\"]Loading Linux [^ \n\t]*" ++ m = re.search(pattern, line) ++ if not m: ++ return line ++ ++ return " echo 'Loading Linux %s ...'\n" % version ++ ++ ++def update_cfg(cfg, kernel, initramfs, ver, cfg_out): ++ if not os.path.isfile(cfg): ++ print "grub config file %s not found\n" % cfg ++ sys.exit(-1) ++ ++ if not os.path.isfile(kernel): ++ print "specified kernel file %s not found\n" % kernel ++ sys.exit(-1) ++ ++ if not os.path.isfile(initramfs): ++ print "specified initrd file %s not found\n" % initramfs ++ sys.exit(-1) ++ ++ new_file_content = [] ++ with open(cfg) as f: ++ for line in f: ++ if is_title(line): ++ new_line = update_title(line, ver) ++ print new_line ++ elif is_kernel(line): ++ new_line = update_kernel(line, kernel) ++ print new_line ++ elif is_initrd(line): ++ new_line = update_initrd(line, initramfs) ++ print new_line ++ else: ++ new_line = convert_line(line, ver) ++ print new_line ++ ++ new_file_content.append(new_line) ++ with open(cfg_out, 'w') as f: ++ for line in new_file_content: ++ f.write("%s" % line) ++ ++ ++def main(): ++ try: ++ parser = argparse.ArgumentParser(description='Update tboot enabled grub config') ++ parser.add_argument('cfg', help='original grub.cfg file path') ++ parser.add_argument('kernel', help='kernel file path') ++ parser.add_argument('initramfs', help='initramfs file path') ++ parser.add_argument('version', help='new version of kernel') ++ parser.add_argument('--cfg-out', help='updated grub.cfg target file path') ++ args = parser.parse_args() ++ cfg_out = args.cfg_out ++ if cfg_out is None: ++ cfg_out = args.cfg ++ ++ update_cfg(args.cfg, args.kernel, args.initramfs, args.version, cfg_out) ++ except Exception as e: ++ print e ++ sys.exit(-1) +diff --git a/new-kernel-pkg b/new-kernel-pkg +index 977ef2d..1bb0a64 100755 +--- a/new-kernel-pkg ++++ b/new-kernel-pkg +@@ -185,6 +185,11 @@ install() { + return + fi + ++ grep -q 'tboot=true' /proc/cmdline 2>/dev/null ++ if [ $? == 0 ] ; then ++ return ++ fi ++ + INITRD="" + if [ -f $initrdfile ]; then + [ -n "$verbose" ] && echo "found $initrdfile and using it with grubby" +@@ -334,6 +339,11 @@ remove() { + return + fi + ++ grep -q 'tboot=true' /proc/cmdline 2>/dev/null ++ if [ $? == 0 ] ; then ++ return ++ fi ++ + local files + local f + files="/etc/kernel/prerm.d/*[^~] /etc/kernel/prerm.d/$version/*[^~]" +@@ -483,14 +493,21 @@ update() { + fi + + if [ -n "$cfgGrub2Efi" ]; then +- [ -n "$verbose" ] && echo "updating $version from $grub2EfiConfig" +- ARGS="--grub2 -c $grub2EfiConfig --efi --update-kernel=$kernelImage \ +- $INITRD ${kernargs:+--args=\"$kernargs\"} \ +- ${removeargs:+--remove-args=\"$removeargs\"} \ +- --title=\"$title\$debugtitle\"" +- +- rungrubby ${ARGS} +- rungrubby --debug ${ARGS} ++ grep -q 'tboot=true' /proc/cmdline 2>/dev/null ++ if [ $? == 0 ] ; then ++ [ -n "$verbose" ] && echo "calling grub-cfg-update $grub2EfiConfig $kernelImage $initrdfile $version" ++ grub-cfg-update $grub2EfiConfig $kernelImage $initrdfile $version ++ return ++ else ++ [ -n "$verbose" ] && echo "updating $version from $grub2EfiConfig" ++ ARGS="--grub2 -c $grub2EfiConfig --efi --update-kernel=$kernelImage \ ++ $INITRD ${kernargs:+--args=\"$kernargs\"} \ ++ ${removeargs:+--remove-args=\"$removeargs\"} \ ++ --title=\"$title\$debugtitle\"" ++ ++ rungrubby ${ARGS} ++ rungrubby --debug ${ARGS} ++ fi + else + [ -n "$verbose" ] && echo "$grub2EfiConfig does not exist, not running grubby" + fi +-- +1.8.3.1 + diff --git a/grub/grubby/centos/srpm_path b/grub/grubby/centos/srpm_path new file mode 100644 index 000000000..09f4c437b --- /dev/null +++ b/grub/grubby/centos/srpm_path @@ -0,0 +1 @@ +mirror:Source/grubby-8.28-23.el7.src.rpm