commit:     3d23af3d4a02c676702cf6d8ddc36a9317320ea8
Author:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 15 20:36:29 2020 +0000
Commit:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Sat Feb 15 20:38:11 2020 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=3d23af3d

Add b2sum

b2sum can be used to verify (boot) media since
commit 5c55dd467a563623f16be27f670b5a3ddc79fb02.

Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>

 doc/genkernel.8.txt        |  4 +++
 gen_cmdline.sh             |  6 +++++
 gen_determineargs.sh       |  1 +
 gen_initramfs.sh           | 31 +++++++++++++++++++++-
 genkernel.conf             |  3 +++
 gkbuilds/coreutils.gkbuild | 66 ++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 110 insertions(+), 1 deletion(-)

diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt
index 6c7b9bd..e00e028 100644
--- a/doc/genkernel.8.txt
+++ b/doc/genkernel.8.txt
@@ -430,6 +430,10 @@ system is able to load multiple initramfs.
     `gpg --symmetric -o /path/to/LUKS-key.gpg /path/to/LUKS-key` .
     After that, re-point the *root_key* argument to the new .gpg file.
 
+*--*[*no-*]*b2sum*::
+    Includes or excludes b2sum in the initramfs.
+    When enabled, this will compile coreutils' b2sum for you.
+
 *--*[*no-*]*busybox*::
     Includes or excludes busybox in the initramfs.
     When enabled, this will compile busybox for you.

diff --git a/gen_cmdline.sh b/gen_cmdline.sh
index c0139d4..aa54c29 100755
--- a/gen_cmdline.sh
+++ b/gen_cmdline.sh
@@ -168,6 +168,8 @@ longusage() {
   echo "       --no-luks               Exclude LUKS support"
   echo "       --gpg                   Include GPG-armored LUKS key support"
   echo "       --no-gpg                Exclude GPG-armored LUKS key support"
+  echo "       --b2sum                 Include b2sum"
+  echo "       --no-b2sum              Exclude b2sum"
   echo "       --busybox               Include busybox"
   echo "       --no-busybox            Exclude busybox"
   echo "       --unionfs               Include support for unionfs"
@@ -383,6 +385,10 @@ parse_cmdline() {
                        CMD_MDADM_CONFIG="${*#*=}"
                        print_info 3 "CMD_MDADM_CONFIG: ${CMD_MDADM_CONFIG}"
                        ;;
+               --b2sum|--no-b2sum)
+                       CMD_B2SUM=$(parse_optbool "$*")
+                       print_info 3 "CMD_B2SUM: ${CMD_B2SUM}"
+                       ;;
                --busybox|--no-busybox)
                        CMD_BUSYBOX=$(parse_optbool "$*")
                        print_info 3 "CMD_BUSYBOX: ${CMD_BUSYBOX}"

