Browse Source

fix output for mac

master
Marc Wäckerlin 1 year ago
parent
commit
36677df6f0
9 changed files with 743 additions and 155 deletions
  1. 18
    5
      ax_check_qt.m4
  2. 83
    32
      ax_init_standard_project.m4
  3. 184
    95
      bootstrap.sh
  4. 23
    11
      build-in-docker.sh
  5. 171
    0
      dependency-graph.sh
  6. 1
    1
      examples/makefile.am
  7. 50
    3
      resolve-debbuilddeps.sh
  8. 54
    8
      resolve-rpmbuilddeps.sh
  9. 159
    0
      template.sh

+ 18
- 5
ax_check_qt.m4 View File

@@ -230,6 +230,7 @@ AC_DEFUN([AX_CHECK_QT], [
230 230
   AC_SUBST(CXXFLAGS)
231 231
   AC_SUBST(PKG_REQUIREMENTS)
232 232
   AX_ADDITIONAL_QT_RULES_HACK='
233
+#### Begin: Appended by $0
233 234
 
234 235
 LANGUAGE_FILE_BASE ?= translations
235 236
 
@@ -241,7 +242,6 @@ moc_%.cxx: %.hxx
241 242
 
242 243
 qrc_%.cxx: %.qrc
243 244
 	$(RCC) -o [$][@] -name ${<:%.qrc=%} $<
244
-  AC_SUBST(AX_ADDITIONAL_QT_RULES_HACK)
245 245
 
246 246
 #%.qrc: %
247 247
 #	cwd=$$(pwd) && cd $< && $(RCC) -project -o $${cwd}/[$][@]
@@ -249,12 +249,15 @@ qrc_%.cxx: %.qrc
249 249
 %.qm: %.ts
250 250
 	${LRELEASE} $< -qm [$][@]
251 251
 
252
-%.ts: ${LANGUAGE_FILES:%=%}
252
+%.ts: ${LANGUAGE_FILES}
253 253
 	${LUPDATE} -no-obsolete \
254
-	           -target-language ${@:${LANGUAGE_FILE_BASE}_%.ts=%} \
255
-	           -ts [$][@] $<
254
+	           -target-language [$]{@:${LANGUAGE_FILE_BASE}_%.ts=%} \
255
+                   [$][^] \
256
+	           -ts [$][@]
256 257
 
257
-'])
258
+#### End: $0
259
+'
260
+])
258 261
 
