Do not overwrite existing info.tar.bz2 files but use timestamp in filename instead
authorMichael Prokop <mika@grml.org>
Mon, 11 Jun 2007 10:17:58 +0000 (12:17 +0200)
committerMichael Prokop <mika@grml.org>
Mon, 11 Jun 2007 10:17:58 +0000 (12:17 +0200)
debian/changelog
grml-hwinfo

index 655ea0a..b99c347 100644 (file)
@@ -3,6 +3,8 @@ grml-hwinfo (0.3-3) unstable; urgency=low
   [Michael Prokop]
   * Improve code layout (like checks for binaries, portability for
     non-grml system).
+  * Do not overwrite existing info.tar.bz2 files but use timestamp
+    in filename instead.
 
   [Alexander Wirt]
   * Add procinfo to suggests.
index 29c898e..b96d2e8 100755 (executable)
@@ -4,7 +4,7 @@
 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2.
-# Latest change: Mon Jun 11 12:05:32 CEST 2007 [mika]
+# Latest change: Mon Jun 11 12:15:04 CEST 2007 [mika]
 ################################################################################
 # Notice: Some ideas have been taken from
 # http://club.black.co.at/david/hwdb/infodump
 ################################################################################
 
 # variables
-UNAME=$(uname -r)
-PN=$(basename $0)
+UNAME="$(uname -r)"
+PN="$(basename $0)"
 VERSION='0.3'
-if [ -z "$INFOFILE" ]; then
-   INFOFILE='info.tar.bz2'
-fi
+
+[ -n "$INFOFILE" ] || INFOFILE='info.tar.bz2'
+
 
 if [ "$(id -u)" != 0 ] ; then
    NOTROOT=1
@@ -181,7 +181,14 @@ fi
 )
 
 # finally create the tarball
-tar jcf $INFOFILE info/ && rm -Rf info/
+if [ -f "$INFOFILE" ] ; then
+   DATE="$(date +%Y%m%d_%H:%M:%S)"
+   INFOFILE="info_$DATE.tar.bz2"
+   echo "Warning:  $INFOFILE exists already, using $INFOFILE instead.">&1
+   tar jcf $INFOFILE info/ && rm -Rf info/
+else
+   tar jcf $INFOFILE info/ && rm -Rf info/
+fi
 
 echo
 [ -r "$INFOFILE" ] && echo "$INFOFILE ($(ls -ahl $INFOFILE | awk '{print $5}')) has been generated."