Merge branch 'master' of http://wagnertech.de/git/projects
authorgnublin <michael@wagnertech.de>
Wed, 27 Jul 2016 10:22:52 +0000 (12:22 +0200)
committergnublin <michael@wagnertech.de>
Wed, 27 Jul 2016 10:22:52 +0000 (12:22 +0200)
tools/make/configure
tools/make/insert_build.sh [new file with mode: 0755]
tools/make/makefile

index f4541ba..32b2558 100755 (executable)
@@ -5,6 +5,8 @@ function echo_usage {
        echo "usage: configure <package> <revision> [options]"
        echo "  -b <branch-rev>"
        echo "  -a <arch>"
+       echo "  -g <alternative repository>"
+       echo "  -n : do not delete src dir"
 }
 
 # to build a package you need ...
@@ -20,26 +22,33 @@ fi
 
 paket=$1
 build=$2
+shift 2
 ARCH=""
 cpp_build=0
+alt_repos=""
+delete_src=1
 
-shift 2
-while getopts "b:a:" opt
-do
+while getopts ":a:b:g:n" opt; do
        case $opt in
-       a) ARCH=$OPTARG
-               ;;
-       b) echo "branching not implemented"
-               ;;
-       *) exit 1
-               ;;
+               a) ARCH=$OPTARG
+                       ;;
+               b) branch=$OPTARG
+                       ;;
+               g) alt_repos="-g $OPTARG"
+                       ;;
+               n) delete_src=0
+                       ;;
+               \?) echo "Invalid option: -$OPTARG"
+                       echo_usage
+                       exit 1
+                       ;;
+               :) echo "Option -$OPTARG requires an argument."
+                       echo_usage
+                       exit 1
+                       ;;
        esac
 done
 
-# checkout build utilities
-if [ ! -d projects ]; then
-       git clone https://github.com/wagner-tech/projects/
-fi
 ln -sf projects/tools/make/makefile .
 
 # check standard files
@@ -50,14 +59,9 @@ then
 fi
 
 # clean dirs and check out
-if [ -d src ]
+if [ -d src -a $delete_src -eq 1 ]
 then
-       echo "Shall I delete src dir? [y]/n"
-       read key
-       if [ "$key" != "n" ]
-       then
-               rm -rf src
-       fi
+       rm -rf src
 fi
 
 if [ -e $paket ]
@@ -72,7 +76,7 @@ cwd=$(pwd)
 
 # checkout
 pushd src >/dev/null
-       ../$paket.co $build
+       ../$paket.co $alt_repos $build 
 popd >/dev/null
 
 # load util functions for C/C++ - build
@@ -127,4 +131,5 @@ fi
 
 # append version to make.pre
 echo "version = $version" >> make.pre
+echo "build = $build" >> make.pre
 
diff --git a/tools/make/insert_build.sh b/tools/make/insert_build.sh
new file mode 100755 (executable)
index 0000000..00a90b0
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/bash
+set -e
+
+usage="insert_build.sh <file> <build>"
+
+# inserts _<build> before last dot of filename
+# example: "insert_build.sh 45 foo.pdf" leads to "foo_45.pdf"
+
+if [ $# -ne 2 ]; then
+       echo $usage
+       exit 1
+fi
+
+stem=${1%.*}
+ext=${1##*.}
+
+cp $1 ${stem}_$2.$ext
+
index 6513f24..b2f4944 100644 (file)
@@ -8,6 +8,7 @@ COMPILE_TARGET = compile.stamp
 COPY = $(NOP)
 ZIP = zip -r $(project).zip $(project)
 DEB = fakeroot dpkg-deb --build $(project)
+INSERT_BUILD = projects/tools/make/insert_build.sh
 
 #default parameters
 project = default
@@ -38,6 +39,9 @@ zip: $(project).zip
 deb: $(project).deb
        # Debian package ready
 
+version: $(COMPILE_TARGET)
+       $(INSERT_BUILD) $(COMPILE_TARGET) $(build)
+
 #-----------------------------------------------------------------
 # compile steps
 #-----------------------------------------------------------------
@@ -78,5 +82,5 @@ clean:
 # Build-Regeln
 #-----------------------------------------------------------------
 %.pdf : %.tex $(SOURCES)
-       pdflatex $<
+       pdflatex $< && pdflatex $<