Browse Source

buid updated

master
Marc Wäckerlin 3 years ago
parent
commit
c8dbfd6434
6 changed files with 257 additions and 82 deletions
  1. 8
    0
      autogen.sh
  2. 58
    18
      ax_init_standard_project.m4
  3. 94
    37
      bootstrap.sh
  4. 82
    23
      build-in-docker.sh
  5. 1
    1
      resolve-debbuilddeps.sh
  6. 14
    3
      resolve-rpmbuilddeps.sh

+ 8
- 0
autogen.sh View File

@@ -0,0 +1,8 @@
1
+#!/bin/bash -e
2
+if test -n "svn" -a -d .svn -a -e -x ; then
3
+    svn2cl
4
+fi
5
+aclocal
6
+libtoolize --force
7
+automake -a
8
+autoconf

+ 58
- 18
ax_init_standard_project.m4 View File

@@ -12,29 +12,27 @@ m4_define(x_least, m4_ifdef([x_least_fix], [x_least_fix],
12 12
   m4_ifdef([x_least_diff],
13 13
     mrw_esyscmd_s([
14 14
       VCS_REVISION="ERROR-UNDEFINED-REVISION-to-be-built-in-subdirectory-of-checkout"
15
-      for path in . .. ../..; do
15
+      for path in . .. ../.. ../../..; do
16 16
         if test -d .svn; then
17
+          svn upgrade 1>&2 > /dev/null || true
17 18
           VCS_REVISION=$(LANG= svn info $path | sed -n 's/Last Changed Rev: //p')
18
-          if test -z "${VCS_REVISION}"; then VCS_REVISION=0; fi
19
-          break;
19
+          if test -n "${VCS_REVISION}"; then break; fi
20 20
         elif test -d .git; then
21 21
           VCS_REVISION=$(git rev-list --all --count)
22
-          if test -z "${VCS_REVISION}"; then VCS_REVISION=0; fi
23
-          break;
22
+          if test -n "${VCS_REVISION}"; then break; fi
24 23
         fi
25 24
       done
26 25
       echo $ECHO_N $(($VCS_REVISION))
27 26
     ]),  mrw_esyscmd_s([
28 27
       VCS_REVISION="ERROR-UNDEFINED-REVISION-to-be-built-in-subdirectory-of-checkout"
29
-      for path in . .. ../..; do
28
+      for path in . .. ../.. ../../..; do
30 29
         if test -d .svn; then
30
+          svn upgrade 1>&2 > /dev/null || true
31 31
           VCS_REVISION=$(LANG= svn info $path | sed -n 's/Last Changed Rev: //p')
32
-          if test -z "${VCS_REVISION}"; then VCS_REVISION=0; fi
33
-          break;
32
+          if test -n "${VCS_REVISION}"; then break; fi
34 33
         elif test -d .git; then
35 34
           VCS_REVISION=$(git rev-list --all --count)
36
-          if test -z "${VCS_REVISION}"; then VCS_REVISION=0; fi
37
-          break;
35
+          if test -n "${VCS_REVISION}"; then break; fi
38 36
         fi
39 37
       done
40 38
       # Mac does not support LEAST > 255
@@ -46,22 +44,21 @@ m4_define(x_least, m4_ifdef([x_least_fix], [x_least_fix],
46 44
 # define version number from subversion's revision number:
47 45
 # it is taken modulo 256 due to a bug on Apple's MacOSX
48 46
 # add to x_minor if revision number is > 256
49
-m4_define(x_minor_diff, mrw_esyscmd_s([
47
+m4_define(x_minor_diff, m4_ifdef([x_least_fix], 0, mrw_esyscmd_s([
50 48
   VCS_REVISION="ERROR-UNDEFINED-REVISION-to-be-built-in-subdirectory-of-checkout"
51
-  for path in . .. ../..; do
49
+  for path in . .. ../.. ../../..; do
52 50
     if test -d .svn; then
51
+      svn upgrade 1>&2 > /dev/null || true
53 52
       VCS_REVISION=$(LANG= svn info $path | sed -n 's/Last Changed Rev: //p')
54
-      if test -z "${VCS_REVISION}"; then VCS_REVISION=0; fi
55
-      break;
53
+      if test -n "${VCS_REVISION}"; then break; fi
56 54
     elif test -d .git; then
57 55
       VCS_REVISION=$(git rev-list --all --count)
58
-      if test -z "${VCS_REVISION}"; then VCS_REVISION=0; fi
59
-      break;
56
+      if test -n "${VCS_REVISION}"; then break; fi
60 57
     fi;
61 58
   done
62 59
   # Mac does not support LEAST > 255
63 60
   echo $ECHO_N $(($VCS_REVISION/256))
64
-]))
61
+])))
65 62
 # setup version number
66 63
 m4_define(x_version, [x_major.m4_ifdef([x_least_diff], x_minor, m4_eval(x_minor+x_minor_diff)).m4_eval(m4_ifdef([x_least_diff], [x_least-x_least_diff], [x_least]))])
67 64
 
@@ -184,6 +181,8 @@ AC_DEFUN([AX_INIT_STANDARD_PROJECT], [
184 181
   _AM_SUBST_NOTMAKE([AUTHOR])
185 182
   DISTRO=$(lsb_release -sc 2>/dev/null || uname -s 2>/dev/null)
186 183
   AX_SUBST(DISTRO)
184
+  ARCH=$((@<:@@<:@ $(uname -sm) =~ 64 @:>@@:>@ && echo amd64) || (@<:@@<:@ $(uname -sm) =~ 'i?86' @:>@@:>@ && echo i386 || uname -sm))
185
+  AX_SUBST(ARCH)
187 186
   DISTRIBUTOR=$(lsb_release -si 2>/dev/null || uname -s 2>/dev/null)
188 187
   case "${DISTRIBUTOR// /-}" in
189 188
     (Ubuntu) UBUNTU=1; AX_SUBST(UBUNTU);;
@@ -312,6 +311,43 @@ maintainer-clean-cxx-targets:
312 311
 EOF
313 312
 ])
314 313
 
314
+# use this in configure.ac to support old school C
315
+AC_DEFUN([AX_USE_C], [
316
+  AC_LANG(C)
317
+  AC_PROG_CC
318
+  AC_PROG_CPP
319
+
320
+  AC_CONFIG_FILES([src/makefile])
321
+  
322
+  AM_CPPFLAGS+=' -I ${top_srcdir}/src -I ${top_builddir}/src -I ${srcdir} -I ${builddir}'
323
+  AM_LDFLAGS+=' -L ${top_srcdir}/src -L ${top_builddir}/src'
324
+
325
+  # Get rid of those stupid -g -O2 options!
326
+  CXXFLAGS="${CXXFLAGS//-g -O2/}"
327
+  CFLAGS="${CFLAGS//-g -O2/}"
328
+
329
+  # pass compile flags to make distcheck
330
+  AM_DISTCHECK_CONFIGURE_FLAGS="CFLAGS='${CFLAGS}' CPPFLAGS='${CPPFLAGS}' CFLAGS='${CFLAGS}' LDFLAGS='${LDFLAGS}'"
331
+  AC_SUBST(AM_DISTCHECK_CONFIGURE_FLAGS)
332
+
333
+  AC_SUBST(AM_CFLAGS)
334
+  AC_SUBST(AM_CPPFLAGS)
335
+  AC_SUBST(AM_LDFLAGS)
336
+  AX_ADD_MAKEFILE_TARGET_DEP([maintainer-clean-am], [maintainer-clean-c-targets], [src/makefile.in])
337
+  test -f src/makefile.in && cat >> src/makefile.in <<EOF
338
+#### Begin: Appended by $0
339
+%.app: %
340
+	-rm -r [\$][@]
341
+	\$(MAKE) DESTDIR=[\$][\$](pwd)/[\$][@]/tmp install
342
+	  \${top_builddir}/mac-create-app-bundle.sh \
343
+	    [\$][@] [\$][<] [\$][\$](pwd)/[\$][@]/tmp\${prefix}
344
+
345
+maintainer-clean-c-targets:
346
+	-rm makefile.in
347
+#### End: $0
348
+EOF
349
+])
350
+
315 351
 # use this in configure.ac to support tests without CppUnit
316 352
 AC_DEFUN([AX_BUILD_TEST], [
317 353
   AC_CONFIG_FILES([test/makefile])
@@ -401,7 +437,7 @@ EXTRA_DIST += debian
401 437
 clean-debian-targets:
402 438
 	-rm -rf \${PACKAGE_NAME}_\${PACKAGE_VERSION}~\${DISTRO}.\${BUILD_NUMBER}.{dsc,tar.gz} \${PACKAGE_NAME}_\${PACKAGE_VERSION}~\${DISTRO}.\${BUILD_NUMBER}*.changes \$\$(sed -n 's,Package: \(.*\),\1_${PACKAGE_VERSION}~${DISTRO}.${BUILD_NUMBER}*.deb,p;' debian/control)
403 439
 deb: distdir
404
-	cd \${PACKAGE_NAME}-\${PACKAGE_VERSION} && ( export CFLAGS="\${CFLAGS}"; export CPPFLAGS="\${CPPFLAGS}"; export  CXXFLAGS="\${CXXFLAGS}"; export LDFLAGS="\${LDFLAGS}"; export DEB_CFLAGS_APPEND="\${CFLAGS}"; export DEB_CPPFLAGS_APPEND="\${CPPFLAGS}"; export  DEB_CXXFLAGS_APPEND="\${CXXFLAGS}"; export  DEB_LDFLAGS_APPEND="\${LDFLAGS}"; dpkg-buildpackage )
440
+	cd \${PACKAGE_NAME}-\${PACKAGE_VERSION} && ( export CFLAGS="\${CFLAGS}"; export CPPFLAGS="\${CPPFLAGS}"; export CXXFLAGS="\${CXXFLAGS}"; export LDFLAGS="\${LDFLAGS}"; export DEB_CFLAGS_APPEND="\${CFLAGS}"; export DEB_CPPFLAGS_APPEND="\${CPPFLAGS}"; export  DEB_CXXFLAGS_APPEND="\${CXXFLAGS}"; export DEB_LDFLAGS_APPEND="\${LDFLAGS}"; dpkg-buildpackage )
405 441
 distclean-debian-targets:
406 442
 	-rm debian/changelog debian/control
407 443
 #### End: $0
@@ -412,12 +448,15 @@ EOF
412 448
 AC_DEFUN([AX_USE_RPM_PACKAGING], [
413 449
   AC_CONFIG_FILES([${PACKAGE_NAME}.spec])
414 450
   #AX_ADD_MAKEFILE_TARGET_DEP([clean-am], [clean-rpm-targets], [makefile.in])
451
+  AX_ADD_MAKEFILE_TARGET_DEP([clean-am], [clean-rpm-targets], [makefile.in])
415 452
   AX_ADD_MAKEFILE_TARGET_DEP([distclean-am], [distclean-rpm-targets], [makefile.in])
416 453
   test -f makefile.in && cat >> makefile.in <<EOF
417 454
 #### Begin: Appended by $0
418 455
 EXTRA_DIST += \${PACKAGE_NAME}.spec.in
419 456
 rpm: dist
420 457
 	rpmbuild -ba --define "_topdir \$\$(pwd)" --define "_sourcedir \$\$(pwd)" \${PACKAGE_NAME}.spec
458
+clean-rpm-targets:
459
+	-rm -rf BUILD BUILDROOT RPMS SPECS SRPMS
421 460
 distclean-rpm-targets:
422 461
 	-rm \${PACKAGE_NAME}.spec
423 462
 #### End: $0
@@ -635,6 +674,7 @@ AC_DEFUN([AX_PKG_CHECK], [
635 674
 # make sure, a specific header exists
636 675
 # - parameter:
637 676
 #    $1 = header name
677
+#    $2 = pathes to search for
638 678
 AC_DEFUN([AX_REQUIRE_HEADER], [
639 679
   AC_CHECK_HEADER($1, [], [
640 680
     if test -n "$2"; then

+ 94
- 37
bootstrap.sh View File

@@ -23,17 +23,22 @@ docker=0
23 23
 buildtarget=""
24 24
 overwrite=0
25 25
 rebuild=0
26
+novcs=0
27
+excludevcs=()
26 28
 rebuildfiles=()
27 29
 while test $# -gt 0; do
28 30
     case "$1" in
29 31
         (--configure|-c) configure=1;;
30 32
         (--docker|-d) docker=1;;
31 33
         (--build|-b) configure=1; build=1; buildtarget+=" distcheck";;
32
-        (--target|-t) shift; configure=1; build=1; buildtarget+=" $1";;
34
+        (--all|-a) shift; configure=1; build=1; buildtarget+=" all";;
33 35
         (--clean) shift; configure=1; build=1; buildtarget+=" maintainer-clean";;
36
+        (--target|-t) shift; configure=1; build=1; buildtarget+=" $1";;
34 37
         (--overwrite|-o) overwrite=1;;
35 38
         (--rebuild|-r) rebuild=1;;
36 39
         (--rebuild-file|-f) shift; rebuildfiles+=("$1");;
40
+        (--no-vcs|-n) novcs=1;;
41
+        (--exclude-vcs|-x) shift; excludevcs+=("$1");;
37 42
         (--version|-v)
38 43
             echo "$Id$";
39 44
             exit;;
@@ -47,10 +52,14 @@ OPTIONS
47 52
   --configure, -c            call ./configure after initialization
48 53
   --docker, -d               build and run tests in a docker instance
49 54
   --build, -b                build, also call ./configure && make distcheck
55
+  --all, -a                  same as -b, but make target all
56
+  --clean                    same as -b, but make target maintainer-clean
50 57
   --target, -t <target>      same as -b, but specify target instead of distcheck
51 58
   --overwrite, -o            overwrite all basic files (bootstrap.sh, m4-macros)
52 59
   --rebuild, -r              force rebuild of generated files, even if modified
53 60
   --rebuild-file, -f <file>  rebild specific file (can be added multiple times)
61
+  --no-vcs, -n               do not automatically add files to version control
62
+  --exclude-vcs, -x <file>   exclude specific file from version control
54 63
   --help, -h                 show this help
55 64
   --version, -v              show version and date of this file
56 65
 
@@ -109,18 +118,21 @@ RUNNING
109 118
   If you run ${MY_NAME}, it first generates the necessary files (see
110 119
   below), then first runs make distclean if a makefile exists. After
111 120
   this it calles aclocal, libtoolize, automake, autoconf and
112
-  optionally ./configure.
121
+  optionally ./configure. If necessary, files are added to version
122
+  control.
113 123
 
114 124
 GENERATED FILES
115 125
 
116 126
   This script copies the following files into your project environment:
117 127
     * ${MY_NAME}
128
+    * autogen.sh - just the basics to initialize auto tools and create configure
118 129
     * ax_init_standard_project.m4 - auxiliary macro definition file
119 130
     * ax_cxx_compile_stdcxx_11.m4 - auxiliary macro definition file
120 131
     * ax_check_qt.m4 - auxiliary macro definition file
121 132
     * resolve-debbuilddeps.sh - script to install debian package dependencies
122 133
     * resolve-rpmbuilddeps.sh - script to install RPM package dependencies
123 134
     * build-in-docker.sh - script to build the project encapsulated in a docker container
135
+    * build-in-docker.conf - additional configuration for build-in-docker.sh
124 136
     * build-resource-file.sh - build resource.qrc file from a resource directory
125 137
     * sql-to-dot.sed - script to convert SQL schema files to graphviz dot in doxygen
126 138
     * mac-create-app-bundle.sh - script to create apple mac os-x app-bundle
@@ -260,20 +272,20 @@ EOF
260 272
 done
261 273
 
262 274
 echo -en "\e[1m-> checking:\e[0m for version control system ..."
275
+VCS=""
276
+VCSDEPENDS=""
263 277
 if test -d .svn; then
264
-  VCS="svn"
265
-  VCSDEPENDS="subversion"
278
+    VCS="svn"
279
+    VCSDEPENDS="subversion,"
280
+    echo -e " \e[32msuccess\e[0m detected ${VCS}"
266 281
 elif test -d .git; then
267
-  VCS="git"
268
-  VCSDEPENDS="git"
282
+    VCS="git"
283
+    VCSDEPENDS="git,"
284
+    echo -e " \e[32msuccess\e[0m detected ${VCS}"
269 285
 else
270
-    echo -e " \e[31merror\e[0m"
271
-    echo -e "\e[1m*** must be started in root path of a subversion or git repositry\e[0m"
272
-    exit 1
286
+    echo -e " \e[33mignored\e[0m"
273 287
 fi
274 288
 
275
-echo -e " \e[32msuccess\e[0m detected ${VCS}"
276
-
277 289
 HEADER='## @id '"\$Id\$"'
278 290
 ##
279 291
 ## This file has been added:
@@ -345,7 +357,9 @@ contains() {
345 357
 checkdir() {
346 358
     if ! test -d "$1"; then # create path
347 359
         run mkdir -p "$1"
348
-        run ${VCS} add "$1"
360
+        if test -n "${VCS}" -a $novcs -eq 0 && ! contains "$1" "${excludevcs[@]}"; then
361
+            run ${VCS} add "$1"
362
+        fi
349 363
     fi
350 364
 }
351 365
 
@@ -358,13 +372,17 @@ checkfile() {
358 372
 }
359 373
 
360 374
 to() {
375
+    mode="u=rw,g=rw,o=r"
361 376
     while test $# -gt 0; do
362
-        mode="u=rw,g=rw,o=r"
363 377
         case "$1" in
364 378
             (--condition) shift # test for a tag, abort if not set
365 379
                 if ! testtag "$1"; then
366 380
                     return 0
367 381
                 fi;;
382
+            (--unless) shift # test for a tag, abort if set
383
+                if testtag "$1"; then
384
+                    return 0
385
+                fi;;
368 386
             (--mode) shift # test for a tag, abort if not set
369 387
                 mode="$1";;
370 388
             (*) break;;
@@ -390,11 +408,13 @@ to() {
390 408
     else
391 409
         echo -e " \e[32msuccess\e[0m"
392 410
     fi
393
-    chmod $mode $1
411
+    run chmod $mode $1
394 412
     if test $exists -eq 0; then
395
-        run ${VCS} add "$1"
396
-        if test "${VCS}" = "svn"; then
397
-            run svn propset svn:keywords "Id" "$1"
413
+        if test -n "${VCS}" -a $novcs -eq 0 && ! contains "$1" "${excludevcs[@]}"; then
414
+            run ${VCS} add "$1"
415
+            if test "${VCS}" = "svn"; then
416
+                run svn propset svn:keywords "Id" "$1"
417
+            fi
398 418
         fi
399 419
     fi
400 420
     return 0
@@ -415,9 +435,11 @@ copy() {
415 435
     fi
416 436
     run cp "${source}" "$1"
417 437
     if test $exists -eq 0; then
418
-        run ${VCS} add "$1"
419
-        if test "${VCS}" = "svn"; then
420
-            run svn propset svn:keywords "Id" "$1"
438
+        if test -n "${VCS}" -a $novcs -eq 0 && ! contains "$1" "${excludevcs[@]}"; then
439
+            run ${VCS} add "$1"
440
+            if test "${VCS}" = "svn"; then
441
+                run svn propset svn:keywords "Id" "$1"
442
+            fi
421 443
         fi
422 444
     fi
423 445
 }
@@ -446,21 +468,27 @@ doxyadd() {
446 468
 
447 469
 vcs2cl() {
448 470
     exists=0
449
-    if test -f "Changelog"; then
471
+    if test -f "ChangeLog"; then
450 472
         exists=1
451
-    fi
452
-    if test "${VCS}" = "git"; then
453
-        ${VCS}2cl > ChangeLog
454 473
     else
455
-        ${VCS}2cl
474
+        touch "ChangeLog"
475
+    fi
476
+    if test -x $(which ${VCS}2cl); then
477
+        if test "${VCS}" = "git"; then
478
+            ${VCS}2cl > ChangeLog
479
+        elif test -n "${VCS}"; then
480
+            ${VCS}2cl
481
+        fi
456 482
     fi
457 483
     if test $exists -eq 0; then
458
-        run ${VCS} add ChangeLog
484
+        if test -n "${VCS}" -a $novcs -eq 0 && ! contains "ChangeLog" "${excludevcs[@]}"; then
485
+            run ${VCS} add ChangeLog
486
+        fi
459 487
     fi
460 488
 }
461 489
 
462 490
 # Check if we are in subversion root, if so, create trunk, branches, tags:
463
-if test "${VCS}" = "svn"; then
491
+if test "${VCS}" = "svn" -a $novcs -eq 0; then
464 492
     if test "$(LANG= svn info | sed -n 's,Relative URL: *,,p')" = "^/"; then
465 493
         svn mkdir trunk branches tags
466 494
         cd trunk
@@ -771,7 +799,9 @@ ${HEADER}dist_bin_SCRIPTS =
771 799
 MAINTAINERCLEANFILES = makefile.in
772 800
 EOF
773 801
 echo "${HEADER}MAINTAINERCLEANFILES = makefile.in" | to --condition AX_USE_DOXYGEN doc/makefile.am
774
-to --condition AX_BUILD_TEST test/runtests.sh < ${0%/*}/test/runtests.sh
802
+if testtag AX_BUILD_TEST; then
803
+    to test/runtests.sh < ${0%/*}/test/runtests.sh
804
+fi
775 805
 to --condition 'AX_BUILD_TEST|AX_USE_CPPUNIT' test/makefile.am <<EOF
776 806
 ${HEADER}$(if testtag AX_USE_CXX; then
777 807
 cat <<EOF2
@@ -809,9 +839,11 @@ if testtag AX_USE_DOXYGEN; then
809 839
         contains doc/doxyfile.in "${rebuildfiles[@]}"; then
810 840
         run doxygen -g doc/doxyfile.in
811 841
         if test $exists -eq 0; then
812
-            run ${VCS} add doc/doxyfile.in
813
-            if test "${VCS}" = "svn"; then
814
-                run svn propset svn:keywords "Id" doc/doxyfile.in
842
+            if test -n "${VCS}" -a $novcs -eq 0 && ! contains "doc/doxyfile" "${excludevcs[@]}"; then
843
+                run ${VCS} add doc/doxyfile.in
844
+                if test "${VCS}" = "svn"; then
845
+                    run svn propset svn:keywords "Id" doc/doxyfile.in
846
+                fi
815 847
             fi
816 848
         fi
817 849
         doxyreplace PROJECT_NAME "@PACKAGE_NAME@"
@@ -892,7 +924,7 @@ if testtag AX_USE_DEBIAN_PACKAGING; then
892 924
 
893 925
  -- @AUTHOR@  @BUILD_DATE@
894 926
 EOF
895
-    BUILD_DEPENDS="debhelper, ${VCSDEPENDS}, pkg-config, automake, libtool, autotools-dev, lsb-release $(if testtag AX_USE_DOXYGEN; then echo -n ", doxygen, graphviz, mscgen"; fi; if testtag AX_USE_CPPUNIT; then echo -n ", libcppunit-dev"; fi; if testtag AX_CXX_QT || testtag AX_CHECK_QT AX_REQUIRE_QT; then echo -n ", qt5-default | libqt4-core | libqtcore4, qt5-qmake | qt4-qmake, qtbase5-dev | libqt4-dev, qtbase5-dev-tools | qt4-dev-tools, qttools5-dev-tools | qt4-dev-tools, qttools5-dev-tools | qt4-dev-tools"; fi)"
927
+    BUILD_DEPENDS="debhelper, ${VCSDEPENDS} pkg-config, automake, libtool, autotools-dev, lsb-release $(if testtag AX_USE_DOXYGEN; then echo -n ", doxygen, graphviz, mscgen"; fi; if testtag AX_USE_CPPUNIT; then echo -n ", libcppunit-dev"; fi; if testtag AX_CXX_QT || testtag AX_CHECK_QT AX_REQUIRE_QT; then echo -n ", qt5-default | libqt4-core | libqtcore4, qt5-qmake | qt4-qmake, qtbase5-dev | libqt4-dev, qtbase5-dev-tools | qt4-dev-tools, qttools5-dev-tools | qt4-dev-tools, qttools5-dev-tools | qt4-dev-tools"; fi)"
896 928
     to debian/control.in <<EOF
897 929
 Source: @PACKAGE_NAME@
898 930
 Priority: extra
@@ -963,7 +995,7 @@ else
963 995
 fi)
964 996
 Source0: %{name}-%{version}.tar.gz
965 997
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
966
-BuildRequires: gnupg, ${VCSDEPENDS}, automake, autoconf$(
998
+BuildRequires: gnupg, ${VCSDEPENDS} make, automake, autoconf, rpm-build$(
967 999
     if testtag AX_USE_DOXYGEN; then
968 1000
       echo -n ", doxygen";
969 1001
     fi)
@@ -1091,12 +1123,31 @@ for d in src test scripts doc examples html; do
1091 1123
         SUBDIRS="${SUBDIRS} $d"
1092 1124
     fi
1093 1125
 done
1126
+to --mode "u=rwx,g=rwx,o=rx" autogen.sh <<EOF
1127
+#!/bin/bash -e
1128
+if test -n "$VCS" -a -d .$VCS -a -e -x $(which ${VCS}2cl); then
1129
+$(case "$VCS" in
1130
+  (svn) echo "    ${VCS}2cl";;
1131
+  (git) echo "    ${VCS}2cl > ChangeLog";;
1132
+esac)
1133
+fi
1134
+aclocal
1135
+$(if testtag AX_USE_LIBTOOL; then echo libtoolize --force; fi)
1136
+automake -a
1137
+autoconf
1138
+EOF
1094 1139
 to makefile.am<<EOF
1095 1140
 ${HEADER}SUBDIRS =${SUBDIRS}
1096 1141
 
1097 1142
 desktopdir = \${datadir}/applications
1098 1143
 desktop_DATA = @PACKAGE_DESKTOP@
1099
-dist_pkgdata_DATA = @PACKAGE_ICON@
1144
+dist_pkgdata_DATA = @PACKAGE_ICON@ ax_check_qt.m4 bootstrap.sh		\\
1145
+                    resolve-rpmbuilddeps.sh autogen.sh			\\
1146
+                    ax_cxx_compile_stdcxx_11.m4 build-in-docker.sh	\\
1147
+                    build-resource-file.sh				\\
1148
+                    ax_init_standard_project.m4				\\
1149
+                    mac-create-app-bundle.sh resolve-debbuilddeps.sh    \\
1150
+                    sql-to-dot.sed
1100 1151
 dist_doc_DATA = AUTHORS NEWS README COPYING INSTALL ChangeLog
1101 1152
 
1102 1153
 MAINTAINERCLEANFILES = makefile.in
@@ -1115,6 +1166,12 @@ Libs: -L\${libdir} -l${PACKAGE_NAME#lib} @LDFLAGS@
1115 1166
 Cflags: -I\${includedir} @CPPFLAGS@
1116 1167
 Requires: @PKG_REQUIREMENTS@
1117 1168
 EOF
1169
+to build-in-docker.conf <<EOF
1170
+repos+=("Debian|Ubuntu-precise::::::universe")
1171
+repos+=("Ubuntu-precise:::'deb http://archive.ubuntu.com/ubuntu precise universe'")
1172
+envs+=("-e 'HOME=\${HOME}'")
1173
+dirs+=("-v \${HOME}/.gnupg:\${HOME}/.gnupg:ro")
1174
+EOF
1118 1175
 
1119 1176
 #### Cleanup If Makefile Exists ####
1120 1177
 if test -f makefile; then
@@ -1130,15 +1187,15 @@ run autoconf
1130 1187
 
1131 1188
 #### Run Configure If User Requires ####
1132 1189
 if test "$configure" -eq 1; then
1133
-    ./configure $*
1190
+    ./configure $* || exit 1
1134 1191
 fi
1135 1192
 
1136 1193
 #### Run Make If User Requires ####
1137 1194
 if test "$build" -eq 1; then
1138
-    make $buildtarget
1195
+    make $buildtarget || exit 1
1139 1196
 fi
1140 1197
 
1141 1198
 #### Build In Docker If User Requires ####
1142 1199
 if test "$docker" -eq 1; then
1143
-    ./build-in-docker.sh
1200
+    ./build-in-docker.sh || exit 1
1144 1201
 fi

+ 82
- 23
build-in-docker.sh View File

@@ -2,6 +2,7 @@
2 2
 set -o errtrace
3 3
 
4 4
 # build and test everything in a fresh docker installation
5
+mode="apt"
5 6
 img="ubuntu:latest"
6 7
 repos=()
7 8
 keys=()
@@ -10,6 +11,7 @@ dirs=("-v $(pwd):/workdir")
10 11
 packages=()
11 12
 targets="all check distcheck"
12 13
 commands=()
14
+wait=0
13 15
 if test -e ./build-in-docker.conf; then
14 16
     # you can preconfigure the variables in file build-in-docker.conf
15 17
     # if you do so, add the file to EXTRA_DIST in makefile.am
@@ -23,6 +25,7 @@ while test $# -gt 0; do
23 25
             echo "OPTIONS:"
24 26
             echo
25 27
             echo "  -h, --help            show this help"
28
+            echo "  -m, --mode <type>     mode: apt or yum, default: ${mode}"
26 29
             echo "  -i, --image <image>   use given docker image instead of ${img}"
27 30
             echo "  -t, --targets targets specify build targets, default: ${targets}"
28 31
             echo "  -r, --repo <url>      add given apt repository"
@@ -31,6 +34,9 @@ while test $# -gt 0; do
31 34
             echo "  -d, --dir <dir>       access given directory read only"
32 35
             echo "  -p, --package <pkg>   install extra debian packages"
33 36
             echo "  -c, --cmd <command>   execute commands as root in docker"
37
+            echo "  -w, --wait            on error keep docker container and wait for enter"
38
+            echo
39
+            echo "  The option -i must be after -m, because mode sets a new default image"
34 40
             echo
35 41
             echo "  The options -r -k -e -d -p -c can be repeated several times."
36 42
             echo
@@ -58,6 +64,17 @@ while test $# -gt 0; do
58 64
             echo
59 65
             exit 0
60 66
             ;;
67
+        (-m|--mode) shift;
68
+            mode="$1"
69
+            case "$mode" in
70
+                (apt) img="ubuntu:latest";;
71
+                (yum) img="centos:latest";;
72
+                (*)
73
+                    echo "**** ERROR: unknown mode '$1', try --help" 1>&2
74
+                    exit 1
75
+                    ;;
76
+            esac
77
+            ;;
61 78
         (-i|--image) shift;
62 79
             img="$1"
63 80
             ;;
@@ -82,6 +99,9 @@ while test $# -gt 0; do
82 99
         (-c|--cmd) shift;
83 100
             commands+=("$1")
84 101
             ;;
102
+        (-w|--wait)
103
+            wait=1
104
+            ;;
85 105
         (*)
86 106
             echo "**** ERROR: unknown option '$1', try --help" 1>&2
87 107
             exit 1
@@ -113,7 +133,12 @@ function traperror() {
113 133
                 fi
114 134
                 echo
115 135
             fi
116
-            echo "**** Entering docker container ${DOCKER_ID}, exit with Ctrl-D"
136
+            if [ "$wait" -eq 1 ]; then
137
+                echo "  ... now you can access the docker container:"
138
+                echo "      docker exec -u $(id -u) -it ${DOCKER_ID} bash"
139
+                echo -n "  ... press enter to cleanup: "
140
+                read
141
+            fi
117 142
             echo -n "   ... cleanup docker: "
118 143
             docker rm -f "${DOCKER_ID}"
119 144
             echo "returning status: $e"
@@ -121,6 +146,12 @@ function traperror() {
121 146
             exit $e
122 147
         fi
123 148
     done
149
+    if [ "$wait" -eq 1 ]; then
150
+        echo "  ... now you can access the docker container:"
151
+        echo "      docker exec -u $(id -u) -it ${DOCKER_ID} bash"
152
+        echo -n "  ... press enter to cleanup: "
153
+        read
154
+    fi
124 155
     echo -n "   SUCCESS ... cleanup docker: "
125 156
     docker rm -f "${DOCKER_ID}"
126 157
     exit 0
@@ -154,25 +185,53 @@ set -x
154 185
 docker pull $img
155 186
 DOCKER_ID=$(docker run -d ${dirs[@]} ${envs[@]} -w /workdir $img sleep infinity)
156 187
 trap 'traperror '"${DOCKER_ID}"' "$? ${PIPESTATUS[@]}" $LINENO $BASH_LINENO "$BASH_COMMAND" "${FUNCNAME[@]}" "${FUNCTION}"' SIGINT INT TERM EXIT
157
-docker exec ${DOCKER_ID} apt-get update
158
-docker exec ${DOCKER_ID} apt-get upgrade -y
159
-docker exec ${DOCKER_ID} apt-get install -y python-software-properties software-properties-common apt-transport-https dpkg-dev lsb-release || \
160
-    docker exec ${DOCKER_ID} apt-get install -y software-properties-common apt-transport-https dpkg-dev lsb-release || \
161
-    docker exec ${DOCKER_ID} apt-get install -y python-software-properties apt-transport-https dpkg-dev lsb-release;
162
-for repo in "${repos[@]}"; do
163
-    ifthenelse "${repo}" "apt-add-repository ARG"
164
-done
165
-for key in "${keys[@]}"; do
166
-    wget -O- "$key" \
167
-        | docker exec -i ${DOCKER_ID} apt-key add -
168
-done
169
-docker exec ${DOCKER_ID} apt-get update
170
-for package in "${packages[@]}"; do
171
-    ifthenelse "${package}" "apt-get install -y --force-yes ARG"
172
-done
173
-for command in "${commands[@]}"; do
174
-    ifthenelse "${command}" "ARG"
175
-done
176
-docker exec ${DOCKER_ID} ./resolve-debbuilddeps.sh
177
-docker exec -u $(id -u) ${DOCKER_ID} svn upgrade || true
178
-docker exec -u $(id -u) ${DOCKER_ID} ./bootstrap.sh -t "${targets}"
188
+case $mode in
189
+    (apt)
190
+        OPTIONS='-o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confnew -y --force-yes --no-install-suggests --no-install-recommends'
191
+        for f in 'libpam-systemd:amd64' 'policykit*' 'colord'; do
192
+            docker exec ${DOCKER_ID} bash -c "echo 'Package: $f' >> /etc/apt/preferences"
193
+            docker exec ${DOCKER_ID} bash -c "echo 'Pin-Priority: -100' >> /etc/apt/preferences"
194
+            docker exec ${DOCKER_ID} bash -c "echo >> /etc/apt/preferences"
195
+        done
196
+        docker exec ${DOCKER_ID} apt-get update ${OPTIONS}
197
+        docker exec ${DOCKER_ID} apt-get upgrade ${OPTIONS}
198
+        docker exec ${DOCKER_ID} apt-get install ${OPTIONS} python-software-properties software-properties-common apt-transport-https dpkg-dev lsb-release || \
199
+            docker exec ${DOCKER_ID} apt-get install ${OPTIONS} software-properties-common apt-transport-https dpkg-dev lsb-release || \
200
+            docker exec ${DOCKER_ID} apt-get install ${OPTIONS} python-software-properties apt-transport-https dpkg-dev lsb-release;
201
+        for repo in "${repos[@]}"; do
202
+            ifthenelse "${repo}" "apt-add-repository ARG"
203
+        done
204
+        for key in "${keys[@]}"; do
205
+            wget -O- "$key" \
206
+                | docker exec -i ${DOCKER_ID} apt-key add -
207
+        done
208
+        docker exec ${DOCKER_ID} apt-get update ${OPTIONS}
209
+        for package in "${packages[@]}"; do
210
+            ifthenelse "${package}" "apt-get install ${OPTIONS} ARG"
211
+        done
212
+        for command in "${commands[@]}"; do
213
+            ifthenelse "${command}" "ARG"
214
+        done
215
+        docker exec ${DOCKER_ID} ./resolve-debbuilddeps.sh
216
+        ;;
217
+    (yum)
218
+        ./bootstrap.sh -t dist
219
+        if [[ "$img" =~ "centos" ]]; then
220
+            docker exec ${DOCKER_ID} yum install -y redhat-lsb
221
+            docker exec -i ${DOCKER_ID} bash -c 'cat > /etc/yum.repos.d/wandisco-svn.repo' <<EOF
222
+[WandiscoSVN]
223
+name=Wandisco SVN Repo
224
+EOF
225
+            docker exec -i ${DOCKER_ID} bash -c 'echo "baseurl=http://opensource.wandisco.com/centos/$(lsb_release -sr | sed '"'"'s,[^0-9].*,,'"'"')/svn-'$(svn --version | head -1 | sed 's,[^0-9]*\([0-9]\+\.[0-9]\+\).*,\1,')'/RPMS/$(uname -i)/" >> /etc/yum.repos.d/wandisco-svn.repo'
226
+            docker exec -i ${DOCKER_ID} bash -c 'cat >> /etc/yum.repos.d/wandisco-svn.repo' <<EOF
227
+enabled=1
228
+gpgcheck=0
229
+EOF
230
+        fi
231
+        docker exec ${DOCKER_ID} yum install -y rpm-build 
232
+        docker exec ${DOCKER_ID} groupadd -g $(id -g) build
233
+        docker exec ${DOCKER_ID} useradd -g $(id -g) -u $(id -u) build
234
+        docker exec ${DOCKER_ID} ./resolve-rpmbuilddeps.sh || true
235
+        ;;
236
+esac
237
+docker exec -u $(id -u):$(id -g) ${DOCKER_ID} ./bootstrap.sh -t "${targets}"

+ 1
- 1
resolve-debbuilddeps.sh View File

@@ -35,7 +35,7 @@ TO_INSTALL=
35 35
 
36 36
 if test -e debian/control.in -a ! -e debian/control; then
37 37
     for f in $(sed -n 's, *AX_DEB_DEPEND_IFEXISTS(\([^)]*\)).*,\1,p' configure.ac); do
38
-        if test -n "$(${DO} apt-cache policy -q ${f})" && ! ${DO} dpkg -l "${f}"; then
38
+        if test -n "$(${DO} apt-cache policy -q ${f})" && ! "$(${DO} apt-cache policy ${f} 2>&1 | grep -q 'N: Unable to locate package')" && ! ${DO} dpkg -l "${f}"; then
39 39
             TO_INSTALL+=" ${f}"
40 40
         fi
41 41
     done

+ 14
- 3
resolve-rpmbuilddeps.sh View File

@@ -12,19 +12,30 @@
12 12
 
13 13
 SCHROOTNAME="$1"
14 14
 PACKAGE_NAME=$(sed -n 's/^ *m4_define(x_package_name, \(.*\)).*/\1/p' configure.ac)
15
+PKGCONFIGS="${2:-epel-release}" # packages to configure yum
15 16
 
16 17
 if test -n "${SCHROOTNAME}"; then
17
-    schroot -c ${SCHROOTNAME} -- ./bootstrap.sh -t dist
18 18
     FILES=$(LANG= schroot -c ${SCHROOTNAME} -- rpmbuild -bb --clean --nobuild --define "_topdir ." --define "_sourcedir ." ${PACKAGE_NAME}.spec  2>&1 | sed -n 's, is needed by.*,,p')
19 19
     if test -n "${FILES}"; then
20
+        FIRST=$(echo "${FILES}" | egrep -o "${PKGCONFIGS// /|}")
21
+        if test -n "${FIRST}"; then
22
+            schroot -c ${SCHROOTNAME} -u root -- yum install -y ${FIRST} || \
23
+                schroot -c ${SCHROOTNAME} -u root -- zypper install -y ${FIRST} || \
24
+                schroot -c ${SCHROOTNAME} -u root -- dnf install -y ${FIRST}
25
+        fi
20 26
         schroot -c ${SCHROOTNAME} -u root -- yum install -y ${FILES} || \
21 27
             schroot -c ${SCHROOTNAME} -u root -- zypper install -y ${FILES} || \
22
-        schroot -c ${SCHROOTNAME} -u root -- dnf install -y ${FILES}
28
+            schroot -c ${SCHROOTNAME} -u root -- dnf install -y ${FILES}
23 29
     fi
24 30
 else
25
-    ./bootstrap.sh -t dist
26 31
     FILES=$(LANG= rpmbuild -bb --clean --nobuild --define "_topdir ." --define "_sourcedir ." ${PACKAGE_NAME}.spec 2>&1 | sed -n 's, is needed by.*,,p')
27 32
     if test -n "${FILES}"; then
33
+        FIRST=$(echo "${FILES}" | egrep -o "${PKGCONFIGS// /|}")
34
+        if test -n "${FIRST}"; then
35
+            yum install -y ${FIRST} || \
36
+                zypper install -y ${FIRST} || \
37
+                dnf install -y ${FIRST}
38
+        fi
28 39
         yum install -y ${FILES} || \
29 40
             zypper install -y ${FILES} || \
30 41
             dnf install -y ${FILES}

Loading…
Cancel
Save