From 70a4e19377784e511f1b45bda1df14ecd377ec89 Mon Sep 17 00:00:00 2001 From: travankor Date: Sat, 13 Mar 2021 07:51:37 -0700 Subject: [PATCH] New package: booster-0.4 --- srcpkgs/booster/files/kernel-hook-postinst | 15 +++++++ srcpkgs/booster/files/kernel-hook-postrm | 11 +++++ srcpkgs/booster/patches/builtin.patch | 27 ++++++++++++ srcpkgs/booster/patches/modprobe.patch | 48 ++++++++++++++++++++++ srcpkgs/booster/template | 41 ++++++++++++++++++ 5 files changed, 142 insertions(+) create mode 100644 srcpkgs/booster/files/kernel-hook-postinst create mode 100644 srcpkgs/booster/files/kernel-hook-postrm create mode 100644 srcpkgs/booster/patches/builtin.patch create mode 100644 srcpkgs/booster/patches/modprobe.patch create mode 100644 srcpkgs/booster/template diff --git a/srcpkgs/booster/files/kernel-hook-postinst b/srcpkgs/booster/files/kernel-hook-postinst new file mode 100644 index 000000000000..68d2eaf6caf6 --- /dev/null +++ b/srcpkgs/booster/files/kernel-hook-postinst @@ -0,0 +1,15 @@ +#!/bin/sh +# +# Kernel post-install hook for booster. +# +# Arguments passed to this script: $1 pkgname, $2 version. +# +PKGNAME="$1" +VERSION="$2" + +if [ ! -x usr/bin/booster ]; then + exit 0 +fi + +usr/bin/booster -force -output boot/initramfs-${VERSION}.img -kernelVersion ${VERSION} +exit $? diff --git a/srcpkgs/booster/files/kernel-hook-postrm b/srcpkgs/booster/files/kernel-hook-postrm new file mode 100644 index 000000000000..ef13d1967a67 --- /dev/null +++ b/srcpkgs/booster/files/kernel-hook-postrm @@ -0,0 +1,11 @@ +#!/bin/sh +# +# Kernel post-remove hook for booster. +# +# Arguments passed to this script: $1 pkgname, $2 version. +# +PKGNAME="$1" +VERSION="$2" + +rm -f boot/initramfs-${VERSION}.img +exit $? diff --git a/srcpkgs/booster/patches/builtin.patch b/srcpkgs/booster/patches/builtin.patch new file mode 100644 index 000000000000..752b613a4dab --- /dev/null +++ b/srcpkgs/booster/patches/builtin.patch @@ -0,0 +1,27 @@ +From e85ea7386f456afaa4f646e21c3407e39bb61bb4 Mon Sep 17 00:00:00 2001 +From: Anatol Pomozov +Date: Sat, 24 Apr 2021 23:16:55 -0700 +Subject: [PATCH] Do not append a builtin module to extraDependencies list + +Closes #81 +--- + generator/kmod.go | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/generator/kmod.go b/generator/kmod.go +index 4cc2c50..c548ee2 100644 +--- a/generator/kmod.go ++++ b/generator/kmod.go +@@ -682,7 +682,11 @@ func readHostModules() (set, error) { + } + + func (k *Kmod) addExtraDep(mod string, deps ...string) { +- k.extraDep[mod] = append(k.extraDep[mod], deps...) ++ for _, dep := range deps { ++ if !k.builtinModules[dep] { ++ k.extraDep[mod] = append(k.extraDep[mod], dep) ++ } ++ } + } + + func (k *Kmod) forceLoad(mods ...string) { diff --git a/srcpkgs/booster/patches/modprobe.patch b/srcpkgs/booster/patches/modprobe.patch new file mode 100644 index 000000000000..9ffb47a3ecd7 --- /dev/null +++ b/srcpkgs/booster/patches/modprobe.patch @@ -0,0 +1,48 @@ +From 68646929c4ff7e144182564fea4272cb3b94cff6 Mon Sep 17 00:00:00 2001 +From: Anatol Pomazau +Date: Sun, 11 Apr 2021 09:45:56 -0700 +Subject: [PATCH] modprobe parser needs to handle lines that contain only + whitespaces + +Closes #78 +--- + generator/kmod.go | 3 +-- + generator/kmod_test.go | 4 ++++ + 2 files changed, 5 insertions(+), 2 deletions(-) + +diff --git a/generator/kmod.go b/generator/kmod.go +index 88df50c..4cc2c50 100644 +--- a/generator/kmod.go ++++ b/generator/kmod.go +@@ -719,6 +719,7 @@ func parseModprobe(content string, options map[string][]string) error { + ) + for s.Scan() { + line := s.Text() ++ line = strings.TrimSpace(line) + if len(line) == 0 || line[0] == '#' { + if multiLine { + return fmt.Errorf("multiline directive contains an empty or comment line") +@@ -726,8 +727,6 @@ func parseModprobe(content string, options map[string][]string) error { + continue + } + +- line = strings.TrimSpace(line) +- + if line[len(line)-1] == '\\' { + multiLine = true + b.WriteString(line[:len(line)-1]) +diff --git a/generator/kmod_test.go b/generator/kmod_test.go +index aa48b48..8b61dba 100644 +--- a/generator/kmod_test.go ++++ b/generator/kmod_test.go +@@ -184,6 +184,10 @@ func TestParseModprobe(t *testing.T) { + map[string][]string{ + "btusb": {"reset=1"}, + }) ++ check("# use \"reset=1\" as default, since it should be safe for recent devices and\n \t \n# solves all kind of problems.\noptions btusb reset=1", ++ map[string][]string{ ++ "btusb": {"reset=1"}, ++ }) + check("install libnvdimm /usr/bin/ndctl load-keys ; /sbin/modprobe --ignore-install libnvdimm $CMDLINE_OPTS\n", map[string][]string{}) + check("# When bonding module is loaded, it creates bond0 by default due to max_bonds\n# option default value 1. This interferes with the network configuration\n# management / networkd, as it is not possible to detect whether this bond0 was\n# intentionally configured by the user, or should be managed by\n# networkd/NM/etc. Therefore disable bond0 creation.\n\noptions bonding max_bonds=0\n\n# Do the same for dummy0.\n\noptions dummy numdummies=0\n", + map[string][]string{ diff --git a/srcpkgs/booster/template b/srcpkgs/booster/template new file mode 100644 index 000000000000..19e042dae2fa --- /dev/null +++ b/srcpkgs/booster/template @@ -0,0 +1,41 @@ +# Template file for 'booster' +pkgname=booster +version=0.4 +revision=2 +build_style=go +go_import_path=github.com/anatol/booster +go_package="${go_import_path}/generator ${go_import_path}/init" +hostmakedepends="git ruby-ronn" +depends="busybox-static" +short_desc="Fast and secure initramfs generator" +maintainer="travankor " +license="MIT" +homepage="https://github.com/anatol/booster" +distfiles="https://github.com/anatol/booster/archive/${version}.tar.gz" +checksum=440def00073a35d012f9b65a4e560d5f81bec279516104dab173b40a5310da27 +conf_files="/etc/booster.yaml" +patch_args="-Np1" + +pre_build() { + export CGO_ENABLED=0 +} + +do_install() { + if [ "$CROSS_BUILD" ]; then + vbin ${GOPATH}/bin/linux_${GOARCH}/generator booster + vinstall ${GOPATH}/bin/linux_${GOARCH}/init 755 usr/lib/booster + else + vbin ${GOPATH}/bin/generator booster + vinstall ${GOPATH}/bin/init 755 usr/lib/booster + fi + ronn docs/manpage.md + vman docs/manpage.1 booster.1 + echo "busybox: true" > boster.yaml +} + +post_install() { + vconf booster.yaml + vinstall ${FILESDIR}/kernel-hook-postinst 755 etc/kernel.d/post-install 20-booster + vinstall ${FILESDIR}/kernel-hook-postrm 755 etc/kernel.d/post-remove 20-booster + vlicense LICENSE +}