259 262
 AC_DEFUN([AX_REQUIRE_QT], [
260 263
   AX_CHECK_QT([$1], [$2], [$3], [$4])
@@ -269,3 +272,13 @@ AC_DEFUN([AX_REQUIRE_QT], [
269 272
 AC_DEFUN([AX_QT_NO_KEYWORDS], [
270 273
   CPPFLAGS+=" -DQT_NO_KEYWORDS"
271 274
 ])
275
+
276
+AC_DEFUN([AX_INIT_QT], [
277
+  if test -n "${AX_ADDITIONAL_QT_RULES_HACK}"; then
278
+    for f in $(find test examples src -name makefile.in); do
279
+      test -f "$f" && cat >> "$f" <<EOF
280
+${AX_ADDITIONAL_QT_RULES_HACK}    
281
+EOF
282
+    done
283
+  fi
284
+])

+ 83
- 32
ax_init_standard_project.m4 View File

@@ -90,7 +90,7 @@ dnl refers to ${prefix}.  Thus we have to use `eval' twice.
90 90
 #     $3 = filename of makefile.in
91 91
 AC_DEFUN([AX_ADD_MAKEFILE_TARGET_DEP], [
92 92
   sh_add_makefile_target_dep() {
93
-    sed -i -e ':a;/^'${1}':.*\\$/{N;s/\\\n//;ta};s/^'${1}':.*$/& '${2}'/' "${srcdir}/${3}"
93
+    sed -i -e ':a;/^'${1}':.*\\$/{N;s/\\\n//;ta};s/^'"${1}"':.*$/& '"${2}"'/' "${srcdir}/${3}"
94 94
     if ! egrep -q "${1}:.* ${2}" "${srcdir}/${3}"; then
95 95
         echo "${1}: ${2}" >> "${srcdir}/${3}"
96 96
     fi
@@ -171,7 +171,7 @@ AC_DEFUN([AX_INIT_STANDARD_PROJECT], [
171 171
   AX_SUBST(HOME)
172 172
   if test -f README.md; then
173 173
     README=$(tail -n +3 README.md)
174
-    DESCRIPTION=$(head -1 README.md)
174
+    DESCRIPTION=$(head -1 README.md | sed 's,^#\+ *,,;s, *#\+$,,')
175 175
   else
176 176
     README=$(tail -n +3 README)
177 177
     DESCRIPTION=$(head -1 README)
@@ -456,6 +456,12 @@ AC_DEFUN([AX_USE_NODEJS], [
456 456
                          [${PATH}${PATH_SEPARATOR}${ANDROID_HOME}/tools])
457 457
   AC_CONFIG_FILES([nodejs/package.json])
458 458
   AC_CONFIG_FILES([nodejs/makefile])
459
+  if test -z "${DEB_SECTION}"; then
460
+    AX_DEB_SECTION([web])
461
+  fi
462
+  if test -z "${RPM_GROUP}"; then
463
+    AX_RPM_GROUP([Applications/Internet])
464
+  fi
459 465
   AX_ADD_MAKEFILE_TARGET_DEP([maintainer-clean-am], [maintainer-clean-nodejs-targets], [nodejs/makefile.in])
460 466
   test -f nodejs/makefile.in && cat >> nodejs/makefile.in <<EOF
461 467
 #### Begin: Appended by $0
@@ -494,6 +500,12 @@ EOF
494 500
 # use this in configure.ac to support HTML data for webservers
495 501
 AC_DEFUN([AX_BUILD_HTML], [
496 502
   AC_CONFIG_FILES([html/makefile])
503
+  if test -z "${DEB_SECTION}"; then
504
+    AX_DEB_SECTION([web])
505
+  fi
506
+  if test -z "${RPM_GROUP}"; then
507
+    AX_RPM_GROUP([Applications/Internet])
508
+  fi
497 509
   AX_ADD_MAKEFILE_TARGET_DEP([maintainer-clean-am], [maintainer-clean-html-targets], [html/makefile.in])
498 510
   test -f html/makefile.in && cat >> html/makefile.in <<EOF
499 511
 #### Begin: Appended by $0
@@ -521,6 +533,12 @@ AC_DEFUN([AX_USE_LIBTOOL], [
521 533
   AC_SUBST(LIB_VERSION)
522 534
   AC_PROG_LIBTOOL
523 535
   AC_CONFIG_FILES([src/${PACKAGE_NAME}.pc])
536
+  if test -z "${DEB_SECTION}"; then
537
+    AX_DEB_SECTION([devel])
538
+  fi
539
+  if test -z "${RPM_GROUP}"; then
540
+    AX_RPM_GROUP([Development/Libraries])
541
+  fi
524 542
   AX_ADD_MAKEFILE_TARGET_DEP([install-data-am], [install-data-libtool-pkg], [src/makefile.in])
525 543
   AX_ADD_MAKEFILE_TARGET_DEP([uninstall-am], [uninstall-data-am], [src/makefile.in])
526 544
   AX_ADD_MAKEFILE_TARGET_DEP([uninstall-data-am], [uninstall-data-libtool-pkg], [src/makefile.in])
@@ -538,7 +556,11 @@ EOF
538 556
 ])
539 557
 
540 558
 # use this in configure.ac to support debian packages
559
+#  - $1: optional debian package section
541 560
 AC_DEFUN([AX_USE_DEBIAN_PACKAGING], [
561
+  if test -n "$1"; then
562
+    AX_DEB_SECTION([$1])
563
+  fi
542 564
   if test -f README.md; then
543 565
     README_DEB=$(tail -n +3 README.md | sed -e 's/^ *$/./g' -e 's/^/ /g')
544 566
   else
@@ -563,7 +585,11 @@ EOF
563 585
 ])
564 586
 
565 587
 # use this in configure.ac to support RPM packages
588
+#  - $1: optional rpm package group
566 589
 AC_DEFUN([AX_USE_RPM_PACKAGING], [
590
+  if test -n "$1"; then
591
+    AX_RPM_GROUP([$1])
592
+  fi
567 593
   AC_CONFIG_FILES([${PACKAGE_NAME}.spec])
568 594
   #AX_ADD_MAKEFILE_TARGET_DEP([clean-am], [clean-rpm-targets], [makefile.in])
569 595
   AX_ADD_MAKEFILE_TARGET_DEP([clean-am], [clean-rpm-targets], [makefile.in])
@@ -718,12 +744,10 @@ EOF
718 744
 #     $5 = optional flags:
719 745
 #            manualflags if CXXFLAGS, CPPFLAGS, LIBS should remain unchanged
720 746
 #     $6 = optional parameters, allowed are (evaluated in this order):
721
-#           - RPM_DIST_PKG=<name>
722
-#             special name for the RPM package
723
-#           - DEB_DIST_PKG=<name>
724
-#             special name for the debian package
725
-#           - DIST_PKG=<name>
726
-#             if the name of the package is different
747
+#           - DEV_RPM_DIST_PKG=<name>
748
+#             special name for the RPM development package
749
+#           - DEV_DEB_DIST_PKG=<name>
750
+#             special name for the debian development package
727 751
 #           - DEV_DIST_PKG=<name>
728 752
 #             if the name of the development package is different
729 753
 #
@@ -735,11 +759,6 @@ EOF
735 759
 AC_DEFUN([AX_PKG_REQUIRE], [
736 760
   PKG_PROG_PKG_CONFIG
737 761
   optional_flags="$5"
738
-  $6
739
-  if test -n "$DEV_DIST_PKG"; then
740
-    DEV_DEB_DIST_PKG=${DEV_DIST_PKG}-dev
741
-    DEV_RPM_DIST_PKG=${DEV_DIST_PKG}-devel
742
-  fi
743 762
   $1_found=no
744 763
   secondpar="m4_default([$2], [$1])"
745 764
   PKG_CHECK_MODULES([$1], [m4_default([$2], [$1])], [
@@ -819,10 +838,6 @@ AC_DEFUN([AX_PKG_REQUIRE], [
819 838
       AC_MSG_ERROR([Feature $1 not found please install module $secondpar])
820 839
     fi
821 840
   fi
822
-  AX_DEB_BUILD_DEPEND([${DEV_DEB_DIST_PKG:-${DEB_DIST_PKG:-${DIST_PKG:-${$1_found}-dev}}}])
823
-  AX_RPM_BUILD_DEPEND([${DEV_RPM_DIST_PKG:-${RPM_DIST_PKG:-${DIST_PKG:-${$1_found}-devel}}}])
824
-  AX_DEB_DEPEND([${DEB_DIST_PKG:-${DIST_PKG:-${$1_found}}}])
825
-  AX_RPM_DEPEND([${RPM_DIST_PKG:-${DIST_PKG:-${$1_found}}}])
826 841
   [$1]_CPPFLAGS="${$1_CFLAGS}"
827 842
   [$1]_CXXFLAGS="${$1_CFLAGS}"
828 843
   AC_SUBST([$1]_CPPFLAGS)
@@ -835,6 +850,33 @@ AC_DEFUN([AX_PKG_REQUIRE], [
835 850
   else
836 851
     AC_MSG_NOTICE([To enable $1, add $1_CPPFLAGS, $1_CXXFLAGS and $1_LIBS])
837 852
   fi
853
+  
854
+  DEV_DEB_DIST_PKG=
855
+  DEV_RPM_DIST_PKG=
856
+  DEV_DIST_PKG=
857
+  pkg=m4_default([$2], [$1])
858
+  $6
859
+  dep_pkg=${DEV_DEB_DIST_PKG:-${DEV_DIST_PKG:-${pkg}}-dev}
860
+  rpm_pkg=${DEV_RPM_DIST_PKG:-${DEV_DIST_PKG:-${pkg}}-devel}
861
+  if test -n "$4"; then
862
+    for f in $pkg $4; do
863
+      if test -n "$(apt-cache policy -q ${f}-dev 2> /dev/null)"; then
864
+        deb_pkg=${f}-dev
865
+        break
866
+      fi
867
+    done
868
+    for f in $pkg $4; do
869
+      if (test -x /usr/bin/zypper && zypper search -x "${f}-devel" 1>&2 > /dev/null) || \
870
+            (test -x /usr/bin/dnf && dnf list -q "${f}-devel" 1>&2 > /dev/null) || \
871
+            (test -x /usr/bin/yum && yum list -q "${f}-devel" 1>&2 > /dev/null) || \
872
+            (test -x /usr/sbin/urpmq && urpmq "${f}-devel" 1>&2 > /dev/null); then
873
+        rpm_pkg=${f}-devel
874
+        break
875
+      fi
876
+    done
877
+  fi
878
+  AX_DEB_BUILD_DEPEND([$deb_pkg])
879
+  AX_RPM_BUILD_DEPEND([$rpm_pkg])
838 880
 ])
839 881
 
840 882
 # check if a specific package exists
@@ -844,12 +886,10 @@ AC_DEFUN([AX_PKG_REQUIRE], [
844 886
 #     $3 = optional flags:
845 887
 #          manualflags if CXXFLAGS, CPPFLAGS, LIBS should remain unchanged
846 888
 #     $4 = optional parameters, allowed are (evaluated in this order):
847
-#           - RPM_DIST_PKG=<name>
848
-#             special name for the RPM package
849
-#           - DEB_DIST_PKG=<name>
850
-#             special name for the debian package
851
-#           - DIST_PKG=<name>
852
-#             if the name of the package is different
889
+#           - DEV_RPM_DIST_PKG=<name>
890
+#             special name for the RPM development package
891
+#           - DEV_DEB_DIST_PKG=<name>
892
+#             special name for the debian development package
853 893
 #           - DEV_DIST_PKG=<name>
854 894
 #             if the name of the development package is different
855 895
 #
@@ -858,11 +898,6 @@ AC_DEFUN([AX_PKG_REQUIRE], [
858 898
 # sets all flags, so that the module can be used everywhere
859 899
 AC_DEFUN([AX_PKG_CHECK], [
860 900
   optional_flags="$3"
861
-  $4
862
-  if test -n "$DEV_DIST_PKG"; then
863
-    DEV_DEB_DIST_PKG=${DEV_DIST_PKG}-dev
864
-    DEV_RPM_DIST_PKG=${DEV_DIST_PKG}-devel
865
-  fi
866 901
   PKG_PROG_PKG_CONFIG
867 902
   PKG_CHECK_MODULES([$1], [m4_default([$2], [$1])], [
868 903
     HAVE_$1=1
@@ -886,15 +921,29 @@ AC_DEFUN([AX_PKG_CHECK], [
886 921
   ], [
887 922
     HAVE_$1=0
888 923
   ])
889
-  AX_DEB_BUILD_DEPEND([${DEV_DEB_DIST_PKG:-${DEB_DIST_PKG:-${DIST_PKG:-m4_default([$2], [$1])-dev}}}])
890
-  AX_RPM_BUILD_DEPEND([${DEV_RPM_DIST_PKG:-${RPM_DIST_PKG:-${DIST_PKG:-m4_default([$2], [$1])-devel}}}])
891
-  AX_DEB_DEPEND([${DEB_DIST_PKG:-${DIST_PKG:-m4_default([$2], [$1])}}])
892
-  AX_RPM_DEPEND([${RPM_DIST_PKG:-${DIST_PKG:-m4_default([$2], [$1])}}])
893 924
   AM_CONDITIONAL(HAVE_$1, test $HAVE_[$1] -eq 1)
894 925
   AC_SUBST(HAVE_$1)
895 926
   AC_SUBST(CPPFLAGS)
896 927
   AC_SUBST(CXXFLAGS)
897 928
   AC_SUBST(PKG_REQUIREMENTS)
929
+  
930
+  DEV_DEB_DIST_PKG=
931
+  DEV_RPM_DIST_PKG=
932
+  DEV_DIST_PKG=
933
+  pkg=m4_default([$2], [$1])
934
+  $4
935
+  dep_pkg=${DEV_DEB_DIST_PKG:-${DEV_DIST_PKG:-${pkg}}-dev}
936
+  rpm_pkg=${DEV_RPM_DIST_PKG:-${DEV_DIST_PKG:-${pkg}}-devel}
937
+  if test -n "$(apt-cache policy -q ${deb_pkg} 2> /dev/null)"; then
938
+    AX_DEB_BUILD_DEPEND([$deb_pkg])
939
+  fi
940
+  if (test -x /usr/bin/zypper && zypper search -x "$rpm_pkg" 1>&2 > /dev/null) || \
941
+            (test -x /usr/bin/dnf && dnf list -q "$rpm_pkg" 1>&2 > /dev/null) || \
942
+            (test -x /usr/bin/yum && yum list -q "$rpm_pkg" 1>&2 > /dev/null) || \
943
+            (test -x /usr/sbin/urpmq && urpmq "$rpm_pkg" 1>&2 > /dev/null); then
944
+    AX_RPM_BUILD_DEPEND([$rpm_pkg])
945
+  fi
946
+)
898 947
 ])
899 948
 
900 949
 # make sure, a specific header exists
@@ -1176,7 +1225,9 @@ AC_DEFUN([AX_ALL_DEPEND], [
1176 1225
 
1177 1226
 # finish configuration - to be called instead of AC_OUTPUT
1178 1227
 AC_DEFUN([AX_OUTPUT], [
1228
+  AX_INIT_QT
1179 1229
   AX_DEB_RESOLVE
1180 1230
   AX_RPM_RESOLVE
1181 1231
   AC_OUTPUT
1232
+  AC_MSG_NOTICE([configured for ${PACKAGE_NAME}-${VERSION}])
1182 1233
 ])

+ 184
- 95
bootstrap.sh View File

@@ -138,10 +138,12 @@ GENERATED FILES
138 138
     * build-resource-file.sh - build resource.qrc file from a resource directory
139 139
     * sql-to-dot.sed - script to convert SQL schema files to graphviz dot in doxygen
140 140
     * mac-create-app-bundle.sh - script to create apple mac os-x app-bundle
141
+    * dependency-graph.sh - script to draw project dependencies
142
+    * template.sh - generic template for bash scripts
141 143
     * test/runtests.sh - template file to run test scripts, i.e. docker based
142 144
     * AUTHORS - replace your name in AUTHORS before first run
143 145
     * NEWS - empty file add your project's news
144
-    * README - add project description (first line is header, followed by an empty line)
146
+    * README (or README.md) - add project description (first line: header, followed by empty line)
145 147
     * configure.ac - global configuration file template
146 148
     * makefile.am - global makefile template
147 149
     * ${DEFAULT_PROJECT_NAME}.desktop.in - linux desktop file
@@ -300,7 +302,91 @@ EOF
300 302
     shift;
301 303
 done
302 304
 
303
-echo -en "\e[1m-> checking:\e[0m for version control system ..."
305
+# check if stdout is a terminal...
306
+if test -t 1; then
307
+
308
+    # see if it supports colors...
309
+    ncolors=$(tput colors)
310
+
311
+    if test -n "$ncolors" && test $ncolors -ge 8; then
312
+        bold="$(tput bold)"
313
+        underline="$(tput smul)"
314
+        standout="$(tput smso)"
315
+        normal="$(tput sgr0)"
316
+        black="$(tput setaf 0)"
317
+        red="$(tput setaf 1)"
318
+        green="$(tput setaf 2)"
319
+        yellow="$(tput setaf 3)"
320
+        blue="$(tput setaf 4)"
321
+        magenta="$(tput setaf 5)"
322
+        cyan="$(tput setaf 6)"
323
+        white="$(tput setaf 7)"
324
+    fi
325
+fi
326
+
327
+notice() {
328
+    echo "${yellow}→ notice: ${bold}$*${normal}"
329
+}
330
+
331
+running() {
332
+    echo -n "${bold}${blue}→ running: ${bold}${white}$*${normal} … "
333
+}
334
+
335
+checking() {
336
+    echo -n "${bold}${blue}→ checking: ${bold}${white}$*${normal} … "
337
+}
338
+
339
+generating() {
340
+    echo -n "${bold}${blue}→ generating: ${bold}${white}$*${normal} … "
341
+}
342
+
343
+configuring() {
344
+    echo -n "${bold}${blue}→ configuring ${bold}${white}$1${normal}:"
345
+    shift
346
+    echo -n "${white}$*${normal} … "
347
+}
348
+
349
+ignored() {
350
+    echo "${bold}${yellow}ignored $*${normal}"
351
+}
352
+
353
+success() {
354
+    echo "${bold}${green}success $*${normal}"
355
+}
356
+
357
+error() {
358
+    echo "${bold}${red}→ error: $1${normal}"
359
+    shift
360
+    if test -n "$*"; then
361
+        echo "${bold}$*${normal}"
362
+    fi
363
+    exit 1
364
+}
365
+
366
+run() {
367
+    check=1
368
+    while test $# -gt 0; do
369
+        case "$1" in
370
+            (--no-check) check=0;;
371
+            (*) break;;
372
+        esac
373
+        shift;
374
+    done
375
+    running $*
376
+    result=$($* 2>&1)
377
+    res=$?
378
+    if test $res -ne 0; then
379
+        if test $check -eq 1; then
380
+            error "Failed with return code: $res" "$result"
381
+        else
382
+            ignored
383
+        fi
384
+    else
385
+        success
386
+    fi
387
+}
388
+
389
+checking for version control system
304 390
 VCS=""
305 391
 VCSDEPENDS=""
306 392
 for path in . .. ../.. ../../..; do
@@ -308,18 +394,18 @@ for path in . .. ../.. ../../..; do
308 394
         VCS="svn"
309 395
         VCSDEPENDS_DEB="svn2cl, subversion, subversion-tools,"
310 396
         VCSDEPENDS_RPM="subversion, "
311
-        echo -e " \e[32msuccess\e[0m detected ${VCS}"
397
+        success detected ${VCS}
312 398
         break
313 399
     elif test -d ${path}/.git; then
314 400
         VCS="git"
315 401
         VCSDEPENDS_DEB="git2cl, git,"
316 402
         VCSDEPENDS_RPM="git, "
317
-        echo -e " \e[32msuccess\e[0m detected ${VCS}"
403
+        success detected ${VCS}
318 404
         break
319 405
     fi
320 406
 done
321 407
 if test -z "$VCS"; then
322
-    echo -e " \e[33mignored\e[0m"
408
+    ignored
323 409
 fi
324 410
 
325 411
 HEADER='## @id '"\$Id\$"'
@@ -347,38 +433,6 @@ CHEADER='/** @id '"\$Id\$"'
347 433
 
348 434
 '
349 435
 
350
-notice() {
351
-    echo -e "\e[1;33m$*\e[0m"
352
-}
353
-
354
-run() {
355
-    check=1
356
-    while test $# -gt 0; do
357
-        case "$1" in
358
-            (--no-check) check=0;;
359
-            (*) break;;
360
-        esac
361
-        shift;
362
-    done
363
-    echo -en "\e[1m-> running:\e[0m $* ..."
364
-    result=$($* 2>&1)
365
-    res=$?
366
-    if test $res -ne 0; then
367
-        if test $check -eq 1; then
368
-            echo -e " \e[31merror\e[0m"
369
-            echo -e "\e[1m*** Failed with return code: $res\e[0m"
370
-            if test -n "$result"; then
371
-                echo "$result"
372
-            fi
373
-            exit 1
374
-        else
375
-            echo -e " \e[33mignored\e[0m"
376
-        fi
377
-    else
378
-        echo -e " \e[32msuccess\e[0m"
379
-    fi
380
-}
381
-
382 436
 testtag() {
383 437
     local IFS="|"
384 438
     egrep -q '^ *'"($*)"' *(\(.*)? *$' configure.ac
@@ -431,18 +485,13 @@ to() {
431 485
         return 1
432 486
     fi
433 487
     checkdir "$(dirname ${1})"
434
-    echo -en "\e[1m-> generating:\e[0m $1 ..."
488
+    generating $1
435 489
     result=$(cat > "$1" 2>&1)
436 490
     res=$?
437 491
     if test $res -ne 0; then
438
-        echo -e " \e[31merror\e[0m"
439
-        echo -e "\e[1m*** Failed with return code: $res\e[0m"
440
-        if test -n "$result"; then
441
-            echo "$result"
442
-        fi
443
-        exit 1
492
+        error "Failed with return code: $res" "$result"
444 493
     else
445
-        echo -e " \e[32msuccess\e[0m"
494
+        success
446 495
     fi
447 496
     run chmod $mode $1
448 497
     if test $exists -eq 0; then
@@ -484,24 +533,20 @@ copy() {
484 533
 }
485 534
 
486 535
 doxyreplace() {
487
-    echo -en "\e[1m-> doxyfile:\e[0m configure $1 ..."
536
+    configuring doxyfile $1
488 537
     if sed -i 's|\(^'"$1"' *=\) *.*|\1'" $2"'|g' doc/doxyfile.in; then
489
-        echo -e " \e[32msuccess\e[0m"
538
+        success
490 539
     else
491
-        echo -e " \e[31merror\e[0m"
492
-        echo -e "\e[1m**** command: $0 $*\e[0m"
493
-        exit 1
540
+        error $0 $*
494 541
     fi
495 542
 }
496 543
 
497 544
 doxyadd() {
498
-    echo -en "\e[1m-> doxyfile:\e[0m configure $1 ..."
545
+    configuring  doxyfile $1
499 546
     if sed -i '/^'"$1"' *=/a'"$1"' += '"$2" doc/doxyfile.in; then
500
-        echo -e " \e[32msuccess\e[0m"
547
+        success
501 548
     else
502
-        echo -e " \e[31merror\e[0m"
503
-        echo -e "\e[1m**** command: $0 $*\e[0m"
504
-        exit 1
549
+        error $0 $*
505 550
     fi
506 551
 }
507 552
 
@@ -512,13 +557,18 @@ vcs2cl() {
512 557
     else
513 558
         touch "ChangeLog"
514 559
     fi
560
+    if test -x $(which timeout); then
561
+        local TIMEOUT="timeout 10"
562
+    else
563
+        local TIMEOUT=
564
+    fi
515 565
     if test -x $(which ${VCS}2cl); then
516 566
         if test "${VCS}" = "git"; then
517
-            ${VCS}2cl > ChangeLog
567
+            $TIMEOUT ${VCS}2cl || true > ChangeLog
518 568
         elif test "${VCS}" = "svn"; then
519
-            ${VCS}2cl --break-before-msg -a -i
569
+            $TIMEOUT ${VCS}2cl --break-before-msg -a -i || true
520 570
         elif test -n "${VCS}"; then
521
-            ${VCS}2cl
571
+            $TIMEOUT ${VCS}2cl || true
522 572
         fi
523 573
     fi
524 574
     if test $exists -eq 0; then
@@ -549,6 +599,8 @@ copy rpmsign.exp
549 599
 copy build-resource-file.sh
550 600
 copy sql-to-dot.sed
551 601
 copy mac-create-app-bundle.sh
602
+copy dependency-graph.sh
603
+copy template.sh
552 604
 AUTHOR=$(gpg -K 2>/dev/null | sed -n 's,uid *\(\[ultimate\] *\)\?,,p' | head -1)
553 605
 if test -z "${AUTHOR}"; then
554 606
     AUTHOR="FIRSTNAME LASTNAME (URL) <EMAIL>"
@@ -559,11 +611,18 @@ EOF
559 611
 to NEWS <<EOF && notice "please edit NEWS"
560 612
 $(date) created ${DEFAULT_PROJECT_NAME}
561 613
 EOF
562
-to README <<EOF && notice "please edit README"
614
+if test -e README.md; then
615
+    README=README.md
616
+else
617
+    README=README
618
+    to README <<EOF && notice "please edit README"
619
+
563 620
 ${DEFAULT_PROJECT_NAME}
564 621
 
565 622
 add description for ${DEFAULT_PROJECT_NAME}
566 623
 EOF
624
+fi
625
+DESCRIPTION=$(head -1 $README | sed 's,^#\+ *,,;s, *#\+$,,')
567 626
 to configure.ac <<EOF && notice "please edit configure.ac, then rerun $0" && exit 0
568 627
 ${HEADER}# default is generated from AUTHORS and project name
569 628
 PROJECT_URL=
@@ -1048,7 +1107,7 @@ to --condition AX_USE_NODEJS nodejs/etc/default/${PACKAGE_NAME} <<EOF
1048 1107
 EOF
1049 1108
 to --condition AX_USE_NODEJS nodejs/etc/init/${PACKAGE_NAME}.conf <<EOF
1050 1109
 #!upstart
1051
-description "$(head -1 README)"
1110
+description "$DESCRIPTION"
1052 1111
 author      "$(head -1 AUTHORS)"
1053 1112
 
1054 1113
 start on (local-filesystems and net-device-up)
@@ -1088,7 +1147,7 @@ end script
1088 1147
 EOF
1089 1148
 to --condition AX_USE_NODEJS nodejs/etc/systemd/system/${PACKAGE_NAME}.service <<EOF
1090 1149
 [Unit]
1091
-Description=$(head -1 README)
1150
+Description=$DESCRIPTION
1092 1151
 
1093 1152
 [Service]
1094 1153
 ExecStart=/usr/bin/nodejs /usr/share/${PACKAGE_NAME}/nodejs/${PACKAGE_NAME}
@@ -1216,11 +1275,11 @@ to --condition AX_USE_NODEJS nodejs/views/index.ejs <<EOF
1216 1275
     <link href="stylesheets/style.css" rel="stylesheet" type="text/css" />
1217 1276
     <script type="text/javascript" src="/socket.io/socket.io.js"></script>
1218 1277
     <script type="text/javascript" src="javascripts/${PACKAGE_NAME}.js"></script>
1219
-    <title>$(head -1 README)</title>
1278
+    <title>$DESCRIPTION</title>
1220 1279
   </head>
1221 1280
 
1222 1281
   <body>
1223
-    <h1>$(head -1 README)</h1>
1282
+    <h1>$DESCRIPTION</h1>
1224 1283
     <p>generated by bootstrap, please edit</p>
1225 1284
   </body>
1226 1285
 </html>
@@ -1290,6 +1349,9 @@ ${HEADER}AM_CPPFLAGS = -I\${top_srcdir}/src -I\${top_builddir}/src
1290 1349
 AM_LDFLAGS = -L\${abs_top_builddir}/src/.libs
1291 1350
 LDADD = -l${PACKAGE_NAME#lib}
1292 1351
 
1352
+exampledir = ${docdir}/examples
1353
+example_DATA = 
1354
+
1293 1355
 MAINTAINERCLEANFILES = makefile.in
1294 1356
 EOF
1295 1357
 to --condition AX_BUILD_HTML_NPM html/package.json.in <<EOF
@@ -1568,7 +1630,7 @@ EOF2
1568 1630
 EOF
1569 1631
     to debian/docs <<EOF
1570 1632
 NEWS
1571
-README
1633
+$README
1572 1634
 EOF
1573 1635
     to --condition AX_USE_LIBTOOL debian/${PACKAGE_NAME}.install <<EOF
1574 1636
 usr/lib/lib*.so.*
@@ -1613,7 +1675,7 @@ fi)
1613 1675
 $(if testtag AX_RPM_DEPEND; then echo "Requires: @RPM_DEPEND@"; fi)
1614 1676
 Source0: %{name}-%{version}.tar.gz
1615 1677
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
1616
-BuildRequires: which, pkgconfig, gnupg, expect, ${VCSDEPENDS_RPM}make, automake, autoconf, rpm-build$(
1678
+BuildRequires: which, pkgconfig, pandoc, gnupg, expect, ${VCSDEPENDS_RPM}make, automake, autoconf, rpm-build$(
1617 1679
     if testtag AX_USE_CXX; then
1618 1680
       echo -n ", binutils-devel, gcc-c++"
1619 1681
     fi
@@ -1626,15 +1688,19 @@ BuildRequires: which, pkgconfig, gnupg, expect, ${VCSDEPENDS_RPM}make, automake,
1626 1688
     if testtag AX_USE_PERLDOC; then
1627 1689
       echo -n ", libpod-tree-perl";
1628 1690
     fi
1629
-    if testtag AX_REQUIRE_QT || testtag AX_CHECK_QT AX_REQUIRE_QT; then
1630
-      echo -n ", qt-devel, libqt5-qtbase-devel, libqt5-qttools, libQt5WebKit5-devel";
1631
-    fi
1632 1691
 )  @RPM_BUILD_DEPEND@ @RPM_DEPEND_IFEXISTS@
1633 1692
 
1634 1693
 #### os dependent definitions ####
1635 1694
 %if 0%{?suse_version} || 0%{?sles_version}
1636
-BuildRequires: lsb-release
1695
+BuildRequires: lsb-release$(
1696
+    if testtag AX_REQUIRE_QT || testtag AX_CHECK_QT; then
1697
+      echo -n ", libqt5-qtbase-devel, libqt5-qttools, libqt5-linguist-devel, libQt5WebKit5-devel libqt5-qtwebengine-devel libQt5WebKitWidgets-devel";
1698
+    fi)
1637 1699
 %else
1700
+$(
1701
+    if testtag AX_REQUIRE_QT || testtag AX_CHECK_QT; then
1702
+      echo -n "BuildRequires: qt5-qtbase-devel, qt5-qttools-devel, qt5-qtwebkit-devel";
1703
+    fi)
1638 1704
 %if  0%{?mageia}
1639 1705
 BuildRequires: rpm-sign, lsb-release
1640 1706
 %else
@@ -1688,25 +1754,20 @@ rm -rf \$RPM_BUILD_ROOT
1688 1754
 $(if testtag AX_USE_LIBTOOL; then
1689 1755
 echo '/usr/%_lib/*.so.*'
1690 1756
 else
1691
-echo '/usr/bin/*'
1692
-echo '/usr/share/applications/*'
1757
+echo '/usr/bin'
1758
+echo '/usr/share/applications'
1693 1759
 fi)
1694
-$(if testtag AX_USE_NODEJS AX_BUILD_HTML AX_BUILD_HTML_NPM; then
1695
-echo '/usr/share/@PACKAGE_NAME@'
1696
-fi)
1697
-%doc
1698
-$(if testtag AX_USE_LIBTOOL; then
1699
-  cat <<EOF2
1700
-/usr/share/doc/packages/@PACKAGE_NAME@/AUTHORS
1701
-/usr/share/doc/packages/@PACKAGE_NAME@/COPYING
1702
-/usr/share/doc/packages/@PACKAGE_NAME@/ChangeLog
1703
-/usr/share/doc/packages/@PACKAGE_NAME@/INSTALL
1704
-/usr/share/doc/packages/@PACKAGE_NAME@/NEWS
1705
-/usr/share/doc/packages/@PACKAGE_NAME@/README
1760
+/usr/share/@PACKAGE_NAME@
1761
+$(if testtag AX_USE_ETC; then
1762
+
1763
+cat <<EOF2
1764
+%config
1765
+/etc/*
1766
+
1706 1767
 EOF2
1707
-else
1708
-  echo '/usr/share'
1709 1768
 fi)
1769
+%doc
1770
+/usr/share/doc
1710 1771
 
1711 1772
 $(if testtag AX_USE_LIBTOOL; then
1712 1773
 cat <<EOF2
@@ -1776,7 +1837,18 @@ $(case "$VCS" in
1776 1837
 esac)
1777 1838
 fi
1778 1839
 aclocal
1779
-$(if testtag AX_USE_LIBTOOL; then echo libtoolize --force; fi)
1840
+$(if testtag AX_USE_LIBTOOL; then
1841
+cat <<EOF1
1842
+if which libtoolize > /dev/null; then
1843
+  run libtoolize --force;
1844
+elif which glibtoolize > /dev/null; then
1845
+  run glibtoolize --force;
1846
+else
1847
+  echo "error: libtoolize not found" 1>&2
1848
+  exit 1
1849
+fi
1850
+EOF1
1851
+fi)
1780 1852
 automake -a
1781 1853
 autoconf
1782 1854
 EOF
@@ -1785,15 +1857,24 @@ ${HEADER}SUBDIRS =${SUBDIRS}
1785 1857
 
1786 1858
 desktopdir = \${datadir}/applications
1787 1859
 desktop_DATA = @PACKAGE_DESKTOP@
1788
-dist_pkgdata_DATA = @PACKAGE_ICON@ ax_check_qt.m4 bootstrap.sh		\\
1789
-                    resolve-rpmbuilddeps.sh autogen.sh			\\
1860
+dist_pkgdata_DATA = @PACKAGE_ICON@
1861
+dist_noinst_DATA = ax_check_qt.m4 bootstrap.sh				\\
1862
+                   resolve-rpmbuilddeps.sh autogen.sh			\\
1790 1863
                     ax_cxx_compile_stdcxx_11.m4 build-in-docker.sh	\\
1791 1864
                     build-resource-file.sh				\\
1792 1865
                     ax_init_standard_project.m4				\\
1793 1866
                     mac-create-app-bundle.sh resolve-debbuilddeps.sh    \\
1867
+                    dependency-graph.sh template.sh                     \\
1794 1868
                     sql-to-dot.sed
1795
-dist_doc_DATA = AUTHORS NEWS README COPYING INSTALL ChangeLog
1869
+dist_doc_DATA = AUTHORS NEWS $README COPYING INSTALL ChangeLog
1870
+$(if test -e README.md -a ! -e README; then
1871
+cat <<EOF2
1872
+
1873
+README: README.md
1796 1874
 
1875
+CLEANFILES = README
1876
+EOF2
1877
+fi)
1797 1878
 MAINTAINERCLEANFILES = makefile.in
1798 1879
 EOF
1799 1880
 to --condition AX_USE_LIBTOOL src/${PACKAGE_NAME}.pc.in <<EOF
@@ -1812,14 +1893,14 @@ Requires: @PKG_REQUIREMENTS@
1812 1893
 EOF
1813 1894
 to build-in-docker.conf <<EOF
1814 1895
 ${HEADER}# Use Ubuntu Universe Repository
1815
-repos+=("Ubuntu:::universe")
1896
+repos+=("ubuntu:::universe")
1816 1897
 
1817 1898
 # Use Marc Wäckerlin's Repository, see https://dev.marc.waeckerlin.org
1818
-repos+=("Debian|Ubuntu:::https://dev.marc.waeckerlin.org/repository")
1819
-repos+=("openSUSE:::https://dev.marc.waeckerlin.org/repository/opensuse/marc-waeckerlin.repo")
1820
-repos+=("Fedora:::https://dev.marc.waeckerlin.org/repository/fedora/marc-waeckerlin.repo")
1821
-repos+=("CentOS:::https://dev.marc.waeckerlin.org/repository/centos/marc-waeckerlin.repo")
1899
+repos+=("debian|ubuntu:::https://dev.marc.waeckerlin.org/repository:::https://dev.marc.waeckerlin.org/repository/@DISTRIBUTOR@/marc-waeckerlin.repo")
1822 1900
 keys+=("https://dev.marc.waeckerlin.org/repository/PublicKey")
1901
+
1902
+# centos requires epel-release for some packages, such as Qt WebKit
1903
+packages+=("centos:::epel-release")
1823 1904
 EOF
1824 1905
 
1825 1906
 #### Cleanup If Makefile Exists ####
@@ -1835,7 +1916,15 @@ else
1835 1916
     #### Bootstrap Before Configure ####
1836 1917
     run --no-check vcs2cl
1837 1918
     run aclocal
1838
-    if testtag AX_USE_LIBTOOL; then run libtoolize --force; fi
1919
+    if testtag AX_USE_LIBTOOL; then
1920
+        if which libtoolize > /dev/null; then
1921
+            run libtoolize --force;
1922
+        elif which glibtoolize > /dev/null; then
1923
+            run glibtoolize --force;
1924
+        else
1925
+            error libtoolize not found
1926
+        fi
1927
+    fi
1839 1928
     run automake -a
1840 1929
     run autoconf
1841 1930
     

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

@@ -90,7 +90,7 @@ while test $# -gt 0; do
90 90
                     img="mwaeckerlin/ubuntu:latest"; host="${host:---host=i686-w64-mingw32}"
91 91
                     targets="all install"
92 92
                     flags+=("--prefix=/workdir/usr")
93
-                    packages1=("mingw-w64")
93
+                    packages+=("mingw-w64")
94 94
                     ;;
95 95
                 (*)
96 96
                     echo "**** ERROR: unknown mode '$1', try --help" 1>&2
@@ -195,21 +195,27 @@ function ifthenelse() {
195 195
     arg="$1"
196 196
     shift
197 197
     cmd="$*"
198
+    DISTRIBUTOR=$(docker exec ${DOCKER_ID} lsb_release -si | sed 's, .*,,' | tr [:upper:] [:lower:])
199
+    CODENAME=$(docker exec ${DOCKER_ID} lsb_release -cs)
200
+    ARCH=$((docker exec ${DOCKER_ID} which dpkg > /dev/null 2> /dev/null && docker exec ${DOCKER_ID} dpkg --print-architecture) || echo amd64)
198 201
     if test "${arg/:::/}" = "${arg}"; then
199
-        docker exec ${DOCKER_ID} bash -c "${cmd//ARG/${arg}}"
202
+        docker exec ${DOCKER_ID} bash -c "${cmd//ARG/${arg//@DISTRIBUTOR@/${DISTRIBUTOR}}}"
200 203
     else
201 204
         os="${arg%%:::*}"
202 205
         thenpart="${arg#*:::}"
203
-        if test "${thenpart/:::/}" = "${thenpart}"; then
204
-            docker exec ${DOCKER_ID} bash -c 'os="'$os'"; if [[ "$(lsb_release -is)-$(lsb_release -cs)-$((which dpkg > /dev/null 2> /dev/null && dpkg --print-architecture) || echo amd64)" =~ ${os} ]]; then '"${cmd//ARG/${thenpart}}"'; fi'
205
-        else
206
+        elsepart=
207
+        if test "${thenpart/:::/}" != "${thenpart}"; then
206 208
             elsepart="${thenpart##*:::}"
207
-            thenpart="${thenpart%:::*}"
209
+            thenpart="${thenpart%%:::*}"
210
+        fi
211
+        if [[ "${DISTRIBUTOR}-${CODENAME}-${ARCH}" =~ ${os} ]]; then
208 212
             if test -n "${thenpart}"; then
209
-                docker exec ${DOCKER_ID} bash -c 'os="'$os'"; if [[ "$(lsb_release -is)-$(lsb_release -cs)-$((which dpkg > /dev/null 2> /dev/null && dpkg --print-architecture) || echo amd64)" =~ ${os} ]]; then '"${cmd//ARG/${thenpart}}"'; else '"${cmd//ARG/${elsepart}}"'; fi'
210
-            else
211
-                docker exec ${DOCKER_ID} bash -c 'os="'$os'"; if [[ "$(lsb_release -is)-$(lsb_release -cs)-$((which dpkg > /dev/null 2> /dev/null && dpkg --print-architecture) || echo amd64)" =~ ${os} ]]; then true; else '"${cmd//ARG/${elsepart}}"'; fi'
212
-            fi    
213
+                docker exec ${DOCKER_ID} bash -c "${cmd//ARG/${thenpart//@DISTRIBUTOR@/${DISTRIBUTOR}}}"
214
+            fi
215
+        else
216
+            if test -n "${elsepart}"; then
217
+                docker exec ${DOCKER_ID} bash -c "${cmd//ARG/${elsepart//@DISTRIBUTOR@/${DISTRIBUTOR}}}"
218
+            fi
213 219
         fi
214 220
     fi
215 221
 }
@@ -290,10 +296,16 @@ EOF
290 296
             rm rpm-key
291 297
         done
292 298
         for repo in "${repos[@]}"; do
293
-            INSTALL_REPO=$((docker exec ${DOCKER_ID} test -x /usr/bin/zypper && echo zypper ar) || (docker exec ${DOCKER_ID} test -x /usr/bin/dnf && echo dnf config-manager --add-repo) || (docker exec ${DOCKER_ID} test -x /usr/bin/yum && echo wget -O/etc/yum.repos.d/additional$i.repo) || (docker exec ${DOCKER_ID} test -x /usr/sbin/urpmi && echo true))
299
+            INSTALL_REPO=$((docker exec ${DOCKER_ID} test -x /usr/bin/zypper && echo zypper ar) || (docker exec ${DOCKER_ID} test -x /usr/bin/dnf && echo dnf config-manager --add-repo) || (docker exec ${DOCKER_ID} test -x /usr/bin/yum && echo wget -O/etc/yum.repos.d/additional$i.repo) || (docker exec ${DOCKER_ID} test -x /usr/sbin/urpmi && echo false))
294 300
             ifthenelse "${repo}" "${INSTALL_REPO} 'ARG'"
295 301
             ((++i))
296 302
         done
303
+        for package in "${packages[@]}"; do
304
+            ifthenelse "${package}" "${INSTALL_TOOL} ARG"
305
+        done
306
+        for command in "${commands[@]}"; do
307
+            ifthenelse "${command}" "ARG"
308
+        done
297 309
         docker exec ${DOCKER_ID} ./resolve-rpmbuilddeps.sh
298 310
         ;;
299 311
 esac

+ 171
- 0
dependency-graph.sh View File

@@ -0,0 +1,171 @@
1
+#!/bin/bash -e
2
+
3
+# template for bash scripts
4
+
5
+# internal use only
6
+append_msg() {
7
+    if test $# -ne 0; then
8
+        echo -en ":\e[0m \e[1m$*"
9
+    fi
10
+    echo -e "\e[0m"
11
+}
12
+
13
+# write a notice
14
+notice() {
15
+    if test $# -eq 0; then
16
+        return
17
+    fi
18
+    echo -e "\e[1m$*\e[0m" 1>&3
19
+}
20
+
21
+# write error message
22
+error() {
23
+    echo -en "\e[1;31merror" 1>&2
24
+    append_msg $* 1>&2
25
+}
26
+
27
+# write a warning message
28
+warning() {
29
+    echo -en "\e[1;33mwarning" 1>&2
30
+    append_msg $* 1>&2
31
+}
32
+
33
+# write a success message
34
+success() {
35
+    echo -en "\e[1;32msuccess" 1>&2
36
+    append_msg $* 1>&2
37
+}
38
+
39
+# commandline parameter evaluation
40
+files=${0%/*}/configure.ac
41
+short=0
42
+while test $# -gt 0; do
43
+    case "$1" in
44
+        (--short|-s) short=1;;
45
+        (--help|-h) less <<EOF
46
+SYNOPSIS
47
+
48
+  $0 [OPTIONS] <files>
49
+
50
+OPTIONS
51
+
52
+  --help, -h                 show this help
53
+  --short, -s                short graph with no external dependencies
54
+
55
+  <files>                    list of zero or more configure.ac files
56
+                             (default: ${files})
57
+
58
+DESCRIPTION
59
+
60
+  Evaluates dependencies of all the given configure.ac file. By
61
+  default takes the local configure.ac. Outputs a graphwiz dot file
62
+  with the dependencies. Solid lines are required dependencies, dotted
63
+  lines are optional dependencies.
64
+
65
+EXAMPLE
66
+
67
+  Evaluate all dependencies between all local subversion and git
68
+  projects, if they are in the path ~/svn and ~/git:
69
+
70
+    $0 ~/svn/*/configure.ac ~/git/*/configure.ac 
71
+
72
+EOF
73
+            exit;;
74
+        (*) files=$*; break;;
75
+    esac
76
+    if test $# -eq 0; then
77
+        error "missing parameter, try $0 --help"; exit 1
78
+    fi
79
+    shift;
80
+done
81
+
82
+# run a command, print the result and abort in case of error
83
+# option: --no-check: ignore the result, continue in case of error
84
+run() {
85
+    check=1
86
+    while test $# -gt 0; do
87
+        case "$1" in
88
+            (--no-check) check=0;;
89
+            (*) break;;
90
+        esac
91
+        shift;
92
+    done
93
+    echo -en "\e[1m-> running:\e[0m $* ..."
94
+    result=$($* 2>&1)
95
+    res=$?
96
+    if test $res -ne 0; then
97
+        if test $check -eq 1; then
98
+            error "failed with return code: $res"
99
+            if test -n "$result"; then
100
+                echo "$result"
101
+            fi
102
+            exit 1
103
+        else
104
+            warning "ignored return code: $res"
105
+        fi
106
+    else
107
+        success
108
+    fi
109
+}
110
+
111
+# error handler
112
+function traperror() {
113
+    set +x
114
+    local err=($1) # error status
115
+    local line="$2" # LINENO
116
+    local linecallfunc="$3"
117
+    local command="$4"
118
+    local funcstack="$5"
119
+    for e in ${err[@]}; do
120
+        if test -n "$e" -a "$e" != "0"; then
121
+            error "line $line - command '$command' exited with status: $e (${err[@]})"
122
+            if [ "${funcstack}" != "main" -o "$linecallfunc" != "0" ]; then
123
+                echo -n "   ... error at ${funcstack} "
124
+                if [ "$linecallfunc" != "" ]; then
125
+                    echo -n "called at line $linecallfunc"
126
+                fi
127
+                echo
128
+            fi
129
+            exit $e
130
+        fi
131
+    done
132
+    success
133
+    exit 0
134
+}
135
+
136
+# catch errors
137
+trap 'traperror "$? ${PIPESTATUS[@]}" $LINENO $BASH_LINENO "$BASH_COMMAND" "${FUNCNAME[@]}" "${FUNCTION}"' ERR SIGINT INT TERM EXIT
138
+
139
+##########################################################################################
140
+
141
+filter() {
142
+    if test $short -eq 1; then
143
+        all=$(cat)
144
+        allowed=$(sed -n '/"\(.*\)" \[style=solid\];/{s//\1/;H};${x;s/\n//;s/\n/\\|/gp}' <<<"${all}")
145
+        sed -n '/"\('"${allowed}"'\)" -> "\('"${allowed}"'\)"/p' <<<"${all}"
146
+    else
147
+        cat
148
+    fi
149
+}
150
+
151
+echo "digraph G {"
152
+if test $short -eq 0; then
153
+    echo "node [style=dashed];"
154
+fi
155
+(
156
+    for file in $files; do
157
+        if ! test -e $file; then
158
+            error "file $file not found"; exit 1
159
+        fi
160
+        sed -n '
161
+      /^ *m4_define(x_package_name, */ {s//"/;s/ *).*/"/;h;s/.*/& [style=solid];/p}
162
+      /^ *AX_REQUIRE_QT/ {s/.*/"qt" -> /;G;s/\n//;s/.*/&;/p}
163
+      /^ *AX_PKG_REQUIRE(\[\?\([^],)]\+\)\]\?, \[\?\([^],)]\+\)\]\?.*/ {s//"\2" -> /;G;s/\n//;s/.*/&;/p}
164
+      /^ *AX_PKG_REQUIRE(\[\?\([^],)]\+\)\]\?.*/ {s//"\1" -> /;G;s/\n//;s/.*/&;/p}
165
+      /^ *AX_CHECK_QT/ {s/.*/"qt" -> /;G;s/\n//;s/.*/& [style=dashed];/p}
166
+      /^ *AX_PKG_CHECK(\[\?\([^],)]\+\)\]\?, \[\?\([^],)]\+\)\]\?.*/ {s//"\2" -> /;G;s/\n//;s/.*/& [style=dotted];/p}
167
+      /^ *AX_PKG_CHECK(\[\?\([^],)]\+\)\]\?.*/ {s//"\1" -> /;G;s/\n//;s/.*/& [style=dotted];/p}
168
+    ' $file
169
+    done
170
+) | filter
171
+echo "}"

+ 1
- 1
examples/makefile.am View File

@@ -23,4 +23,4 @@ arguments_SOURCES = arguments.cxx
23 23
 
24 24
 shared_SOURCES = shared.cxx
25 25
 
26
-MAINTAINERCLEANFILES = makefile.in
26
+MAINTAINERCLEANFILES = makefile.in

+ 50
- 3
resolve-debbuilddeps.sh View File

@@ -35,13 +35,53 @@ TO_INSTALL=
35 35
 DEPS=
36 36
 
37 37
 if test -e debian/control.in -a ! -e debian/control; then
38
+    function pkg_exists() {
39
+        test -n "$(${DO} apt-cache policy -q ${1})"
40
+    }
41
+    function AX_PKG_CHECK() {
42
+        local DEV_DEB_DIST_PKG=
43
+        local DEV_DIST_PKG=
44
+        local pkg=
45
+        eval $4
46
+        if test -z "$2"; then
47
+            pkg=$1
48
+        else
49
+            pkg=$2
50
+        fi
51
+        pkg=${DEV_DEB_DIST_PKG:-${DEV_DIST_PKG:-${pkg}}-dev}
52
+        if pkg_exists "${pkg}"; then
53
+            echo $pkg
54
+        fi
55
+    }
56
+    function AX_PKG_REQUIRE() {
57
+        local DEV_DEB_DIST_PKG=
58
+        local DEV_DIST_PKG=
59
+        local pkg=
60
+        eval $6
61
+        if test -z "$2"; then
62
+            pkg=$1
63
+        else
64
+            pkg=$2
65
+        fi
66
+        if test -n "$4"; then
67
+            for f in $pkg $4; do
68
+                if pkg_exists "${f}-dev"; then
69
+                    pkg=$f
70
+                    break
71
+                fi
72
+            done
73
+        fi
74
+        echo ${DEV_DEB_DIST_PKG:-${DEV_DIST_PKG:-${pkg}}-dev}
75
+    }
76
+    DEPS+=" $(eval $(sed -n '/^ *AX_PKG_REQUIRE/{s,^ *\(AX_PKG_REQUIRE\) *(\(.*\)).*,\1 \2,;s.\[\([^]]*\)\],\?."\1".g;s,$,;,g;p}' configure.ac))"
77
+    DEPS+=" $(eval $(sed -n '/^ *AX_PKG_CHECK/{s,^ *\(AX_PKG_CHECK\) *(\(.*\)).*,\1 \2,;s.\[\([^]]*\)\],\?."\1".g;s,$,;,g;p}' configure.ac))"
38 78
     for f in $(sed -n 's, *AX_\(DEB\|ALL\)_DEPEND_IFEXISTS(\([^)]*\)).*,\2,p' configure.ac); do
39
-        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
79
+        if pkg_exists "${f}"; then
40 80
             DEPS+=" ${f}"
41 81
         fi
42 82
     done
43 83
     for f in $(sed -n 's, *AX_\(DEB\|ALL\)_DEPEND_IFEXISTS_DEV(\([^)]*\)).*,\2,p' configure.ac); do
44
-        if test -n "$(${DO} apt-cache policy -q ${f}-dev)" && ((! $(${DO} apt-cache policy ${f}-dev 2>&1 | grep -q 'N: Unable to locate package')) && (! ${DO} dpkg -l "${f}-dev")); then
84
+        if pkg_exists "${f}-dev"; then
45 85
             DEPS+=" ${f}-dev"
46 86
         fi
47 87
     done
@@ -57,10 +97,11 @@ if test -e debian/control.in -a ! -e debian/control; then
57 97
 fi
58 98
 
59 99
 install dpkg-dev
100
+
60 101
 DEPS+=" $(LANG= ${DO} dpkg-checkbuilddeps 2>&1 | sed -n '/Unmet build dependencies/ { s,.*Unmet build dependencies: ,,g; s, ([^)]*),,g; s, *| *,|,g; p}')"
61 102
 
62 103
 for pa in ${DEPS}; do
63
-    if test ${pa//|/} = ${pa}; then
104
+    if test "${pa//|/}" = "${pa}"; then
64 105
         TO_INSTALL+=" ${pa}"
65 106
         continue;
66 107
     fi
@@ -83,4 +124,10 @@ if test -n "${TO_INSTALL}" && ! install ${TO_INSTALL}; then
83 124
     exit 1
84 125
 fi
85 126
 
127
+FILES="$(LANG= ${DO} dpkg-checkbuilddeps 2>&1 | sed -n '/Unmet build dependencies/ { s,.*Unmet build dependencies: ,,g; s, ([^)]*),,g; s, *| *,|,g; p}')"
128
+if test -n "${FILES}"; then
129
+    echo "**** ERROR: Cannot install: " $FILES
130
+    exit 1
131
+fi
132
+
86 133
 echo "**** Success: All Dependencies Resolved"

+ 54
- 8
resolve-rpmbuilddeps.sh View File

@@ -23,19 +23,56 @@ for f in BUILD BUILDROOT RPMS SPECS SRPMS; do
23 23
   fi
24 24
 done
25 25
 if test -e ${PACKAGE_NAME}.spec.in -a ! -e ${PACKAGE_NAME}.spec; then
26
+    function pkg_exists() {
27
+        (test -x /usr/bin/zypper && zypper search -x "$1" 1>&2 > /dev/null) || \
28
+            (test -x /usr/bin/dnf && dnf list -q "$1" 1>&2 > /dev/null) || \
29
+            (test -x /usr/bin/yum && yum list -q "$1" 1>&2 > /dev/null) || \
30
+            (test -x /usr/sbin/urpmq && urpmq "$1" 1>&2 > /dev/null)
31
+    }
32
+    function AX_PKG_CHECK() {
33
+        local DEV_RPM_DIST_PKG=
34
+        local DEV_DIST_PKG=
35
+        local pkg=
36
+        eval $4
37
+        if test -z "$2"; then
38
+            pkg=$1
39
+        else
40
+            pkg=$2
41
+        fi
42
+        pkg=${DEV_RPM_DIST_PKG:-${DEV_DIST_PKG:-${pkg}}-devel}
43
+        if pkg_exists "${pkg}"; then
44
+            echo ${pkg}
45
+        fi
46
+    }
47
+    function AX_PKG_REQUIRE() {
48
+        local DEV_RPM_DIST_PKG=
49
+        local DEV_DIST_PKG=
50
+        local pkg=
51
+        eval $6
52
+        if test -z "$2"; then
53
+            pkg=$1
54
+        else
55
+            pkg=$2
56
+        fi
57
+        if test -n "$4"; then
58
+            for f in $pkg $4; do
59
+                if pkg_exists "${f}-devel"; then
60
+                    pkg=$f
61
+                    break
62
+                fi
63
+            done
64
+        fi
65
+        echo ${DEV_RPM_DIST_PKG:-${DEV_DIST_PKG:-${pkg}}-devel}
66
+    }
67
+    DEPS+=" $(eval $(sed -n '/^ *AX_PKG_REQUIRE/{s,^ *\(AX_PKG_REQUIRE\) *(\(.*\)).*,\1 \2,;s.\[\([^]]*\)\],\?."\1".g;s,$,;,g;p}' configure.ac))"
68
+    DEPS+=" $(eval $(sed -n '/^ *AX_PKG_CHECK/{s,^ *\(AX_PKG_CHECK\) *(\(.*\)).*,\1 \2,;s.\[\([^]]*\)\],\?."\1".g;s,$,;,g;p}' configure.ac))"
26 69
     for f in $(sed -n 's, *AX_\(RPM\|ALL\)_DEPEND_IFEXISTS(\([^)]*\)).*,\2,p' configure.ac); do
27
-        if (test -x /usr/bin/zypper && zypper search -x "$f" 1>&2 > /dev/null) || \
28
-               (test -x /usr/bin/dnf && dnf list -q "$f" 1>&2 > /dev/null) || \
29
-               (test -x /usr/bin/yum && yum list -q "$f" 1>&2 > /dev/null) || \
30
-               (test -x /usr/sbin/urpmq && urpmq "$f" 1>&2 > /dev/null); then
70
+        if pkg_exists "${f}"; then
31 71
             DEPS+=" ${f}"
32 72
         fi
33 73
     done
34 74
     for f in $(sed -n 's, *AX_\(RPM\|ALL\)_DEPEND_IFEXISTS_DEV(\([^)]*\)).*,\2,p' configure.ac); do
35
-        if (test -x /usr/bin/zypper && zypper search -x "$f"-devel 1>&2 > /dev/null) || \
36
-               (test -x /usr/bin/dnf && dnf list -q "$f"-devel 1>&2 > /dev/null) || \
37
-               (test -x /usr/bin/yum && yum list -q "$f"-devel 1>&2 > /dev/null) || \
38
-               (test -x /usr/sbin/urpmq && urpmq "$f"-devel 1>&2 > /dev/null); then
75
+        if pkg_exists "${f}-devel"; then
39 76
             DEPS+=" ${f}-devel"
40 77
         fi
41 78
     done
@@ -70,5 +107,14 @@ else
70 107
     fi
71 108
 fi
72 109
 
110
+if test -n "${SCHROOTNAME}"; then
111
+    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')
112
+else
113
+    FILES=$(LANG= rpmbuild -bb --clean --nobuild --define "_topdir ." --define "_sourcedir ." ${PACKAGE_NAME}.spec 2>&1 | sed -n 's, is needed by.*,,p')
114
+fi
115
+if test -n "${FILES}"; then
116
+    echo "**** ERROR: Cannot install: " $FILES
117
+    exit 1
118
+fi
73 119
 
74 120
 echo "**** Success: All Dependencies Resolved"

+ 159
- 0
template.sh View File

@@ -0,0 +1,159 @@
1
+#!/bin/bash -e
2
+
3
+##########################################################################################
4
+#### template for bash scripts #### START BELOW ##########################################
5
+##########################################################################################
6
+
7
+############################################################################ begin logging
8
+# check if stdout is a terminal...
9
+if test -t 1; then
10
+
11
+    # see if it supports colors...
12
+    ncolors=$(tput colors)
13
+
14
+    if test -n "$ncolors" && test $ncolors -ge 8; then
15
+        bold="$(tput bold)"
16
+        underline="$(tput smul)"
17
+        standout="$(tput smso)"
18
+        normal="$(tput sgr0)"
19
+        black="$(tput setaf 0)"
20
+        red="$(tput setaf 1)"
21
+        green="$(tput setaf 2)"
22
+        yellow="$(tput setaf 3)"
23
+        blue="$(tput setaf 4)"
24
+        magenta="$(tput setaf 5)"
25
+        cyan="$(tput setaf 6)"
26
+        white="$(tput setaf 7)"
27
+    fi
28
+fi
29
+
30
+append_msg() {
31
+    if test $# -ne 0; then
32
+        echo -n ": ${bold}$*"
33
+    fi
34
+    echo "${normal}"
35
+}
36
+
37
+# write a message
38
+message() {
39
+    if test $# -eq 0; then
40
+        return
41
+    fi
42
+    echo "${bold}${while}$*${normal}" 1>&2
43
+}
44
+
45
+# write a success message
46
+success() {
47
+    echo -n "${bold}${green}success" 1>&2
48
+    append_msg $* 1>&2
49
+}
50
+
51
+# write a notice
52
+notice() {
53
+    echo -n "${bold}${yellow}notice" 1>&2
54
+    append_msg $* 1>&2
55
+}
56
+
57
+# write a warning message
58
+warning() {
59
+    echo -en "${bold}${red}warning" 1>&2
60
+    append_msg $* 1>&2
61
+}
62
+
63
+# write error message
64
+error() {
65
+    echo -en "${bold}${red}error" 1>&2
66
+    append_msg $* 1>&2
67
+}
68
+
69
+# run a command, print the result and abort in case of error
70
+# option: --ignore: ignore the result, continue in case of error
71
+run() {
72
+    ignore=1
73
+    while test $# -gt 0; do
74
+        case "$1" in
75
+            (--ignore) ignore=0;;
76
+            (*) break;;
77
+        esac
78
+        shift;
79
+    done
80
+    echo -n "${bold}${yellow}running:${white} $*${normal} … "
81
+    set +e
82
+    result=$($* 2>&1)
83
+    res=$?
84
+    set -e
85
+    if test $res -ne 0; then
86
+        if test $ignore -eq 1; then
87
+            error "failed with return code: $res"
88
+            if test -n "$result"; then
89
+                echo "$result"
90
+            fi
91
+            exit 1
92
+        else
93
+            warning "ignored return code: $res"
94
+        fi
95
+    else
96
+        success
97
+    fi
98
+}
99
+
100
+############################################################################ error handler
101
+function traperror() {
102
+    set +x
103
+    local err=($1) # error status
104
+    local line="$2" # LINENO
105
+    local linecallfunc="$3"
106
+    local command="$4"
107
+    local funcstack="$5"
108
+    for e in ${err[@]}; do
109
+        if test -n "$e" -a "$e" != "0"; then
110
+            error "line $line - command '$command' exited with status: $e (${err[@]})"
111
+            if [ "${funcstack}" != "main" -o "$linecallfunc" != "0" ]; then
112
+                echo -n "   ... error at ${funcstack} " 1>&2
113
+                if [ "$linecallfunc" != "" ]; then
114
+                    echo -n "called at line $linecallfunc" 1>&2
115
+                fi
116
+                echo
117
+            fi
118
+            exit $e
119
+        fi
120
+    done
121
+    success
122
+    exit 0
123
+}
124
+
125
+# catch errors
126
+trap 'traperror "$? ${PIPESTATUS[@]}" $LINENO $BASH_LINENO "$BASH_COMMAND" "${FUNCNAME[@]}" "${FUNCTION}"' ERR SIGINT INT TERM EXIT
127
+
128
+
129
+
130
+##########################################################################################
131
+#### START HERE ##########################################################################
132
+##########################################################################################
133
+
134
+######################################################### commandline parameter evaluation
135
+while test $# -gt 0; do
136
+    case "$1" in
137
+        (--help|-h) less <<EOF
138
+SYNOPSIS
139
+
140
+  $0 [OPTIONS]
141
+
142
+OPTIONS
143
+
144
+  --help, -h                 show this help
145
+
146
+DESCRIPTION
147
+
148
+EOF
149
+            exit;;
150
+        (*) error "unknow option $1, try $0 --help"; exit 1;;
151
+    esac
152
+    if test $# -eq 0; then
153
+        error "missing parameter, try $0 --help"; exit 1
154
+    fi
155
+    shift;
156
+done
157
+
158
+##################################################################################### Main
159
+

Loading…
Cancel
Save