Compare commits
29 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
69e614eab8 | ||
|
e6b270b9d2 | ||
|
74ff4810be | ||
|
1faea2de0a | ||
|
c8241463d7 | ||
|
29fb24f205 | ||
|
810b5eee5a | ||
|
78927fa5ed | ||
|
599a2e1a99 | ||
|
79765ad0d7 | ||
|
aaefddefe8 | ||
|
415ad451de | ||
|
1bc3038166 | ||
|
59ba93105a | ||
|
dfdd26c908 | ||
|
0dd1a4fc40 | ||
|
eaef784cc6 | ||
|
e69860d718 | ||
|
9ebc469d54 | ||
|
e94425201f | ||
|
2b59d1355d | ||
|
5d3963841d | ||
|
786a133370 | ||
|
fd57e031d4 | ||
|
536f42db1c | ||
|
b91640a743 | ||
|
3498276978 | ||
|
1ead121a08 | ||
|
a5c9c3a138 |
28
0013-Fix-build-with-rpm-4.16.patch
Normal file
28
0013-Fix-build-with-rpm-4.16.patch
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
From 1afddd618629a97479560bedbdcfa11b2c492a0e Mon Sep 17 00:00:00 2001
|
||||||
|
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||||
|
Date: Fri, 26 Jun 2020 10:02:51 +0200
|
||||||
|
Subject: [PATCH] Fix build with rpm-4.16
|
||||||
|
|
||||||
|
rpmvercmp() was moved to librpmio, so link against this library instead.
|
||||||
|
|
||||||
|
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||||
|
---
|
||||||
|
Makefile | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/Makefile b/Makefile
|
||||||
|
index 1ab58aeb039..a54b053a30b 100644
|
||||||
|
--- a/Makefile
|
||||||
|
+++ b/Makefile
|
||||||
|
@@ -59,7 +59,7 @@ grubby:: $(OBJECTS)
|
||||||
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(grubby_LIBS)
|
||||||
|
|
||||||
|
rpm-sort::rpm-sort.o
|
||||||
|
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ -lrpm
|
||||||
|
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ -lrpmio
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o grubby rpm-sort *~
|
||||||
|
--
|
||||||
|
2.26.2
|
||||||
|
|
73
10-devicetree.install
Executable file
73
10-devicetree.install
Executable file
@ -0,0 +1,73 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# set -x
|
||||||
|
|
||||||
|
if [[ "$(uname -m)" == arm* || "$(uname -m)" == aarch64 ]]
|
||||||
|
then
|
||||||
|
COMMAND="$1"
|
||||||
|
KERNEL_VERSION="$2"
|
||||||
|
#BOOT_DIR_ABS="$3"
|
||||||
|
#KERNEL_IMAGE="$4"
|
||||||
|
|
||||||
|
[ -f /etc/u-boot.conf ] && source /etc/u-boot.conf || true
|
||||||
|
[ -z "$FIRMWAREDT" ] || FirmwareDT=$FIRMWAREDT
|
||||||
|
|
||||||
|
if [[ $FirmwareDT == "True" ]]
|
||||||
|
then
|
||||||
|
# if we want to use firmware DT we remove symlink to current kernel DT
|
||||||
|
if [ -h /boot/dtb ]; then
|
||||||
|
rm -f /boot/dtb
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Setup a /boot/dtb -> /boot/dtb-$newest_kernel_version symlink so that
|
||||||
|
# u-boot can find the correct dtb to load.
|
||||||
|
#
|
||||||
|
# If invoked to 'add' a new kernel, find the newest based on `sort`ing
|
||||||
|
# the kernel versions dtb. If 'remove', then follow basically the same
|
||||||
|
# procedure but exclude the version currently being removed.
|
||||||
|
#
|
||||||
|
# The theory of operation here is that, while newer kernels may add new
|
||||||
|
# dtb nodes and fields, as upstreaming hw support for some particular
|
||||||
|
# device progresses, it should never make backward incompatible changes.
|
||||||
|
# So it should always be safe to use a newer dtb with an older kernel.
|
||||||
|
|
||||||
|
list_dtb_versions() {
|
||||||
|
excluded_version="$1"
|
||||||
|
for dtbdir in /boot/dtb-*; do
|
||||||
|
dtbver=${dtbdir#*-}
|
||||||
|
if [ "$dtbver" != "$excluded_version" ]; then
|
||||||
|
echo $dtbver
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_dtb_link() {
|
||||||
|
ver=`list_dtb_versions $1 | sort -r --sort=version | head -1`
|
||||||
|
if [ -h /boot/dtb ]; then
|
||||||
|
rm -f /boot/dtb
|
||||||
|
fi
|
||||||
|
ln -s dtb-$ver /boot/dtb
|
||||||
|
}
|
||||||
|
|
||||||
|
ret=0
|
||||||
|
case "$COMMAND" in
|
||||||
|
add)
|
||||||
|
# If we're adding a kernel we want that version
|
||||||
|
if [ -h /boot/dtb ]; then
|
||||||
|
rm -f /boot/dtb
|
||||||
|
fi
|
||||||
|
ln -s dtb-$KERNEL_VERSION /boot/dtb
|
||||||
|
ret=$?
|
||||||
|
;;
|
||||||
|
remove)
|
||||||
|
setup_dtb_link $KERNEL_VERSION
|
||||||
|
ret=$?
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
exit $ret
|
||||||
|
else
|
||||||
|
# Just exit on non ARM
|
||||||
|
exit 0
|
||||||
|
fi
|
55
grubby-bls
55
grubby-bls
@ -235,7 +235,7 @@ get_bls_args() {
|
|||||||
local opts=(${args})
|
local opts=(${args})
|
||||||
|
|
||||||
for opt in ${opts[*]}; do
|
for opt in ${opts[*]}; do
|
||||||
if [[ $opt =~ ^\$ ]]; then
|
if [[ $opt = "\$kernelopts" ]]; then
|
||||||
value="$(expand_var $opt)"
|
value="$(expand_var $opt)"
|
||||||
args="$(echo ${args} | sed -e "s/${opt}/${value}/")"
|
args="$(echo ${args} | sed -e "s/${opt}/${value}/")"
|
||||||
fi
|
fi
|
||||||
@ -429,7 +429,7 @@ add_bls_fragment() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n $extra_initrd ]]; then
|
if [[ -n $extra_initrd ]]; then
|
||||||
append_bls_value "${bls_target}" "initrd" "${extra_initrd}"
|
append_bls_value "${bls_target}" "initrd" " ${extra_initrd}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $MAKEDEBUG = "yes" ]]; then
|
if [[ $MAKEDEBUG = "yes" ]]; then
|
||||||
@ -528,6 +528,20 @@ update_bls_fragment() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ $param = "ALL" ]] && [[ -n $remove_args || -n $add_args ]]; then
|
||||||
|
if [[ ! -f /etc/kernel/cmdline ]]; then
|
||||||
|
# anaconda could pre-populate this file, but until then, most of
|
||||||
|
# the time we'll just want the most recent one. This is pretty
|
||||||
|
# close to the current almost-correct behavior of falling back to
|
||||||
|
# /proc/cmdline anyhow.
|
||||||
|
echo "$(get_bls_args -1)" > /etc/kernel/cmdline
|
||||||
|
fi
|
||||||
|
|
||||||
|
read old_args < /etc/kernel/cmdline
|
||||||
|
local new_args="$(update_args "${old_args}" "${remove_args}" "${add_args}")"
|
||||||
|
echo "$new_args" > /etc/kernel/cmdline
|
||||||
|
fi
|
||||||
|
|
||||||
update_grubcfg
|
update_grubcfg
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,7 +581,7 @@ remove_var_prefix() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n $extra_initrd ]]; then
|
if [[ -n $extra_initrd ]]; then
|
||||||
extra_initrd=" /${extra_initrd##${prefix}/}"
|
extra_initrd="/${extra_initrd##${prefix}/}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n $kernel ]]; then
|
if [[ -n $kernel ]]; then
|
||||||
@ -581,8 +595,33 @@ remove_var_prefix() {
|
|||||||
|
|
||||||
update_grubcfg()
|
update_grubcfg()
|
||||||
{
|
{
|
||||||
if [[ $arch = 'ppc64' || $arch = 'ppc64le' ]]; then
|
# Older ppc64le OPAL firmware (petitboot version < 1.8.0) don't have BLS support
|
||||||
grub2-mkconfig --no-grubenv-update -o "${grub_config}" >& /dev/null
|
# so grub2-mkconfig has to be run to generate a config with menuentry commands.
|
||||||
|
if [ "${arch}" = "ppc64le" ] && [ -d /sys/firmware/opal ]; then
|
||||||
|
RUN_MKCONFIG="true"
|
||||||
|
petitboot_path="/sys/firmware/devicetree/base/ibm,firmware-versions/petitboot"
|
||||||
|
|
||||||
|
if test -e ${petitboot_path}; then
|
||||||
|
read -r -d '' petitboot_version < ${petitboot_path}
|
||||||
|
petitboot_version="$(echo ${petitboot_version//v})"
|
||||||
|
|
||||||
|
if test -n ${petitboot_version}; then
|
||||||
|
major_version="$(echo ${petitboot_version} | cut -d . -f1)"
|
||||||
|
minor_version="$(echo ${petitboot_version} | cut -d . -f2)"
|
||||||
|
|
||||||
|
re='^[0-9]+$'
|
||||||
|
if [[ $major_version =~ $re ]] && [[ $minor_version =~ $re ]] &&
|
||||||
|
([[ ${major_version} -gt 1 ]] ||
|
||||||
|
[[ ${major_version} -eq 1 &&
|
||||||
|
${minor_version} -ge 8 ]]); then
|
||||||
|
RUN_MKCONFIG="false"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $RUN_MKCONFIG = "true" ]]; then
|
||||||
|
grub2-mkconfig --no-grubenv-update -o "${grub_config}" >& /dev/null
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -616,12 +655,12 @@ Usage: grubby [OPTION...]
|
|||||||
--no-etc-grub-update don't update the GRUB_CMDLINE_LINUX variable in /etc/default/grub
|
--no-etc-grub-update don't update the GRUB_CMDLINE_LINUX variable in /etc/default/grub
|
||||||
|
|
||||||
Help options:
|
Help options:
|
||||||
-?, --help Show this help message
|
-h, --help Show this help message
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
OPTS="$(getopt -o c:i:b:? --long help,add-kernel:,args:,bad-image-okay,\
|
OPTS="$(getopt -o hc:i:b:? --long help,add-kernel:,args:,bad-image-okay,\
|
||||||
config-file:,copy-default,default-kernel,default-index,default-title,env:,\
|
config-file:,copy-default,default-kernel,default-index,default-title,env:,\
|
||||||
grub2,info:,initrd:,extra-initrd:,make-default,remove-args:,\
|
grub2,info:,initrd:,extra-initrd:,make-default,remove-args:,\
|
||||||
remove-kernel:,set-default:,set-default-index:,title:,update-kernel:,zipl,\
|
remove-kernel:,set-default:,set-default-index:,title:,update-kernel:,zipl,\
|
||||||
@ -683,7 +722,7 @@ while [ ${#} -gt 0 ]; do
|
|||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--extra-initrd|-i)
|
--extra-initrd|-i)
|
||||||
extra_initrd=" /${2}"
|
extra_initrd="${2}"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--make-default)
|
--make-default)
|
||||||
|
14
grubby.8
14
grubby.8
@ -19,13 +19,10 @@ about the configuration files for the \fBgrub2\fR and \fBzipl\fR boot loaders.
|
|||||||
It is primarily designed to be used from scripts which install new kernels and
|
It is primarily designed to be used from scripts which install new kernels and
|
||||||
need to find information about the current boot environment.
|
need to find information about the current boot environment.
|
||||||
|
|
||||||
On BIOS-based Intel x86 platforms, \fBgrub2\fR is the default bootloader and
|
On BIOS-based Intel x86, PowerPC and UEFI-based platforms, \fBgrub2\fR is the
|
||||||
the configuration file is in \fB/boot/grub2/grub.cfg\fR. On UEFI-based Intel
|
default bootloader and the configuration file is in \fB/boot/grub2/grub.cfg\fR.
|
||||||
x86 platforms, \fBgrub2\fR is the default bootloader, and the configuration
|
On s390x platforms, the \fBzipl\fR bootloader use a default configuration in
|
||||||
file is in \fB/boot/efi/EFI/redhat/grub.cfg\fR. On PowerPC platforms, systems
|
\fB/etc/zipl.conf\fR.
|
||||||
based on Power8 and Power9 support \fBgrub2\fR as a bootloader and use a
|
|
||||||
configuration stored in \fB/boot/grub2/grub.cfg\fR. On s390x platforms the
|
|
||||||
\fBzipl\fR bootloader use a default configuration in \fB/etc/zipl.conf\fR.
|
|
||||||
|
|
||||||
All bootloaders define the boot entries as individual configuration fragments
|
All bootloaders define the boot entries as individual configuration fragments
|
||||||
that are stored by default in \fB/boot/loader/entries\fR. The format for the
|
that are stored by default in \fB/boot/loader/entries\fR. The format for the
|
||||||
@ -148,7 +145,8 @@ the only items that can be updated is the kernel argument list, which is
|
|||||||
modified via the \fB-\-args\fR and \fB-\-remove-args\fR options. If the
|
modified via the \fB-\-args\fR and \fB-\-remove-args\fR options. If the
|
||||||
\fBALL\fR argument is used the variable \fB GRUB_CMDLINE_LINUX\fR in
|
\fBALL\fR argument is used the variable \fB GRUB_CMDLINE_LINUX\fR in
|
||||||
\fB/etc/default/grub\fR is updated with the latest kernel argument list,
|
\fB/etc/default/grub\fR is updated with the latest kernel argument list,
|
||||||
unless the \fB-\-no-etc-grub-update\fR option is used.
|
unless the \fB-\-no-etc-grub-update\fR option is used or the file does not
|
||||||
|
exist (e.g., on s390x).
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fB-\-zipl\fR
|
\fB-\-zipl\fR
|
||||||
|
114
grubby.spec
114
grubby.spec
@ -1,6 +1,6 @@
|
|||||||
Name: grubby
|
Name: grubby
|
||||||
Version: 8.40
|
Version: 8.40
|
||||||
Release: 45%{?dist}
|
Release: 67%{?dist}
|
||||||
Summary: Command line tool for updating bootloader configs
|
Summary: Command line tool for updating bootloader configs
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
URL: https://github.com/rhinstaller/grubby
|
URL: https://github.com/rhinstaller/grubby
|
||||||
@ -14,7 +14,9 @@ Source2: grubby.in
|
|||||||
Source3: installkernel.in
|
Source3: installkernel.in
|
||||||
Source4: installkernel-bls
|
Source4: installkernel-bls
|
||||||
Source5: 95-kernel-hooks.install
|
Source5: 95-kernel-hooks.install
|
||||||
Source6: grubby.8
|
Source6: 10-devicetree.install
|
||||||
|
Source7: grubby.8
|
||||||
|
|
||||||
Patch0001: 0001-remove-the-old-crufty-u-boot-support.patch
|
Patch0001: 0001-remove-the-old-crufty-u-boot-support.patch
|
||||||
Patch0002: 0002-Change-return-type-in-getRootSpecifier.patch
|
Patch0002: 0002-Change-return-type-in-getRootSpecifier.patch
|
||||||
Patch0003: 0003-Add-btrfs-subvolume-support-for-grub2.patch
|
Patch0003: 0003-Add-btrfs-subvolume-support-for-grub2.patch
|
||||||
@ -27,46 +29,41 @@ Patch0009: 0009-Improve-man-page-for-info-option.patch
|
|||||||
Patch0010: 0010-Fix-GCC-warnings-about-possible-string-truncations-a.patch
|
Patch0010: 0010-Fix-GCC-warnings-about-possible-string-truncations-a.patch
|
||||||
Patch0011: 0011-Fix-stringop-overflow-warning.patch
|
Patch0011: 0011-Fix-stringop-overflow-warning.patch
|
||||||
Patch0012: 0012-Fix-maybe-uninitialized-warning.patch
|
Patch0012: 0012-Fix-maybe-uninitialized-warning.patch
|
||||||
|
Patch0013: 0013-Fix-build-with-rpm-4.16.patch
|
||||||
|
|
||||||
BuildRequires: gcc
|
BuildRequires: gcc
|
||||||
BuildRequires: pkgconfig glib2-devel popt-devel
|
BuildRequires: pkgconfig glib2-devel popt-devel
|
||||||
BuildRequires: libblkid-devel git-core sed make
|
BuildRequires: libblkid-devel sed make
|
||||||
# for make test / getopt:
|
# for make test / getopt:
|
||||||
BuildRequires: util-linux-ng
|
BuildRequires: util-linux-ng
|
||||||
BuildRequires: rpm-devel
|
BuildRequires: rpm-devel
|
||||||
%ifarch aarch64 i686 x86_64 %{power64}
|
BuildRequires: sed
|
||||||
|
%ifarch aarch64 x86_64 %{power64}
|
||||||
BuildRequires: grub2-tools-minimal
|
BuildRequires: grub2-tools-minimal
|
||||||
Requires: grub2-tools-minimal
|
Requires: grub2-tools-minimal
|
||||||
Requires: grub2-tools
|
Requires: grub2-tools
|
||||||
%endif
|
%endif
|
||||||
%ifarch s390 s390x
|
%ifarch s390 s390x
|
||||||
Requires: s390utils-base
|
Requires: s390utils-core
|
||||||
%endif
|
%endif
|
||||||
Requires: findutils
|
Requires: findutils
|
||||||
Requires: util-linux
|
Requires: util-linux
|
||||||
|
|
||||||
|
ExcludeArch: %{ix86}
|
||||||
|
Conflicts: uboot-tools < 2021.01-0.1.rc2
|
||||||
Obsoletes: %{name}-bls < %{version}-%{release}
|
Obsoletes: %{name}-bls < %{version}-%{release}
|
||||||
|
|
||||||
%description
|
%description
|
||||||
This package provides a grubby compatibility script that manages
|
This package provides a grubby compatibility script that manages
|
||||||
BootLoaderSpec files and is meant to only be used for legacy compatibility
|
BootLoaderSpec files and is meant to be backward compatible with
|
||||||
users with existing grubby users.
|
the previous grubby tool.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n grubby-%{version}-1
|
%autosetup -p1 -n grubby-%{version}-1
|
||||||
|
|
||||||
git init
|
|
||||||
git config user.email "noone@example.com"
|
|
||||||
git config user.name "no one"
|
|
||||||
git add .
|
|
||||||
git commit -a -q -m "%{version} baseline"
|
|
||||||
git am %{patches} </dev/null
|
|
||||||
git config --unset user.email
|
|
||||||
git config --unset user.name
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%set_build_flags
|
%set_build_flags
|
||||||
make %{?_smp_mflags} LDFLAGS="${LDFLAGS}"
|
%make_build LDFLAGS="${LDFLAGS}"
|
||||||
|
|
||||||
%ifnarch aarch64 %{arm}
|
%ifnarch aarch64 %{arm}
|
||||||
%check
|
%check
|
||||||
@ -86,8 +83,9 @@ sed -e "s,@@LIBEXECDIR@@,%{_libexecdir}/grubby,g" %{SOURCE2} \
|
|||||||
sed -e "s,@@LIBEXECDIR@@,%{_libexecdir}/installkernel,g" %{SOURCE3} \
|
sed -e "s,@@LIBEXECDIR@@,%{_libexecdir}/installkernel,g" %{SOURCE3} \
|
||||||
> %{buildroot}%{_sbindir}/installkernel
|
> %{buildroot}%{_sbindir}/installkernel
|
||||||
install -D -m 0755 -t %{buildroot}%{_prefix}/lib/kernel/install.d/ %{SOURCE5}
|
install -D -m 0755 -t %{buildroot}%{_prefix}/lib/kernel/install.d/ %{SOURCE5}
|
||||||
|
install -D -m 0755 -t %{buildroot}%{_prefix}/lib/kernel/install.d/ %{SOURCE6}
|
||||||
rm %{buildroot}%{_mandir}/man8/grubby.8*
|
rm %{buildroot}%{_mandir}/man8/grubby.8*
|
||||||
install -m 0644 %{SOURCE6} %{buildroot}%{_mandir}/man8/
|
install -m 0644 %{SOURCE7} %{buildroot}%{_mandir}/man8/
|
||||||
|
|
||||||
%post
|
%post
|
||||||
if [ "$1" = 2 ]; then
|
if [ "$1" = 2 ]; then
|
||||||
@ -111,7 +109,6 @@ scripts which install new kernels and need to find information about the
|
|||||||
current boot environment.
|
current boot environment.
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%{!?_licensedir:%global license %%doc}
|
|
||||||
%license COPYING
|
%license COPYING
|
||||||
%dir %{_libexecdir}/grubby
|
%dir %{_libexecdir}/grubby
|
||||||
%dir %{_libexecdir}/installkernel
|
%dir %{_libexecdir}/installkernel
|
||||||
@ -120,11 +117,11 @@ current boot environment.
|
|||||||
%attr(0755,root,root) %{_sbindir}/grubby
|
%attr(0755,root,root) %{_sbindir}/grubby
|
||||||
%attr(0755,root,root) %{_libexecdir}/installkernel/installkernel-bls
|
%attr(0755,root,root) %{_libexecdir}/installkernel/installkernel-bls
|
||||||
%attr(0755,root,root) %{_sbindir}/installkernel
|
%attr(0755,root,root) %{_sbindir}/installkernel
|
||||||
|
%attr(0755,root,root) %{_prefix}/lib/kernel/install.d/10-devicetree.install
|
||||||
%attr(0755,root,root) %{_prefix}/lib/kernel/install.d/95-kernel-hooks.install
|
%attr(0755,root,root) %{_prefix}/lib/kernel/install.d/95-kernel-hooks.install
|
||||||
%{_mandir}/man8/[gi]*.8*
|
%{_mandir}/man8/[gi]*.8*
|
||||||
|
|
||||||
%files deprecated
|
%files deprecated
|
||||||
%{!?_licensedir:%global license %%doc}
|
|
||||||
%license COPYING
|
%license COPYING
|
||||||
%dir %{_libexecdir}/grubby
|
%dir %{_libexecdir}/grubby
|
||||||
%dir %{_libexecdir}/installkernel
|
%dir %{_libexecdir}/installkernel
|
||||||
@ -133,9 +130,82 @@ current boot environment.
|
|||||||
%attr(0755,root,root) %{_sbindir}/grubby
|
%attr(0755,root,root) %{_sbindir}/grubby
|
||||||
%attr(0755,root,root) %{_sbindir}/installkernel
|
%attr(0755,root,root) %{_sbindir}/installkernel
|
||||||
%attr(0755,root,root) %{_sbindir}/new-kernel-pkg
|
%attr(0755,root,root) %{_sbindir}/new-kernel-pkg
|
||||||
%{_mandir}/man8/*.8*
|
%{_mandir}/man8/*.8*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Aug 22 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-67
|
||||||
|
- Give up and just pull the config from BLS
|
||||||
|
- Suggested-by: Bojan Smojver <bojan@rexursive.com>
|
||||||
|
|
||||||
|
* Thu Aug 18 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-66
|
||||||
|
- Bring back -deprecated for fedora 36
|
||||||
|
|
||||||
|
* Wed Aug 17 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-65
|
||||||
|
- Mark package as obsoleting -deprecated
|
||||||
|
- Resolves: #2117817
|
||||||
|
|
||||||
|
* Tue Aug 02 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-64
|
||||||
|
- Handle updating /etc/kernel/cmdline
|
||||||
|
|
||||||
|
* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 8.40-63
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
|
||||||
|
|
||||||
|
* Tue Jul 19 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-62
|
||||||
|
- Clarify that grub files aren't used on s390x in man page
|
||||||
|
|
||||||
|
* Wed Jun 22 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-61
|
||||||
|
- Revert previous change
|
||||||
|
|
||||||
|
* Tue May 31 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-60
|
||||||
|
- Additionally write to /etc/kernel/cmdline
|
||||||
|
|
||||||
|
* Wed Apr 27 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-59
|
||||||
|
- Remove upstream and layers of indirection around -bls
|
||||||
|
|
||||||
|
* Thu Mar 10 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-58
|
||||||
|
- Remove grubby-deprecated
|
||||||
|
|
||||||
|
* Mon Feb 07 2022 Robbie Harwood <rharwood@redhat.com> - 8.40-57
|
||||||
|
- grubby-bls: wire up -h (help)
|
||||||
|
|
||||||
|
* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 8.40-56
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
|
||||||
|
|
||||||
|
* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 8.40-55
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
|
||||||
|
|
||||||
|
* Wed Jun 23 2021 Javier Martinez Canillas <javierm@redhat.com> - 8.40-54
|
||||||
|
- Clarify package description
|
||||||
|
Resolves: rhbz#1913299
|
||||||
|
- Update man page to not mention the GRUB config in the ESP anymore
|
||||||
|
Resolves: rhbz#1958458
|
||||||
|
|
||||||
|
* Wed Jun 09 2021 Javier Martinez Canillas <javierm@redhat.com> - 8.40-53
|
||||||
|
- grubby-bls: expand only the kernelopts variable
|
||||||
|
|
||||||
|
* Mon Apr 26 2021 Javier Martinez Canillas <javierm@redhat.com> - 8.40-52
|
||||||
|
- grubby-bs: Fix changing kernel cmdline params not working on ppc64le
|
||||||
|
|
||||||
|
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 8.40-51
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
|
||||||
|
|
||||||
|
* Wed Dec 30 2020 Tom Stellard <tstellar@redhat.com> - 8.40-50
|
||||||
|
- Use make_build macro instead of plain make
|
||||||
|
- https://docs.fedoraproject.org/en-US/packaging-guidelines/#_parallel_make
|
||||||
|
|
||||||
|
* Fri Nov 20 2020 Peter Robinson <pbrobinson@fedoraproject.org> - 8.40-49
|
||||||
|
- Add device tree kernel install option
|
||||||
|
|
||||||
|
* Mon Oct 26 2020 Josh Boyer <jwb@redhat.com> - 8.40-48
|
||||||
|
- Only require s390utils-core, not s390utils-base
|
||||||
|
|
||||||
|
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 8.40-47
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
|
||||||
|
|
||||||
|
* Fri Jun 26 2020 Javier Martinez Canillas <javierm@redhat.com> - 8.40-46
|
||||||
|
- fix build with rpm-4.16
|
||||||
|
- grubby-bls: fix --extra-initrd option not adding the correct path
|
||||||
|
|
||||||
* Wed May 13 2020 Javier Martinez Canillas <javierm@redhat.com> - 8.40-45
|
* Wed May 13 2020 Javier Martinez Canillas <javierm@redhat.com> - 8.40-45
|
||||||
- grubby-bls: don't replace options with kernelopts if values are the same
|
- grubby-bls: don't replace options with kernelopts if values are the same
|
||||||
|
|
||||||
|
356
rpm-sort.c
Normal file
356
rpm-sort.c
Normal file
@ -0,0 +1,356 @@
|
|||||||
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
|
#include <argp.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <rpm/rpmlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
RPMNVRCMP,
|
||||||
|
VERSNVRCMP,
|
||||||
|
RPMVERCMP,
|
||||||
|
STRVERSCMP,
|
||||||
|
} comparitors;
|
||||||
|
|
||||||
|
static comparitors comparitor = RPMNVRCMP;
|
||||||
|
|
||||||
|
static inline void *xmalloc(size_t sz)
|
||||||
|
{
|
||||||
|
void *ret = malloc(sz);
|
||||||
|
|
||||||
|
assert(sz == 0 || ret != NULL);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void *xrealloc(void *p, size_t sz)
|
||||||
|
{
|
||||||
|
void *ret = realloc(p, sz);
|
||||||
|
|
||||||
|
assert(sz == 0 || ret != NULL);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline char *xstrdup(const char * const s)
|
||||||
|
{
|
||||||
|
void *ret = strdup(s);
|
||||||
|
|
||||||
|
assert(s == NULL || ret != NULL);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
read_file (const char *input, char **ret)
|
||||||
|
{
|
||||||
|
FILE *in;
|
||||||
|
size_t s;
|
||||||
|
size_t sz = 2048;
|
||||||
|
size_t offset = 0;
|
||||||
|
char *text;
|
||||||
|
|
||||||
|
if (!strcmp(input, "-"))
|
||||||
|
in = stdin;
|
||||||
|
else
|
||||||
|
in = fopen(input, "r");
|
||||||
|
|
||||||
|
text = xmalloc (sz);
|
||||||
|
|
||||||
|
if (!in)
|
||||||
|
err(1, "cannot open `%s'", input);
|
||||||
|
|
||||||
|
while ((s = fread (text + offset, 1, sz - offset, in)) != 0)
|
||||||
|
{
|
||||||
|
offset += s;
|
||||||
|
if (sz - offset == 0)
|
||||||
|
{
|
||||||
|
sz += 2048;
|
||||||
|
text = xrealloc (text, sz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
text[offset] = '\0';
|
||||||
|
*ret = text;
|
||||||
|
|
||||||
|
if (in != stdin)
|
||||||
|
fclose(in);
|
||||||
|
|
||||||
|
return offset + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* returns name/version/release */
|
||||||
|
/* NULL string pointer returned if nothing found */
|
||||||
|
static void
|
||||||
|
split_package_string (char *package_string, char **name,
|
||||||
|
char **version, char **release)
|
||||||
|
{
|
||||||
|
char *package_version, *package_release;
|
||||||
|
|
||||||
|
/* Release */
|
||||||
|
package_release = strrchr (package_string, '-');
|
||||||
|
|
||||||
|
if (package_release != NULL)
|
||||||
|
*package_release++ = '\0';
|
||||||
|
|
||||||
|
*release = package_release;
|
||||||
|
|
||||||
|
/* Version */
|
||||||
|
package_version = strrchr(package_string, '-');
|
||||||
|
|
||||||
|
if (package_version != NULL)
|
||||||
|
*package_version++ = '\0';
|
||||||
|
|
||||||
|
*version = package_version;
|
||||||
|
/* Name */
|
||||||
|
*name = package_string;
|
||||||
|
|
||||||
|
/* Bubble up non-null values from release to name */
|
||||||
|
if (*name == NULL)
|
||||||
|
{
|
||||||
|
*name = (*version == NULL ? *release : *version);
|
||||||
|
*version = *release;
|
||||||
|
*release = NULL;
|
||||||
|
}
|
||||||
|
if (*version == NULL)
|
||||||
|
{
|
||||||
|
*version = *release;
|
||||||
|
*release = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
cmprpmversp(const void *p1, const void *p2)
|
||||||
|
{
|
||||||
|
return rpmvercmp(*(char * const *)p1, *(char * const *)p2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
cmpstrversp(const void *p1, const void *p2)
|
||||||
|
{
|
||||||
|
return strverscmp(*(char * const *)p1, *(char * const *)p2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* package name-version-release comparator for qsort
|
||||||
|
* expects p, q which are pointers to character strings (char *)
|
||||||
|
* which will not be altered in this function
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
package_version_compare (const void *p, const void *q)
|
||||||
|
{
|
||||||
|
char *local_p, *local_q;
|
||||||
|
char *lhs_name, *lhs_version, *lhs_release;
|
||||||
|
char *rhs_name, *rhs_version, *rhs_release;
|
||||||
|
int vercmpflag = 0;
|
||||||
|
int (*cmp)(const char *s1, const char *s2);
|
||||||
|
|
||||||
|
switch(comparitor)
|
||||||
|
{
|
||||||
|
default: /* just to shut up -Werror=maybe-uninitialized */
|
||||||
|
case RPMNVRCMP:
|
||||||
|
cmp = rpmvercmp;
|
||||||
|
break;
|
||||||
|
case VERSNVRCMP:
|
||||||
|
cmp = strverscmp;
|
||||||
|
break;
|
||||||
|
case RPMVERCMP:
|
||||||
|
return cmprpmversp(p, q);
|
||||||
|
break;
|
||||||
|
case STRVERSCMP:
|
||||||
|
return cmpstrversp(p, q);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
local_p = alloca (strlen (*(char * const *)p) + 1);
|
||||||
|
local_q = alloca (strlen (*(char * const *)q) + 1);
|
||||||
|
|
||||||
|
/* make sure these allocated */
|
||||||
|
assert (local_p);
|
||||||
|
assert (local_q);
|
||||||
|
|
||||||
|
strcpy (local_p, *(char * const *)p);
|
||||||
|
strcpy (local_q, *(char * const *)q);
|
||||||
|
|
||||||
|
split_package_string (local_p, &lhs_name, &lhs_version, &lhs_release);
|
||||||
|
split_package_string (local_q, &rhs_name, &rhs_version, &rhs_release);
|
||||||
|
|
||||||
|
/* Check Name and return if unequal */
|
||||||
|
vercmpflag = cmp ((lhs_name == NULL ? "" : lhs_name),
|
||||||
|
(rhs_name == NULL ? "" : rhs_name));
|
||||||
|
if (vercmpflag != 0)
|
||||||
|
return vercmpflag;
|
||||||
|
|
||||||
|
/* Check version and return if unequal */
|
||||||
|
vercmpflag = cmp ((lhs_version == NULL ? "" : lhs_version),
|
||||||
|
(rhs_version == NULL ? "" : rhs_version));
|
||||||
|
if (vercmpflag != 0)
|
||||||
|
return vercmpflag;
|
||||||
|
|
||||||
|
/* Check release and return the version compare value */
|
||||||
|
vercmpflag = cmp ((lhs_release == NULL ? "" : lhs_release),
|
||||||
|
(rhs_release == NULL ? "" : rhs_release));
|
||||||
|
|
||||||
|
return vercmpflag;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_input (const char *filename, char ***package_names, size_t *n_package_names)
|
||||||
|
{
|
||||||
|
char *orig_input_buffer = NULL;
|
||||||
|
char *input_buffer;
|
||||||
|
char *position_of_newline;
|
||||||
|
char **names = *package_names;
|
||||||
|
char **new_names = NULL;
|
||||||
|
size_t n_names = *n_package_names;
|
||||||
|
|
||||||
|
if (!*package_names)
|
||||||
|
new_names = names = xmalloc (sizeof (char *) * 2);
|
||||||
|
|
||||||
|
if (read_file (filename, &orig_input_buffer) < 2)
|
||||||
|
{
|
||||||
|
if (new_names)
|
||||||
|
free (new_names);
|
||||||
|
if (orig_input_buffer)
|
||||||
|
free (orig_input_buffer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
input_buffer = orig_input_buffer;
|
||||||
|
while (input_buffer && *input_buffer &&
|
||||||
|
(position_of_newline = strchrnul (input_buffer, '\n')))
|
||||||
|
{
|
||||||
|
size_t sz = position_of_newline - input_buffer;
|
||||||
|
char *new;
|
||||||
|
|
||||||
|
if (sz == 0)
|
||||||
|
{
|
||||||
|
input_buffer = position_of_newline + 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
new = xmalloc (sz+1);
|
||||||
|
strncpy (new, input_buffer, sz);
|
||||||
|
new[sz] = '\0';
|
||||||
|
|
||||||
|
names = xrealloc (names, sizeof (char *) * (n_names + 1));
|
||||||
|
names[n_names] = new;
|
||||||
|
n_names++;
|
||||||
|
|
||||||
|
/* move buffer ahead to next line */
|
||||||
|
input_buffer = position_of_newline + 1;
|
||||||
|
if (*position_of_newline == '\0')
|
||||||
|
input_buffer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
free (orig_input_buffer);
|
||||||
|
|
||||||
|
*package_names = names;
|
||||||
|
*n_package_names = n_names;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
help_filter (int key, const char *text, void *input __attribute__ ((unused)))
|
||||||
|
{
|
||||||
|
return (char *)text;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct argp_option options[] = {
|
||||||
|
{ "comparitor", 'c', "COMPARITOR", 0, "[rpm-nvr-cmp|vers-nvr-cmp|rpmvercmp|strverscmp]", 0},
|
||||||
|
{ 0, }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct arguments
|
||||||
|
{
|
||||||
|
size_t ninputs;
|
||||||
|
size_t input_max;
|
||||||
|
char **inputs;
|
||||||
|
};
|
||||||
|
|
||||||
|
static error_t
|
||||||
|
argp_parser (int key, char *arg, struct argp_state *state)
|
||||||
|
{
|
||||||
|
struct arguments *arguments = state->input;
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case 'c':
|
||||||
|
if (!strcmp(arg, "rpm-nvr-cmp") || !strcmp(arg, "rpmnvrcmp"))
|
||||||
|
comparitor = RPMNVRCMP;
|
||||||
|
else if (!strcmp(arg, "vers-nvr-cmp") || !strcmp(arg, "versnvrcmp"))
|
||||||
|
comparitor = VERSNVRCMP;
|
||||||
|
else if (!strcmp(arg, "rpmvercmp"))
|
||||||
|
comparitor = RPMVERCMP;
|
||||||
|
else if (!strcmp(arg, "strverscmp"))
|
||||||
|
comparitor = STRVERSCMP;
|
||||||
|
else
|
||||||
|
err(1, "Invalid comparitor \"%s\"", arg);
|
||||||
|
break;
|
||||||
|
case ARGP_KEY_ARG:
|
||||||
|
assert (arguments->ninputs < arguments->input_max);
|
||||||
|
arguments->inputs[arguments->ninputs++] = xstrdup (arg);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return ARGP_ERR_UNKNOWN;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct argp argp = {
|
||||||
|
options, argp_parser, "[INPUT_FILES]",
|
||||||
|
"Sort a list of strings in RPM version sort order.",
|
||||||
|
NULL, help_filter, NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char *argv[])
|
||||||
|
{
|
||||||
|
struct arguments arguments;
|
||||||
|
char **package_names = NULL;
|
||||||
|
size_t n_package_names = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
memset (&arguments, 0, sizeof (struct arguments));
|
||||||
|
arguments.input_max = argc+1;
|
||||||
|
arguments.inputs = xmalloc ((arguments.input_max + 1)
|
||||||
|
* sizeof (arguments.inputs[0]));
|
||||||
|
memset (arguments.inputs, 0, (arguments.input_max + 1)
|
||||||
|
* sizeof (arguments.inputs[0]));
|
||||||
|
|
||||||
|
/* Parse our arguments */
|
||||||
|
if (argp_parse (&argp, argc, argv, 0, 0, &arguments) != 0)
|
||||||
|
errx(1, "%s", "Error in parsing command line arguments\n");
|
||||||
|
|
||||||
|
/* If there's no inputs in argv, add one for stdin */
|
||||||
|
if (!arguments.ninputs)
|
||||||
|
{
|
||||||
|
arguments.ninputs = 1;
|
||||||
|
arguments.inputs[0] = xmalloc (2);
|
||||||
|
strcpy(arguments.inputs[0], "-");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < arguments.ninputs; i++)
|
||||||
|
add_input(arguments.inputs[i], &package_names, &n_package_names);
|
||||||
|
|
||||||
|
if (package_names == NULL || n_package_names < 1)
|
||||||
|
errx(1, "Invalid input");
|
||||||
|
|
||||||
|
qsort (package_names, n_package_names, sizeof (char *),
|
||||||
|
package_version_compare);
|
||||||
|
|
||||||
|
/* send sorted list to stdout */
|
||||||
|
for (i = 0; i < n_package_names; i++)
|
||||||
|
{
|
||||||
|
fprintf (stdout, "%s\n", package_names[i]);
|
||||||
|
free (package_names[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
free (package_names);
|
||||||
|
for (i = 0; i < arguments.ninputs; i++)
|
||||||
|
free (arguments.inputs[i]);
|
||||||
|
|
||||||
|
free (arguments.inputs);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user