Thanks for you comments; there is a branch Bradley Kuhn started where
I will integrate your changes for a subsequent patch.  Anyone
who has an interest in this is welcome to contribute to it.

-i

[1] https://www.gitorious.org/busybox/busybox

On 10/21/2012 07:43 PM, Mike Frysinger wrote:
On Wednesday 19 September 2012 18:16:11 Ian Wienand wrote:
--- /dev/null
+++ b/scripts/create-spdx
@@ -0,0 +1,91 @@
+#!/bin/bash

considering this is also POSIX compliant, use /bin/sh

+#  http://www.spdx.org/

would be handy to include this URL in the usage output

+BUSYBOX_VERSION=$(egrep '^VERSION =|^PATCHLEVEL =|^SUBLEVEL ='
"${SRC_DIR}/Makefile" | sed 's/^.*= //' | tr '\n' '.')

why not make this an argument to the script and have the makefile pass it along
via $(KERNELVERSION) ?  seems like much less effort.

+cp "${SRC_DIR}/scripts/COPYRIGHT.spdx.template" "${DEST_FILE}"

probably should run `set -e` at the top of the script to avoid having to add
error checking everywhere

+# replace template strings
+sed "s/%BUSYBOX_VERSION%/${BUSYBOX_VERSION}/" "${DEST_FILE}">
"${DEST_FILE}.tmp"
+mv "${DEST_FILE}.tmp" "${DEST_FILE}"

use the -i flag with sed to avoid this ugly `sed ...>  tmp; mv tmp ...` logic

+echo -e "\n\n# autogenerated file info\n\n">>  "${DEST_FILE}"

use printf rather than `echo -e`.  also, i wonder why you bother quoting the
dest file when you don't bother quoting any of the source files.

+    copyright=$(grep 'Copyright' ${f} | sed 's/^.*Copyright/Copyright/')

single command:
        sed -n '/Copyright/s:^.*Copyright:Copyright:p' ${f}

+    echo "FileName: ${f#$SRC_DIR}">>  "${DEST_FILE}"
+    echo "FileType: SOURCE">>  "${DEST_FILE}"
+    echo "FileChecksum: SHA1: ${chksum}">>  "${DEST_FILE}"
+    echo "LicenseConcluded: GPL-2.0">>  "${DEST_FILE}"
+    echo "LicenseInfoInFile: NOASSERTION">>  "${DEST_FILE}"

use heredocs to simplify:
        cat<<-EOF>>  "${DEST_FILE}"
        FileName: ......
        .....
        EOF

+VER_FILE=$(tempfile)

use mktemp

+grep '^FileChecksum' "${DEST_FILE}" | awk '{print $3}' | sort | tr -d '\n'

no need to grep|awk:
        awk '$1 ~ /^FileChecksum' {print $3} "${DEST_FILE}" | sort ...

"${VER_FILE}"
+VER_HASH=$(sha1sum "${VER_FILE}" | awk '{print $1}')
+rm -f "${VER_FILE}"

so you create a tempfile just to run sha1 on it ?  use a pipeline and avoid
that altogether:
VER_HASH=$(awk ... | sort | tr ... | sha1sum | awk ...)

+sed "s/%PACKAGE_VERIFICATION_CODE%/${VER_HASH}/" "${DEST_FILE}">
"${DEST_FILE}.tmp"
+mv "${DEST_FILE}.tmp" "${DEST_FILE}"

sed -i
-mike

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to