From 991dc63f174a167ede00865d249f30aa81d92ba9 Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Tue, 19 Dec 2023 09:37:52 +0100 Subject: build: fix and refactor scripts --- bin/Makefile.am | 8 ------- bin/dosubst.awk | 47 -------------------------------------- bin/gana_update.sh | 59 ------------------------------------------------ bin/grephdr.sh | 4 ---- bin/grepsrc.sh | 4 ---- bin/meson.build | 16 ------------- bin/pogen.sh | 11 --------- bin/rename.sh | 7 ------ bin/sphinx_update.sh | 35 ---------------------------- bootstrap | 17 +++++--------- configure.ac | 1 - meson-dist-script | 2 +- scripts/dosubst.awk | 47 ++++++++++++++++++++++++++++++++++++++ scripts/gana_update.sh | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ scripts/grephdr.sh | 4 ++++ scripts/grepsrc.sh | 4 ++++ scripts/meson.build | 16 +++++++++++++ scripts/pogen.sh | 11 +++++++++ scripts/rename.sh | 7 ++++++ scripts/sphinx_update.sh | 35 ++++++++++++++++++++++++++++ 20 files changed, 190 insertions(+), 204 deletions(-) delete mode 100644 bin/Makefile.am delete mode 100755 bin/dosubst.awk delete mode 100755 bin/gana_update.sh delete mode 100755 bin/grephdr.sh delete mode 100755 bin/grepsrc.sh delete mode 100644 bin/meson.build delete mode 100755 bin/pogen.sh delete mode 100755 bin/rename.sh delete mode 100755 bin/sphinx_update.sh create mode 100755 scripts/dosubst.awk create mode 100755 scripts/gana_update.sh create mode 100755 scripts/grephdr.sh create mode 100755 scripts/grepsrc.sh create mode 100755 scripts/pogen.sh create mode 100755 scripts/rename.sh create mode 100755 scripts/sphinx_update.sh diff --git a/bin/Makefile.am b/bin/Makefile.am deleted file mode 100644 index 18fccda56..000000000 --- a/bin/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -EXTRA_DIST = \ - dosubst.awk \ - grephdr.sh \ - grepsrc.sh \ - pogen.sh \ - sphinx_update.sh \ - gana_update.sh \ - rename.sh diff --git a/bin/dosubst.awk b/bin/dosubst.awk deleted file mode 100755 index 3ed0403dd..000000000 --- a/bin/dosubst.awk +++ /dev/null @@ -1,47 +0,0 @@ -# Dedicated to the public domain. -# SPDX-License-Identifier: 0BSD -# -# awk script to substitute variables in scripts and applications. -# -# You can pass these variables to it in Makefiles or on the -# commandline: -# bdir="$(bindir)" -# py="$(PYTHON)" -# awkay="$(AWK_BINARY)" -# pfx="$(prefix)" -# prl="$(PERL)" -# sysconfdirectory="$(sysconfdir)" -# pkgdatadirectory="$(pkgdatadir)" - -{ - - if (/@bindirectory@/) { - gsub("@bindirectory@",bdir) ; - } - - if (/@PYTHONEXE@/) { - gsub("@PYTHONEXE@",py) ; - } - - if (/@AWKEXE@/) { - gsub("@AWKEXE@",awkay) ; - } - - if (/@SUBSTPREFIX@/) { - gsub("@SUBSTPREFIX@",pfx) ; - } - - if (/@PERLEXE@/) { - gsub("@PERLEXE@",prl) ; - } - - if (/@SYSCONFDIR@/) { - gsub("@SYSCONFDIR@",sysconfdirectory) ; - } - - if (/@PKGDATADIRECTORY@/) { - gsub("@PKGDATADIRECTORY@",pkgdatadirectory) ; - } - - print $0 ; -} diff --git a/bin/gana_update.sh b/bin/gana_update.sh deleted file mode 100755 index 0707433f5..000000000 --- a/bin/gana_update.sh +++ /dev/null @@ -1,59 +0,0 @@ -# This is more portable than `which' but comes with -# the caveat of not(?) properly working on busybox's ash: -existence() -{ - type "$1" >/dev/null 2>&1 -} - -gana_update() -{ - if [ ! -z $GNUNET_SKIP_GANA ]; then - echo "Skipping GANA update" - return - fi - echo "Updating GANA..." - if existence recfmt; then - cwd=$PWD - cd contrib/gana || exit 1 - # GNS - echo "Updating GNS record types" - cd gnu-name-system-record-types && \ - make >/dev/null && \ - cp gnu_name_system_record_types.h ../../../src/include/ || exit 1 - echo "Creating default TLDs" - cd ../gnu-name-system-default-tlds && \ - make >/dev/null && \ - cp tlds.conf ../../../src/service/gns || exit 1 - echo "Creating default GNS protocol numbers" - cd ../gns-protocol-numbers && \ - make >/dev/null && \ - cp gnu_name_system_protocols.h ../../../src/include/ || exit 1 - echo "Creating default GNS service port nummbers" - cd ../gns-service-port-numbers && \ - make >/dev/null && \ - cp gnu_name_system_service_ports.h ../../../src/include/ || exit 1 - - # Signatures - echo "Updating GNUnet signatures" - cd ../gnunet-signatures && \ - make >/dev/null && \ - cp gnunet_signatures.h ../../../src/include || exit 1 - # DHT Block Types - echo "Updating DHT record types" - cd ../gnunet-dht-block-types && \ - make >/dev/null && \ - cp gnunet_dht_block_types.h ../../../src/include || exit 1 - echo "Generating GNUnet error types" - cd ../gnunet-error-codes && \ - make >/dev/null && \ - cp gnunet_error_codes.h ../../../src/include && \ - cp gnunet_error_codes.c ../../../src/lib/util || exit 1 - cd $cwd - else - echo "ERROR: No recutils found! Unable to generate recent GANA headers and configs." - exit 1 - fi - echo "GANA finished" -} - -gana_update diff --git a/bin/grephdr.sh b/bin/grephdr.sh deleted file mode 100755 index dd9050335..000000000 --- a/bin/grephdr.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# This script is in the public domain. -# grepsrc.sh string --- greps for string over all header files -find . -name "*.h" -print | grep -v "#" | xargs grep "$@" diff --git a/bin/grepsrc.sh b/bin/grepsrc.sh deleted file mode 100755 index eb2d5e462..000000000 --- a/bin/grepsrc.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# This script is in the public domain. -# grepsrc.sh string --- greps for string over all C files -find . -name "*.c" -print | grep -v "#" | xargs grep -n "$*" diff --git a/bin/meson.build b/bin/meson.build deleted file mode 100644 index e98bd2fb3..000000000 --- a/bin/meson.build +++ /dev/null @@ -1,16 +0,0 @@ -binfiles = [ - 'dosubst.awk', - 'grephdr.sh', - 'grepsrc.sh', - 'pogen.sh', - 'rename.sh', - 'gana_update.sh', - 'sphinx_update.sh', - ] - -foreach f : binfiles - configure_file(input : f, - output : f, - copy: true) -endforeach - diff --git a/bin/pogen.sh b/bin/pogen.sh deleted file mode 100755 index a68152bf4..000000000 --- a/bin/pogen.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -# This script is in the public domain. - -# Set language domain to C for a more stable sort! -export LANG=C -# Manual says, it should be LC_ALL... -export LC_ALL=C - -find src -name "*.c" | grep -v \# | grep -v /test_ | grep -v /perf_ | grep -v _old | grep -v chat | grep -v .libs/ | sort > po/POTFILES.in -grep -l _\( `find src -name "*.h"` | grep -v "platform.h" | grep -v _old | grep -v chat | sort >> po/POTFILES.in - diff --git a/bin/rename.sh b/bin/rename.sh deleted file mode 100755 index eec77e277..000000000 --- a/bin/rename.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -# This script is in the public domain. -for n in `find * -name "*.c"` `find * -name "*.h"` `find * -name "*.am"` `find * -name "*.conf"` `find * -name "*.conf.in"` -do - cat $n | sed -e "s/$1/$2/g" > $n.new - mv $n.new $n || echo "Move failed: $n.new to $n" -done diff --git a/bin/sphinx_update.sh b/bin/sphinx_update.sh deleted file mode 100755 index 6d589667c..000000000 --- a/bin/sphinx_update.sh +++ /dev/null @@ -1,35 +0,0 @@ -# This is more portable than `which' but comes with -# the caveat of not(?) properly working on busybox's ash: -existence() -{ - type "$1" >/dev/null 2>&1 -} - -sphinx_update() -{ - echo "Updating handbook..." - if existence sphinx-build; then - cwd=$PWD - cd contrib/handbook || exit 1 - if test -e _build; then - make clean - fi - # GNS - make html >/dev/null || exit 1 - if test -e ../../doc/handbook/html; then - rm -r ../../doc/handbook/html || exit 1 - fi - cp -r _build/html ../../doc/handbook/ || exit 1 - if test -e ../../doc/handbook/texinfo; then - rm -r ../../doc/handbook/texinfo || exit 1 - fi - make info >/dev/null || exit 1 - cp -r _build/texinfo ../../doc/handbook/ || exit 1 - cd $cwd - else - echo "ERROR: Sphinx not found! Unable to generate recent documentation." - exit 1 - fi -} - -sphinx_update diff --git a/bootstrap b/bootstrap index 348c2ce44..5698c39f6 100755 --- a/bootstrap +++ b/bootstrap @@ -75,23 +75,18 @@ check_libtool() { echo "checking for libtoolize / libtool... " + . "scripts/gana_update.sh" || exit 1 + . "scripts/sphinx_update.sh" || exit 1 if existence libtool || \ existence libtoolize || \ existence glibtoolize || \ existence slibtool; then - if existence autoreconf; then - autoreconf -if - elif ! existence meson; then - echo "*** No autoconf or meson installed, please install either ***" - exit 1 - fi - . "bin/pogen.sh" || exit 1 - . "bin/gana_update.sh" || exit 1 - . "bin/sphinx_update.sh" || exit 1 - else - echo "*** No libtoolize (libtool) or libtool found, please install it ***" >&2; + autoreconf -if + elif ! existence meson + echo "*** No libtoolize (libtool) or libtool or meson found, please install it ***" >&2; exit 1 fi + . "scripts/pogen.sh" || exit 1 } submodules() diff --git a/configure.ac b/configure.ac index 0e1bbb75a..8cc00d1de 100644 --- a/configure.ac +++ b/configure.ac @@ -1212,7 +1212,6 @@ AC_DEFINE_UNQUOTED([VCS_VERSION], [$vcs_version], AC_CONFIG_FILES([ Makefile -bin/Makefile contrib/Makefile data/Makefile data/hellos/Makefile diff --git a/meson-dist-script b/meson-dist-script index 4695439df..e5e9287dc 100644 --- a/meson-dist-script +++ b/meson-dist-script @@ -3,4 +3,4 @@ set -eu cd "${MESON_DIST_ROOT}" -. ./bin/sphinx_update.sh +. ./scripts/sphinx_update.sh diff --git a/scripts/dosubst.awk b/scripts/dosubst.awk new file mode 100755 index 000000000..3ed0403dd --- /dev/null +++ b/scripts/dosubst.awk @@ -0,0 +1,47 @@ +# Dedicated to the public domain. +# SPDX-License-Identifier: 0BSD +# +# awk script to substitute variables in scripts and applications. +# +# You can pass these variables to it in Makefiles or on the +# commandline: +# bdir="$(bindir)" +# py="$(PYTHON)" +# awkay="$(AWK_BINARY)" +# pfx="$(prefix)" +# prl="$(PERL)" +# sysconfdirectory="$(sysconfdir)" +# pkgdatadirectory="$(pkgdatadir)" + +{ + + if (/@bindirectory@/) { + gsub("@bindirectory@",bdir) ; + } + + if (/@PYTHONEXE@/) { + gsub("@PYTHONEXE@",py) ; + } + + if (/@AWKEXE@/) { + gsub("@AWKEXE@",awkay) ; + } + + if (/@SUBSTPREFIX@/) { + gsub("@SUBSTPREFIX@",pfx) ; + } + + if (/@PERLEXE@/) { + gsub("@PERLEXE@",prl) ; + } + + if (/@SYSCONFDIR@/) { + gsub("@SYSCONFDIR@",sysconfdirectory) ; + } + + if (/@PKGDATADIRECTORY@/) { + gsub("@PKGDATADIRECTORY@",pkgdatadirectory) ; + } + + print $0 ; +} diff --git a/scripts/gana_update.sh b/scripts/gana_update.sh new file mode 100755 index 000000000..0707433f5 --- /dev/null +++ b/scripts/gana_update.sh @@ -0,0 +1,59 @@ +# This is more portable than `which' but comes with +# the caveat of not(?) properly working on busybox's ash: +existence() +{ + type "$1" >/dev/null 2>&1 +} + +gana_update() +{ + if [ ! -z $GNUNET_SKIP_GANA ]; then + echo "Skipping GANA update" + return + fi + echo "Updating GANA..." + if existence recfmt; then + cwd=$PWD + cd contrib/gana || exit 1 + # GNS + echo "Updating GNS record types" + cd gnu-name-system-record-types && \ + make >/dev/null && \ + cp gnu_name_system_record_types.h ../../../src/include/ || exit 1 + echo "Creating default TLDs" + cd ../gnu-name-system-default-tlds && \ + make >/dev/null && \ + cp tlds.conf ../../../src/service/gns || exit 1 + echo "Creating default GNS protocol numbers" + cd ../gns-protocol-numbers && \ + make >/dev/null && \ + cp gnu_name_system_protocols.h ../../../src/include/ || exit 1 + echo "Creating default GNS service port nummbers" + cd ../gns-service-port-numbers && \ + make >/dev/null && \ + cp gnu_name_system_service_ports.h ../../../src/include/ || exit 1 + + # Signatures + echo "Updating GNUnet signatures" + cd ../gnunet-signatures && \ + make >/dev/null && \ + cp gnunet_signatures.h ../../../src/include || exit 1 + # DHT Block Types + echo "Updating DHT record types" + cd ../gnunet-dht-block-types && \ + make >/dev/null && \ + cp gnunet_dht_block_types.h ../../../src/include || exit 1 + echo "Generating GNUnet error types" + cd ../gnunet-error-codes && \ + make >/dev/null && \ + cp gnunet_error_codes.h ../../../src/include && \ + cp gnunet_error_codes.c ../../../src/lib/util || exit 1 + cd $cwd + else + echo "ERROR: No recutils found! Unable to generate recent GANA headers and configs." + exit 1 + fi + echo "GANA finished" +} + +gana_update diff --git a/scripts/grephdr.sh b/scripts/grephdr.sh new file mode 100755 index 000000000..dd9050335 --- /dev/null +++ b/scripts/grephdr.sh @@ -0,0 +1,4 @@ +#!/bin/sh +# This script is in the public domain. +# grepsrc.sh string --- greps for string over all header files +find . -name "*.h" -print | grep -v "#" | xargs grep "$@" diff --git a/scripts/grepsrc.sh b/scripts/grepsrc.sh new file mode 100755 index 000000000..eb2d5e462 --- /dev/null +++ b/scripts/grepsrc.sh @@ -0,0 +1,4 @@ +#!/bin/sh +# This script is in the public domain. +# grepsrc.sh string --- greps for string over all C files +find . -name "*.c" -print | grep -v "#" | xargs grep -n "$*" diff --git a/scripts/meson.build b/scripts/meson.build index fd45de0d2..830bec0c4 100644 --- a/scripts/meson.build +++ b/scripts/meson.build @@ -10,3 +10,19 @@ install_data([ install_data('xdg-scheme-handler'/'gnunet-uri.desktop', install_dir: get_option('datadir')/'applications') +binfiles = [ + 'dosubst.awk', + 'grephdr.sh', + 'grepsrc.sh', + 'pogen.sh', + 'rename.sh', + 'gana_update.sh', + 'sphinx_update.sh', + ] + +foreach f : binfiles + configure_file(input : f, + output : f, + copy: true) +endforeach + diff --git a/scripts/pogen.sh b/scripts/pogen.sh new file mode 100755 index 000000000..a68152bf4 --- /dev/null +++ b/scripts/pogen.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# This script is in the public domain. + +# Set language domain to C for a more stable sort! +export LANG=C +# Manual says, it should be LC_ALL... +export LC_ALL=C + +find src -name "*.c" | grep -v \# | grep -v /test_ | grep -v /perf_ | grep -v _old | grep -v chat | grep -v .libs/ | sort > po/POTFILES.in +grep -l _\( `find src -name "*.h"` | grep -v "platform.h" | grep -v _old | grep -v chat | sort >> po/POTFILES.in + diff --git a/scripts/rename.sh b/scripts/rename.sh new file mode 100755 index 000000000..eec77e277 --- /dev/null +++ b/scripts/rename.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# This script is in the public domain. +for n in `find * -name "*.c"` `find * -name "*.h"` `find * -name "*.am"` `find * -name "*.conf"` `find * -name "*.conf.in"` +do + cat $n | sed -e "s/$1/$2/g" > $n.new + mv $n.new $n || echo "Move failed: $n.new to $n" +done diff --git a/scripts/sphinx_update.sh b/scripts/sphinx_update.sh new file mode 100755 index 000000000..6d589667c --- /dev/null +++ b/scripts/sphinx_update.sh @@ -0,0 +1,35 @@ +# This is more portable than `which' but comes with +# the caveat of not(?) properly working on busybox's ash: +existence() +{ + type "$1" >/dev/null 2>&1 +} + +sphinx_update() +{ + echo "Updating handbook..." + if existence sphinx-build; then + cwd=$PWD + cd contrib/handbook || exit 1 + if test -e _build; then + make clean + fi + # GNS + make html >/dev/null || exit 1 + if test -e ../../doc/handbook/html; then + rm -r ../../doc/handbook/html || exit 1 + fi + cp -r _build/html ../../doc/handbook/ || exit 1 + if test -e ../../doc/handbook/texinfo; then + rm -r ../../doc/handbook/texinfo || exit 1 + fi + make info >/dev/null || exit 1 + cp -r _build/texinfo ../../doc/handbook/ || exit 1 + cd $cwd + else + echo "ERROR: Sphinx not found! Unable to generate recent documentation." + exit 1 + fi +} + +sphinx_update -- cgit v1.2.3