]> wagnertech.de Git - projects.git/commitdiff
Merge ../projects
authorMichael Wagner <michael@wagnertech.de>
Tue, 6 Mar 2018 21:01:36 +0000 (22:01 +0100)
committerMichael Wagner <michael@wagnertech.de>
Tue, 6 Mar 2018 21:01:36 +0000 (22:01 +0100)
README.md
tools/make/c_configure.sh
tools/make/configure
tools/make/makefile
tools/make/mconfigure [new file with mode: 0755]
tools/make/treecopy [new file with mode: 0755]

index 402873d672738d500bdb11129009620e32e52eab..b5bd55b3f257b9332d0da031a05b74ff926eaea4 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,2 +1,5 @@
 # projects
 WagnerTech utility projects
+
+To build a debian package:
+git checkout <build-tag>
index f2e5bcd1105b1c3336ff5180dbae87a95f1e0237..c7b610ad560f220953f0cfcdc17aaeee703bfb3b 100755 (executable)
@@ -16,8 +16,9 @@ function install_cpp_make {
        src=$(pwd);
        pushd $1
        if [ -f makefile ]; then rm makefile; fi
+       if [ -L makefile ]; then rm makefile; fi
        if [ -f make.post ]; then rm make.post; fi
-       ln -s $cwd/Make/cpp.make makefile
+       ln -s $cwd/projects/tools/make/cpp.make makefile
        echo "SOURCE = \\" > make.pre
        for file in $(ls *.cpp)
        do
@@ -50,6 +51,16 @@ function append_dependency {
        echo "" >> $1/make.post
 }
 
+function add_include {
+# adds a include directory
+# parameter:
+# $1: main directory
+# $2: include dir
+
+       src=$(pwd)
+       echo "CXXFLAGS += -I$src/$2" >> $1/make.pre
+}
+
 function append_library {
 # same as append_dependency. In addition a include statement + a link to the library is added to "main directory"
 # parameter:
index e91b31ad2110bd3bd9ff0aa1006b1160c3a26c3e..a92ecbd7e017e19861e06092c2e24bf29f9ae528 100755 (executable)
@@ -130,6 +130,11 @@ then
 project = $paket
 COPY = ./$paket.cp
 MAKE_PRE
+       if [ -n "$ARCH" ]
+       then
+               echo "arch = $ARCH" >>make.pre
+               echo "_arch = _${ARCH}" >>make.pre
+       fi
        echo "make.pre written."
 fi
 
index 0dea1519ae0ea3edf808ead1db233dc282a6c845..57dc39d5c289631491acbb91df3ddea44f992e8a 100644 (file)
@@ -54,7 +54,7 @@ compile.stamp: $(SOURCES)
 #-----------------------------------------------------------------
 
 copy.stamp: $(COPY_PRE)
-       $(COPY) $(project)
+       $(COPY) $(project) $(version) ${arch}
        @touch copy.stamp
 
 control.stamp: $(project).control
diff --git a/tools/make/mconfigure b/tools/make/mconfigure
new file mode 100755 (executable)
index 0000000..a5e9297
--- /dev/null
@@ -0,0 +1,136 @@
+#!/bin/bash
+set -e
+
+function echo_usage {
+       echo "usage: configure <package> [options]"
+       echo "  -a <arch>"
+}
+
+function set_build {
+       if [ -e .svn ]
+       then
+               build=$(svnversion)
+       elif [ -e .git ]
+       then
+               build=$(git describe --tags 2>/dev/null)
+               test -n "$build" || build="TOP"
+               changes=$(git status -s |grep "^ *M") || true
+               test -z "$changes" || build="${build}M"
+       fi
+}
+
+# to build a package you need ...
+# <package>.cp (optional): copy step for package production
+# <package>.cpp.sh (optional): commands to setup the C++ compile environment
+
+if [ $# -lt 1 ]
+then
+       echo_usage
+       exit 1
+fi
+
+paket=$1
+shift
+ARCH=""
+cpp_build=0
+delete_src=1
+
+set_build
+echo "building $paket with build $build"
+
+while getopts ":a" opt; do
+       case $opt in
+               a) ARCH=$OPTARG
+                       ;;
+               \?) echo "Invalid option: -$OPTARG"
+                       echo_usage
+                       exit 1
+                       ;;
+               :) echo "Option -$OPTARG requires an argument."
+                       echo_usage
+                       exit 1
+                       ;;
+       esac
+done
+
+# clean dirs and check out
+if [ -d build -a $delete_src -eq 1 ]
+then
+       rm -rf build
+fi
+
+mkdir -p build
+pushd build >/dev/null
+
+ln -sf /usr/share/mbuild/makefile .
+
+if [ -e $paket ]
+then
+       rm -rf $paket
+fi
+rm *.stamp || true
+rm make.pre || true
+
+# load util functions for C/C++ - build
+if [ -f $paket.cpp.sh ]
+then
+       cpp_build=1
+       . projects/tools/make/c_configure.sh
+       . $paket.cpp.sh
+fi
+
+# copy package control
+control=$(find -L src -name $paket.control)
+build_number=${build#*_}
+if [ -z "$control" ]
+then
+       echo "warning: control file not found"
+       echo "  this file is necessary for any package production."
+else   
+       sed "s/%BUILD%/$build_number/" $control |sed "s/%ARCH%/$ARCH/" >$paket.control
+       echo "$paket.control written."
+
+       # extract version
+       version=$(grep Version $paket.control |sed "s/Version: //")
+fi
+
+# check for copy file
+copy=$(find -L src -name $paket.cp)
+if [ -n "$copy" ]
+then
+       ln -sf $copy .
+else
+       echo "warning: file $paket.cp missing or not executable:"
+       echo "  this file is necessary for any package production."
+fi
+
+# check for installation scripts
+files=$(find src -name $paket.preinst)
+files="$files $(find -L src -name $paket.postinst)"
+files="$files $(find -L src -name $paket.prerm)"
+files="$files $(find -L src -name $paket.postrm)"
+for file in $files
+do
+       ln -sf $file .
+done
+
+# create generic make.pre, if not existing
+if [ ! -f make.pre ]
+then
+       cat  >>make.pre <<MAKE_PRE
+# mBuild make.pre script (auto generated)
+project = $paket
+COPY = ./$paket.cp
+MAKE_PRE
+       if [ -n "$ARCH" ]
+       then
+               echo "arch = $ARCH" >>make.pre
+               echo "_arch = _${ARCH}" >>make.pre
+       fi
+       echo "make.pre written."
+fi
+
+# append version to make.pre
+echo "version = $version" >> make.pre
+echo "build = $build" >> make.pre
+
diff --git a/tools/make/treecopy b/tools/make/treecopy
new file mode 100755 (executable)
index 0000000..761bd87
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+# copy all files below <from> ($1), that match <filepattern> ($3)
+# into target <to> ($2)
+
+function fcp
+{
+       rel_path=${3#$1}
+       
+       # create target dir, if necessary
+       rel_dir=${rel_path%/*}
+       mkdir -p $2/$rel_dir
+       cp -a $1/$rel_path $2/$rel_dir
+}
+       
+usage="usage: treecopy <from> <to> <filepattern>|-e"
+
+if [ $# -ne 3 ]
+then
+       echo $usage
+       exit 1
+fi
+if [ $3 == "-e" ]
+then
+       for file in $(find $1 \( -type f -o -type l \) -executable)
+       do
+               fcp $1 $2 $file
+       done
+else   
+       for file in $(find $1 \( -type f -o -type l \) -name "$3")
+       do
+               fcp $1 $2 $file
+       done
+fi