diff --git a/gen_determineargs.sh b/gen_determineargs.sh
index fffb3e9..14ef757 100755
--- a/gen_determineargs.sh
+++ b/gen_determineargs.sh
@@ -340,6 +340,7 @@ determine_real_args() {
        set_config_with_override BOOL   HYPERV                                
CMD_HYPERV                                "no"
        set_config_with_override STRING BOOTFONT                              
CMD_BOOTFONT                              "none"
        set_config_with_override STRING BOOTLOADER                            
CMD_BOOTLOADER                            "no"
+       set_config_with_override BOOL   B2SUM                                 
CMD_B2SUM                                 "no"
        set_config_with_override BOOL   BUSYBOX                               
CMD_BUSYBOX                               "yes"
        set_config_with_override STRING BUSYBOX_CONFIG                        
CMD_BUSYBOX_CONFIG
        set_config_with_override BOOL   NFS                                   
CMD_NFS                                   "yes"

diff --git a/gen_initramfs.sh b/gen_initramfs.sh
index 2ad4e64..d055b24 100755
--- a/gen_initramfs.sh
+++ b/gen_initramfs.sh
@@ -363,6 +363,7 @@ append_base_layout() {
        isTrue "${MICROCODE_INITRAMFS}" && build_parameters+=( 
--microcode-initramfs ) || build_parameters+=( --no-microcode-initramfs )
        isTrue "${RAMDISKMODULES}" && build_parameters+=( --ramdisk-modules ) 
|| build_parameters+=( --no-ramdisk-modules )
        isTrue "${BUSYBOX}" && build_parameters+=( --busybox ) || 
build_parameters+=( --no-busybox )
+       isTrue "${B2SUM}" && build_parameters+=( --b2sum ) || 
build_parameters+=( --no-b2sum )
        isTrue "${DISKLABEL}" && build_parameters+=( --disklabel ) || 
build_parameters+=( --no-disklabel )
        isTrue "${BTRFS}" && build_parameters+=( --btrfs ) || 
build_parameters+=( --no-btrfs )
        isTrue "${ISCSI}" && build_parameters+=( --iscsi ) || 
build_parameters+=( --no-iscsi )
@@ -504,6 +505,33 @@ append_e2fsprogs() {
        fi
 }
 
+append_b2sum() {
+       local PN="coreutils"
+       local TDIR="${TEMP}/initramfs-b2sum-temp"
+       if [ -d "${TDIR}" ]
+       then
+               rm -r "${TDIR}" || gen_die "Failed to clean out existing 
'${TDIR}'!"
+       fi
+
+       populate_binpkg ${PN}
+
+       mkdir -p "${TDIR}" || gen_die "Failed to create '${TDIR}'!"
+
+       unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}"
+
+       cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
+
+       log_future_cpio_content
+       find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F 
"${CPIO_ARCHIVE}" \
+               || gen_die "Failed to append b2sum to cpio!"
+
+       cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+       if isTrue "${CLEANUP}"
+       then
+               rm -rf "${TDIR}"
+       fi
+}
+
 append_blkid() {
        local PN="util-linux"
        local TDIR="${TEMP}/initramfs-blkid-temp"
@@ -1742,9 +1770,10 @@ create_initramfs() {
        append_data 'devices' # WARNING, must be first!
        append_data 'base_layout'
        append_data 'auxilary' "${BUSYBOX}"
+       append_data 'busybox' "${BUSYBOX}"
        append_data 'blkid' "${DISKLABEL}"
+       append_data 'b2sum' "${B2SUM}"
        append_data 'btrfs' "${BTRFS}"
-       append_data 'busybox' "${BUSYBOX}"
        append_data 'dmraid' "${DMRAID}"
        append_data 'dropbear' "${SSH}"
        append_data 'e2fsprogs' "${E2FSPROGS}"

diff --git a/genkernel.conf b/genkernel.conf
index c5d7052..43415ef 100644
--- a/genkernel.conf
+++ b/genkernel.conf
@@ -100,6 +100,9 @@ NOCOLOR="false"
 # Add SSH support
 #SSH="no"
 
+# Add b2sum support
+#B2SUM="no"
+
 # Include busybox in the initramfs. If included, busybox is rebuilt
 # if the cached copy is out of date.
 #BUSYBOX="yes"

diff --git a/gkbuilds/coreutils.gkbuild b/gkbuilds/coreutils.gkbuild
new file mode 100644
index 0000000..f320d63
--- /dev/null
+++ b/gkbuilds/coreutils.gkbuild
@@ -0,0 +1,66 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+src_prepare() {
+       default
+
+       # Since we've patched many .c files, the make process will try to
+       # re-build the manpages by running `./bin --help`.  When doing a
+       # cross-compile, we can't do that since 'bin' isn't a native bin.
+       # Also, it's not like we changed the usage on any of these things,
+       # so let's just update the timestamps and skip the help2man step.
+       set -- man/*.x
+       touch ${@/%x/1}
+
+       # Avoid perl dep for compiled in dircolors default #348642
+       touch src/dircolors.h
+       touch ${@/%x/1}
+}
+
+src_configure() {
+       append-ldflags -static
+
+       # configure doesn't like our TMPDIR and would try to write to
+       # /usr instead which would trigger sandbox
+       export ac_cv_sys_long_file_names=yes
+
+       export gl_cv_func_mknod_works=yes #409919
+
+       # no selinux
+       export 
ac_cv_{header_selinux_{context,flash,selinux}_h,search_setfilecon}=no
+
+       if tc-is-cross-compiler
+       then
+               export fu_cv_sys_stat_statfs2_bsize=yes #311569
+               export gl_cv_func_realpath_works=yes #416629
+               export gl_cv_func_working_mktime=yes
+       fi
+
+       local myconf=(
+               --with-packager="genkernel"
+               --enable-largefile
+               --disable-libcap
+               --disable-nls
+               --disable-acl
+               --disable-xattr
+               --without-gmp
+               
--enable-no-install-program="stdbuf,groups,hostname,kill,su,uptime"
+       )
+
+       gkconf "${myconf[@]}"
+}
+
+src_install() {
+       local MYMAKEOPTS=( "V=1" )
+       MYMAKEOPTS+=( "DESTDIR=${D}" )
+       MYMAKEOPTS+=( "install" )
+       gkmake "${MYMAKEOPTS[@]}"
+
+       # We are only interested in b2sum
+       find "${D}" -type f -not -name 'b2sum' -print0 | xargs --null -I {} rm 
{}
+
+       rm -rf "${D}"/usr/share || die "Failed to remove '${D}/usr/share'!"
+
+       "${STRIP}" --strip-all "${D}"/usr/bin/b2sum \
+               || die "Failed to strip '${D}/usr/bin/b2sum'!"
+}

Reply via email to