From: Michael J.M. Wagner Date: Wed, 13 Jul 2022 20:32:35 +0000 (+0200) Subject: posaune X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=0b8ae20fd3339cdb7b02aa37ec295cb0ceca6380;p=projects.git posaune --- diff --git a/debian/mbuild.conf b/debian/mbuild.conf new file mode 100644 index 0000000..af95b98 --- /dev/null +++ b/debian/mbuild.conf @@ -0,0 +1,12 @@ +# mbuild configuration file + +# type of compile. Possible values: NONE, CPP, CMAKE, PDF +compile_type=NONE +# compile target +compile_target= +# compile directory +compile_dir= + +# target type. Possible values: FILE, DEB, ZIP +target_type=DEB + diff --git a/debian/mbuild.cp b/debian/mbuild.cp index 628589c..b7efd86 100755 --- a/debian/mbuild.cp +++ b/debian/mbuild.cp @@ -14,6 +14,7 @@ cp tools/make/insert_build.sh $base/usr/share/mbuild/ cp tools/make/mMakefile $base/usr/share/mbuild/makefile cp tools/make/c_configure.sh $base/usr/share/mbuild/ cp tools/make/cpp.make $base/usr/share/mbuild/ +cp tools/make/configure $base/usr/share/mbuild/ cp doc/copyright $base/usr/share/mbuild/ mkdir -p $base/usr/share/man/man8 diff --git a/tools/make/configure b/tools/make/configure index da630c3..2382c1d 100755 --- a/tools/make/configure +++ b/tools/make/configure @@ -4,12 +4,12 @@ set -e function echo_usage { echo "usage: configure [options] " echo " -a " - echo " -c : configure" + echo " -b : extern build in ../build directory" + echo " -c " echo " -C " - echo " -d : compile" echo " -i : install dir. default: /" echo " -I : print this info" - echo " -p : pack default: do all" + echo " -t default: NONE" echo " -v : set version" echo " -V : version set by project" } @@ -97,7 +97,7 @@ function set_build { build=${tag##*-} else echo "No configuration system found. Cannot determine version." - exit 1 + exit 3 fi } @@ -122,7 +122,7 @@ function check_version { if [ "$clversion" != $version ] then echo "version mismatch: git: $version, changelog: $clversion" - exit 1 + exit 4 fi } @@ -131,13 +131,20 @@ function check_version { ############################################################################## install_dir="/" +compile_type=NONE +extern_build=0 + while [ $OPTIND -le "$#" ] do - if getopts "a:C:i:Iv:V" opt + if getopts "a:bB:C:i:It:v:V" opt then case $opt in a) ARCH=$OPTARG ;; + b) extern_build=1 + ;; + c) compile_dir=$OPTARG + ;; C) cross=$OPTARG ;; i) install_dir=$OPTARG @@ -145,17 +152,19 @@ do I) echo_usage exit 0 ;; + t) compile_type=$OPTARG + ;; v) optversion=$OPTARG ;; V) optversion="0.0" ;; \?) echo "Invalid option: -$OPTARG" echo_usage - exit 1 + exit 5 ;; :) echo "Option -$OPTARG requires an argument." echo_usage - exit 1 + exit 6 ;; esac else @@ -167,13 +176,19 @@ done if [ -z "$paket" ] then echo_usage - exit 1 + exit 7 +fi + +# read build configuration, if existing +if [ -f debian/$paket.conf ] +then + . debian/$paket.conf fi if [ -n "$ARCH" -a -n "$cross" ] then echo "invalid options: supply -a for multiarch or -C for explicit cross compile environment" - exit 1 + exit 8 fi if [ ! -e Makefile ] @@ -217,7 +232,6 @@ fi dpkg-architecture $arch_opt >> debian/setenv.sh echo "paket=$paket" >> debian/setenv.sh -echo "oldpack=\"$oldpack\"" >> debian/setenv.sh set_build if [ -z "$optversion" ] @@ -227,7 +241,9 @@ else version=$optversion fi echo "version=$version" >> debian/rules.pre +echo "version=$version" >> debian/setenv.sh echo "build=$build" >> debian/rules.pre +echo "build=$build" >> debian/setenv.sh # get repository name # tmp=$(pwd) @@ -279,16 +295,6 @@ sed -i "s/^/export /" setenv.sh popd >/dev/null # ./. --------------------------------------------- -# copy package control -if [ -f debian/$paket.control ] -then - # proceed - echo -else - echo "warning: control file not found" - echo " this file is necessary for any package production." -fi - # build prepare if [ -x debian/$paket.prepare ] then @@ -296,59 +302,53 @@ then debian/$paket.prepare fi -# compile prepare -if [ -x debian/$paket.build -o -e debian/$paket.cmake ] +if [ "$compile_type" == "NONE" ] then - # build requrired - echo "BUILD=build" >> debian/rules.pre - if [ -n "$BUILD_DIR" ] - then - BUILD_DIR=. - fi -else echo "BUILD=nobuild" >> debian/rules.pre -fi -# .build -if [ -x debian/$paket.build ] -then - if [ -x debian/$paket.prebuild ] +else + echo "BUILD=build" >> debian/rules.pre + + if [ $extern_build -eq 1 ] then - pushd $BUILD_DIR >/dev/null - . debian/setenv.sh - debian/$paket.prebuild - popd >/dev/null + BUILD_DIR=~/build + echo "BUILD_DIR=~/build" >> debian/rules.pre + debian/rules sync fi -fi -# .cmake -if [ -e debian/$paket.cmake ] -then - cmake_check -fi -# pack prepare -if [ -f debian/$paket.cp -a -f debian/$paket.control ] -then - echo "PACK=binary" >> debian/rules.pre - if grep "^Architecture: *all" debian/$paket.control >/dev/null + # .build + if [ "$compile_type" != "CMAKE" ] then - echo "arch = all" >> debian/rules.pre - echo 'BINARY_INDEP = copy ../$(paket)_$(version)-$(build)_all.deb' >> debian/rules.pre - else - echo 'arch = ${DEB_HOST_ARCH}' >> debian/rules.pre - echo "BINARY_ARCH = copy ../${paket}_$version-${build}_"'$(arch).deb' >> debian/rules.pre + cp debian/rules.pre $BUILD_DIR/$compile_dir/make.pre + pushd $BUILD_DIR/$compile_dir >/dev/null + ln -sf /usr/share/mbuild/makefile . + if [ -n "$sources_suffix" ] + then + echo "SOURCES = \\" >> make.pre + for suf in $sources_suffix + do + find . -name "*.$suf" -exec echo " "{}" \\" >> make.pre \; + done + echo >> make.pre + fi + popd >/dev/null fi - if ! [ -f debian/$paket.changelog ] + + if [ -x debian/$paket.build ] then - echo "changelog_source = debian/default.changelog" >> debian/rules.pre - if [ -f debian/default.changelog ] + if [ -x debian/$paket.prebuild ] then - rm debian/default.changelog + pushd $BUILD_DIR >/dev/null + . debian/setenv.sh + debian/$paket.prebuild + popd >/dev/null fi fi -elif [ -f debian/$paket.cp ] -then - echo "PACK=zip" >> debian/rules.pre -else - echo "PACK=version" >> debian/rules.pre + + # .cmake + if [ -e debian/$paket.cmake ] + then + cmake_check + fi fi + diff --git a/tools/make/mMakefile b/tools/make/mMakefile index d6da7bb..db7fa6c 100644 --- a/tools/make/mMakefile +++ b/tools/make/mMakefile @@ -24,8 +24,8 @@ clean: %.so: $(SOURCE:%.cpp=%.o) $(LDLIBS) $(CXX) -shared -o $(TARGET) *.o $(LDLIBS) $(EXTLIB) -make.pre: ~/build/debian/rules.pre - cp ~/build/debian/rules.pre make.pre +#make.pre: ~/build/debian/rules.pre +# cp ~/build/debian/rules.pre make.pre -include make.post # defile default operations @@ -35,5 +35,5 @@ make.pre: ~/build/debian/rules.pre #----------------------------------------------------------------- %.pdf : %.tex $(SOURCES) pdflatex $< && pdflatex $< - cp $*.pdf ~/build + #cp $*.pdf ~/build diff --git a/tools/make/mconfigure b/tools/make/mconfigure index b102ad7..dda9b97 100755 --- a/tools/make/mconfigure +++ b/tools/make/mconfigure @@ -3,9 +3,6 @@ set -e function echo_usage { echo "usage: mconfigure [options] " - echo " -c : copy configure/Makefile" - echo " -d : compile" - echo " -p : pack default: do all" ./configure -I } @@ -20,20 +17,12 @@ then fi configure=0 -compile=0 -pack=0 -confirure_args="-b ../build" +configure_args="-i debian/tmp" while [ $OPTIND -le "$#" ] do - if getopts "cdp" opt + if getopts "c" opt then case $opt in - c) configure=1 - ;; - d) compile=1 - ;; - p) pack=1 - ;; \?) $confirure_args="$configure_ars -$OPTARG" if [ $OPTARG="a" -o $OPTARG="C" -o $OPTARG="i" -o $OPTARG="v" ] then @@ -43,7 +32,7 @@ do ;; :) echo "Option -$OPTARG requires an argument." echo_usage - exit 1 + exit 3 ;; esac else @@ -55,67 +44,118 @@ done if [ -z "$paket" ] then echo_usage - exit 1 + exit 4 fi -if [ $configure -eq 1 ] +if [ ! -f debian/$paket.conf ] then - # installation of configure file - cp /usr/share/mbuild/configure . -else - if [ ! -e configure ] - then - ln -s /usr/share/mbuild/configure . - fi + echo "$paket.conf missing. We create it ..." + echo "to be implemented ..." + exit 5 fi -configure_args="$configure_args $paket" -if [ -x debian/$paket.preconfigure ] +if [ ! -e configure ] then - # if necessary $configure_args can be added to setenv.sh - debian/$paket.preconfigure + ln -s /usr/share/mbuild/configure . fi -#-> configure -# .build or .cmake -if [ -x debian/$paket.build -o -e debian/$paket.cmake ] +# clean build directory +if [ "$compile_type" != "NONE" ] then - echo "BUILD_DIR=../build" >> debian/setenv.sh - if [ -e ../build ] + if [ -e ~/build ] then - rm -rf ../build - mkdir ../build + rm -rf ~/build + mkdir ~/build fi +fi + +# perform configure +. debian/$paket.conf +if [ -n "$compile_dir" ] +then + configure_args="$configure_args -b $compile_dir" +fi +if [ -z "$compile_type" ] +then + echo "compile_type required in $paket.conf" + exit 51 +fi +if [ "$target_type" == "FILE" ] +then + # no version needed + configure_args="$configure_args -V" +fi +configure_args="$configure_args $paket" +echo "Executing ./configure $configure_args ..." +./configure $configure_args + +if [ "$compile_type" != "NONE" ] +then if grep -- "-prepare" debian/$paket.build >/dev/null then echo "prepare in .build no longer supported. Use .prebuild" - exit 2 + exit 6 fi # sync build dir . debian/setenv.sh debian/rules sync + make fi -# perform configure -. debian/setenv.sh -./configure $configure_args - -# if nothing is selected, select all -if [ $compile -eq 0 -a $pack -eq 0 ] +# pack prepare +if [ "$target_type" == "DEB" ] then - compile=1 - pack=1 -fi - -if [ $compile -eq 1 ] + if [ ! -f debian/$paket.cp ] + then + echo "debian/$paket.cp missing for target type DEB" + exit 9 + fi + if [ ! -f debian/$paket.control ] + then + echo "debian/$paket.control missing for target type DEB" + exit 10 + fi + + echo "PACK=binary" >> debian/rules.pre + if grep "^Architecture: *all" debian/$paket.control >/dev/null + then + echo "arch = all" >> debian/rules.pre + echo 'BINARY_INDEP = copy ../$(paket)_$(version)-$(build)_all.deb' >> debian/rules.pre + else + echo 'arch = ${DEB_HOST_ARCH}' >> debian/rules.pre + echo "BINARY_ARCH = copy ../${paket}_$version-${build}_"'$(arch).deb' >> debian/rules.pre + fi + if ! [ -f debian/$paket.changelog ] + then + echo "changelog_source = debian/default.changelog" >> debian/rules.pre + if [ -f debian/default.changelog ] + then + rm debian/default.changelog + fi + fi +elif [ "$target_type" == "ZIP" ] then - # build - make -fi - -if [ $pack -eq 1 ] + echo "PACK=zip" >> debian/rules.pre + if [ ! -f debian/$paket.cp ] + then + echo "debian/$paket.cp missing for target type ZIP" + exit 11 + fi +elif [ "$target_type" == "FILE" ] then - # build package - debian/rules pack + echo "PACK=version" >> debian/rules.pre + if [ -z "$compile_target" ] + then + echo "compile_target is needed for target_type FILE" + exit 12 + fi + echo "TARGET = $compile_target" >> debian/rules.pre + +else + echo "Unknown target type: $target_type" + exit 13 fi +# build package +debian/rules pack + diff --git a/tools/make/rules b/tools/make/rules index e84acf9..7d0fa32 100755 --- a/tools/make/rules +++ b/tools/make/rules @@ -4,9 +4,10 @@ # defile default operations NOP = @echo "No operation for target $@" -DEB = fakeroot dpkg-deb --build $(oldpack) debian/tmp +DEB = fakeroot dpkg-deb --build debian/tmp INSERT_BUILD = /usr/share/mbuild/insert_build.sh RSYNC_OPT = -av --exclude="build" --exclude="debian/tmp" --exclude="Packages" --exclude="*Aktuell" --exclude=".*" +BUILD_DIR = . std_inst_tgt = debian/tmp/usr/share/doc/$(paket)/copyright debian/tmp/usr/share/doc/$(paket)/README.debian changelog_source = debian/$(paket).changelog @@ -22,8 +23,8 @@ clean: -rm -rf debian/tmp # Bauen der kompilierten Programme und formatierten Dokumente aus den Quellen im Bauverzeichnis -build: ../build/debian/$(paket).build sync - cd ../build ; debian/$(paket).build +build: $(BUILD_DIR)/debian/$(paket).build sync + cd $(BUILD_DIR) ; debian/$(paket).build # Build succeeded nobuild: @@ -31,6 +32,7 @@ nobuild: install: debian/$(paket).cp $(INSTALL_DIR) + pack: $(PACK) # packing succeeded @@ -52,18 +54,17 @@ binary-arch: $(BINARY_ARCH) # Erstellen Architektur-unabhängiger (Architecture: all) Binärpakete im übergeordneten Verzeichnis binary-indep: $(BINARY_INDEP) -version: ~/build/$(TARGET) - $(INSERT_BUILD) ~/build/$(TARGET) $(build) - cp ~/build/*$(build)* ../ +version: $(BUILD_DIR)/$(TARGET) + $(INSERT_BUILD) $(BUILD_DIR)/$(TARGET) $(build) + cp $(BUILD_DIR)/*$(build)* ../ -../build: - mkdir ../build +$(BUILD_DIR): + mkdir $(BUILD_DIR) -sync: ../build - rsync $(RSYNC_OPT) ./ ../build/ +sync: $(BUILD_DIR) + rsync $(RSYNC_OPT) ./ $(BUILD_DIR)/ -copy: debian/$(paket).cp - debian/$(paket).cp debian/tmp +copy: debian/$(paket).cp install create-conffiles debian/tmp touch debian/tmp