Linux kbuild/kconfig development
 help / color / mirror / Atom feed
* [PATCH] usr/gen_initramfs.sh: (cosmetic) improve comments and formatting
@ 2025-11-05 18:06 Jack Grube
  2025-11-05 18:27 ` Grube, Jack
  0 siblings, 1 reply; 3+ messages in thread
From: Jack Grube @ 2025-11-05 18:06 UTC (permalink / raw)
  To: linux-kbuild@vger.kernel.org

This patch rewrites comments to be more descriptive and as complete sentences;
it also tweaks the usage function's output is also adjusted to make it more readable
when using the -h flag.
I ran the script with the -h option to verify that the usage output remains correct,
but no other testing was performed as no core logic was changed.
Lastly, I added an SPDX license identifier for any tools that may depend on that.
I welcome feedback there are any areas for improvement.


diff --git a/usr/gen_initramfs.sh b/usr/gen_initramfs.sh
index 4490d496f374..7eba2fddf0ef 100755
--- a/usr/gen_initramfs.sh
+++ b/usr/gen_initramfs.sh
@@ -1,8 +1,8 @@
 #!/bin/sh
-# SPDX-License-Identifier: GPL-2.0-or-later
 # Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org>
 # Copyright (C) 2006 Sam Ravnborg <sam@ravnborg.org>
-# Released under the terms of the GNU GPL.
+#
+# Released under the terms of the GNU GPL
 #
 # Generate a cpio packed initramfs. It uses gen_init_cpio to generate
 # the cpio archive.
@@ -18,15 +18,15 @@ $0 [-o <file>] [-l <dep_list>] [-u <uid>] [-g <gid>] {-d | <cpio_source>} ...
      -o <file>      Create initramfs file named <file> by using gen_init_cpio
      -l <dep_list>  Create dependency list named <dep_list>
      -u <uid>       User ID to map to user ID 0 (root).
-                    <uid> is only meaningful if <cpio_source> is a
-                    directory.  "squash" forces all files to uid 0.
+                  <uid> is only meaningful if <cpio_source> is a
+                  directory.  "squash" forces all files to uid 0.
      -g <gid>       Group ID to map to group ID 0 (root).
-                    <gid> is only meaningful if <cpio_source> is a
-                    directory.  "squash" forces all files to gid 0.
+                  <gid> is only meaningful if <cpio_source> is a
+                  directory.  "squash" forces all files to gid 0.
      -d <date>      Use date for all file mtime values
      <cpio_source>  File list or directory for cpio archive.
-                    If <cpio_source> is a .cpio file it will be used
-                    as direct input to initramfs.
+                  If <cpio_source> is a .cpio file it will be used
+                  as direct input to initramfs.
 
 All options except -o and -l may be repeated and are interpreted
 sequentially and immediately.  -u and -g states are preserved across
@@ -35,9 +35,8 @@ to reset the root/group mapping.
 EOF
 }
 
-
 # awk style field access
-# $1 -- field number; the rest is the argument string.
+# $1 - field number; rest is argument string
 field() {
      shift $1 ; echo $1
 }
@@ -45,7 +44,7 @@ field() {
 filetype() {
      local argv1="$1"
 
-     # The symlink test must come before the file test.
+     # symlink test must come before file test
      if [ -L "${argv1}" ]; then
            echo "slink"
      elif [ -f "${argv1}" ]; then
@@ -82,9 +81,9 @@ list_parse() {
      echo "$1" | sed 's/:/\\:/g; s/$/ \\/' >> $dep_list
 }
 
-# For each file, print a line in following format:
+# for each file print a line in following format
 # <filetype> <name> <path to file> <octal mode> <uid> <gid>
-# For links, devices, etc., the format differs. See gen_init_cpio for details.
+# for links, devices etc the format differs. See gen_init_cpio for details
 parse() {
      local location="$1"
      local name="/${location#${srcdir}}"
@@ -144,14 +143,14 @@ header() {
      printf "\n#####################\n# $1\n" >> $cpio_list
 }
 
-# Process one directory (including sub-directories).
+# process one directory (incl sub-directories)
 dir_filelist() {
      header "$1"
 
      srcdir=$(echo "$1" | sed -e 's://*:/:g')
      dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" | LC_ALL=C sort)
 
-     # If $dirlist is only one line, then the directory is empty.
+     # If $dirlist is only one line, then the directory is empty
      if [  "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then
            print_mtime "$1"
 
@@ -180,7 +179,7 @@ input_file() {
                  done
            fi
      elif [ -d "$1" ]; then
-           # If a directory is specified, then add all files in it to the file system.
+           # If a directory is specified then add all files in it to fs
            dir_filelist "$1"
      else
            echo "  ${prog}: Cannot open '$1'" >&2
@@ -203,26 +202,26 @@ while [ $# -gt 0 ]; do
      arg="$1"
      shift
      case "$arg" in
-           "-l") # files included in initramfs--used by kbuild
+           "-l") # files included in initramfs - used by kbuild
                  dep_list="$1"
                  echo "deps_initramfs := \\" > $dep_list
                  shift
                  ;;
-           "-o") # Generate a cpio image named $1.
+           "-o") # generate cpio image named $1
                  output="-o $1"
                  shift
                  ;;
-           "-u") # Map $1 to uid=0 (root).
+           "-u") # map $1 to uid=0 (root)
                  root_uid="$1"
                  [ "$root_uid" = "-1" ] && root_uid=$(id -u || echo 0)
                  shift
                  ;;
-           "-g") # Map $1 to gid=0 (root).
+           "-g") # map $1 to gid=0 (root)
                  root_gid="$1"
                  [ "$root_gid" = "-1" ] && root_gid=$(id -g || echo 0)
                  shift
                  ;;
-           "-d") # Date for file mtimes
+           "-d") # date for file mtimes
                  timestamp="$(date -d"$1" +%s || :)"
                  if test -n "$timestamp"; then
                        timestamp="-t $timestamp"
@@ -238,7 +237,7 @@ while [ $# -gt 0 ]; do
                        "-"*)
                              unknown_option
                              ;;
-                       *)    # input file/dir -- process it
+                       *)    # input file/dir - process it
                              input_file "$arg"
                              ;;
                  esac
@@ -246,6 +245,6 @@ while [ $# -gt 0 ]; do
      esac
 done
 
-# If the output_file is set, we will generate cpio archive.
-# We are careful to delete tmp files.
+# If output_file is set we will generate cpio archive
+# we are careful to delete tmp files
 usr/gen_init_cpio $output $timestamp $cpio_list


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-12-09 13:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-05 18:06 [PATCH] usr/gen_initramfs.sh: (cosmetic) improve comments and formatting Jack Grube
2025-11-05 18:27 ` Grube, Jack
2025-12-09 13:07   ` Nicolas Schier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox