]> Frank Brehm's Git Trees - my-stuff/storcli.git/commitdiff
Added mangle-changelog.sh for transforming the original changelog from LSI into a...
authorFrank Brehm <frank.brehm@profitbricks.com>
Wed, 20 May 2015 10:03:54 +0000 (12:03 +0200)
committerFrank Brehm <frank.brehm@profitbricks.com>
Wed, 20 May 2015 10:03:54 +0000 (12:03 +0200)
mangle-changelog.sh [new file with mode: 0755]

diff --git a/mangle-changelog.sh b/mangle-changelog.sh
new file mode 100755 (executable)
index 0000000..07f8e90
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+
+set -e
+set -u
+
+CUR_DIR=$( dirname $0 )
+
+if [[ "$#" -ne "1" ]] ; then
+    cat >&2 <<EOF
+Usage:
+$0 ORIG_CHANGELOG
+
+EOF
+    exit 1
+fi
+
+ORIG="${1}"
+if [[ ! -f "${ORIG}" ]] ; then
+    echo "File '${ORIG}' does not exists." >&2
+    exit 1
+fi
+
+TEMP_FILE=$(mktemp tmp.changelog.XXXXXXXXXX.txt)
+
+cleanup() {
+    if [[ -f "${TEMP_FILE}" ]] ; then
+        rm -v "${TEMP_FILE}"
+    fi
+}
+
+trap "cleanup; echo 'Exception while running $0'; exit 5" INT TERM EXIT
+
+iconv -f windows-1252 -t utf-8 "${ORIG}" > "${TEMP_FILE}"
+dos2unix "${TEMP_FILE}"
+sed -i -e 's/[         ][      ]*$//' "${TEMP_FILE}"
+
+mv -vi "${TEMP_FILE}" "${CUR_DIR}/changelog.txt" </dev/null
+
+trap - INT TERM EXIT
+cleanup
+
+
+# vim: ts=4 et
+