From e83bfcb9d5ae6da7e668fe7ae7f0046fc78ec5f1 Mon Sep 17 00:00:00 2001
From: Mario Fetka <mario@localhost.localdomain>
Date: Fri, 10 Nov 2017 18:08:35 +0100
Subject: [PATCH] move

---
 build_orig.sh | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++
 files.diz     |  2 ++
 2 files changed, 87 insertions(+)
 create mode 100644 build_orig.sh
 create mode 100644 files.diz

diff --git a/build_orig.sh b/build_orig.sh
new file mode 100644
index 0000000..bc5ab97
--- /dev/null
+++ b/build_orig.sh
@@ -0,0 +1,85 @@
+#!/bin/bash
+# the directory of the script
+DIR=`cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd`
+echo "Working directory $DIR"
+
+# the temp directory used, within $DIR
+WORK_DIR=`mktemp -d -p "$DIR"`
+echo "Creating temp working directory $WORK_DIR"
+
+# deletes the temp directory
+function cleanup {
+  rm -rf "$WORK_DIR"
+  echo "Deleted temp working directory $WORK_DIR"
+}
+
+# register the cleanup function to be called on the EXIT signal
+trap cleanup EXIT
+
+# Download Files specified in files.diz
+while IFS=! read type app version outputfile url md5
+do
+  echo "Downloading $app Version: $version"
+  #use -O for output file. define $outputfile yourself
+  wget -c --no-check-certificate --tries=1 -O $DIR/../$outputfile --timeout=5 "$url"
+  # use $(..) instead of backticks.
+  calculated_md5=$(md5sum "$DIR/../$outputfile" | cut -f 1 -d " ")
+  # compare md5
+  case "$calculated_md5" in
+    "$md5" )
+      echo "$DIR/../$outputfile md5 ok"
+    ;;
+    *)
+      echo "$DIR/../$outputfile md5 NOT ok"
+      exit 1
+    ;;
+  esac
+done < "$DIR/files.diz"
+
+# Extract to specified dir and set some variables
+while IFS=! read type app version outputfile url md5
+do
+  mkdir -p $WORK_DIR/${type}
+  pushd $WORK_DIR/${type}
+  unzip $DIR/../$outputfile
+  tar -zxf *.tgz
+  popd
+  mkdir -p $WORK_DIR/${app}-${version}/${type}
+  dos2unix $WORK_DIR/${type}/*.txt
+  mv $WORK_DIR/${type}/*.txt $WORK_DIR/${app}-${version}
+  mv $WORK_DIR/${type}/3dm2* $WORK_DIR/${app}-${version}/${type}
+  pushd $WORK_DIR/${app}-${version}/${type}
+  case "${type}" in
+    "amd64" )
+      rm -f *.x86
+    ;;
+    "i386" )
+      rm -f *.x86_64
+    ;;
+    *)
+      echo "Wrong arch"
+      exit 1
+    ;;
+  esac
+  echo "${app}_${version}.orig.tar.gz" > $WORK_DIR/filename.txt
+  echo "${app}-${version}" > $WORK_DIR/dirname.txt
+  echo "${version}" > $WORK_DIR/version.txt
+  popd
+done < "$DIR/files.diz"
+
+FILENAME=`cat $WORK_DIR/filename.txt`
+DIRNAME=`cat $WORK_DIR/dirname.txt`
+echo "Creating $DIR/../$FILENAME "
+
+pushd $WORK_DIR
+tar -czf $DIR/../$FILENAME $DIRNAME
+popd
+
+#exit 1
+
+VER=`cat $WORK_DIR/version.txt`
+echo "Importing $DIR/../$FILENAME as $VER into git"
+cleanup
+gbp import-orig --pristine-tar -u $VER $DIR/../$FILENAME
+
+exit 0
diff --git a/files.diz b/files.diz
new file mode 100644
index 0000000..ccec895
--- /dev/null
+++ b/files.diz
@@ -0,0 +1,2 @@
+amd64!3dm2!2.11.00.021!3DM2_CLI-linux_10-2-2-1_9-5-5-1.zip!https://docs.broadcom.com/docs-and-downloads/raid-controllers/raid-controllers-common-files/3DM2_CLI-linux_10-2-2-1_9-5-5-1.zip!3889909bc63c7f65be89006d22a55b28
+i386!3dm2!2.11.00.021!3DM2_CLI-linux_10-2-2-1_9-5-5-1.zip!https://docs.broadcom.com/docs-and-downloads/raid-controllers/raid-controllers-common-files/3DM2_CLI-linux_10-2-2-1_9-5-5-1.zip!3889909bc63c7f65be89006d22a55b28