Browse Source

Cherry-pick "Move build system to meson"

Required to make subsequent easier to cherry-pick.
Christoph Biedl 3 years ago
parent
commit
df73e9af21

+ 1 - 0
debian/control

@@ -11,6 +11,7 @@ Build-Depends: debhelper-compat (= 13),
     libhttp-parser-dev (>= 2.8.0),
     libjansson-dev (>= 2.10),
     libjose-dev (>= 8),
+    meson,
     pkg-config,
     systemd,
 Priority: optional

+ 369 - 0
debian/patches/cherry-pick/1576775046.v7-2-gfed9020.move-build-system-to-meson.patch

@@ -0,0 +1,369 @@
+Subject: Move build system to meson
+Origin: v7-2-gfed9020 <https://github.com/latchset/tang/commit/v7-2-gfed9020>
+Upstream-Author: Sergio Correia <scorreia@redhat.com>
+Date: Thu Dec 19 14:04:06 2019 -0300
+
+    Also install asciidoc package in CI, so that it will build the
+    man pages as well.
+
+--
+    Some extra adjustment needed for pre-usrmerge.
+
+--- a/Makefile.am
++++ /dev/null
+@@ -1,60 +0,0 @@
+-DISTCHECK_CONFIGURE_FLAGS = --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)
+-BUILT_SOURCES=
+-CLEANFILES=
+-man1_MANS=
+-man8_MANS=
+-
+-AM_CFLAGS = @TANG_CFLAGS@ @jose_CFLAGS@
+-LDADD = @jose_LIBS@ @http_parser_LIBS@
+-
+-cachedir = $(localstatedir)/cache/$(PACKAGE_NAME)
+-jwkdir = $(localstatedir)/db/$(PACKAGE_NAME)
+-
+-nodist_systemdsystemunit_DATA = \
+-    units/tangd@.service \
+-    units/tangd.socket \
+-    units/tangd-update.path \
+-    units/tangd-update.service \
+-    units/tangd-keygen.service
+-
+-dist_libexec_SCRIPTS = src/tangd-update src/tangd-keygen
+-dist_bin_SCRIPTS = src/tang-show-keys
+-libexec_PROGRAMS = src/tangd
+-
+-man_ADOC_FILES= \
+-	doc/tang-show-keys.1.adoc \
+-	doc/tang.8.adoc
+-
+-if HAVE_A2X
+-man_ROFF_FILES = $(man_ADOC_FILES:.adoc=.roff)
+-BUILT_SOURCES += $(man_ROFF_FILES)
+-CLEANFILES += $(man_ROFF_FILES) $(man_ROFF_FILES:.roff=)
+-
+-$(top_builddir)/%.roff: %.adoc
+-	$(MKDIR_P) $$(dirname $@)
+-	$(A2X) -f manpage $^ -D $(top_builddir)/$$(dirname $@)
+-	$(INSTALL) -m 644 $(top_builddir)/$(@:.roff=) $(top_builddir)/$@
+-
+-man1_MANS += doc/tang-show-keys.1
+-man8_MANS += doc/tang.8
+-endif
+-
+-src_tangd_SOURCES = src/http.c src/http.h src/tangd.c
+-
+-%: %.in
+-	$(AM_V_GEN)mkdir -p "`dirname "$@"`"
+-	$(AM_V_GEN)$(SED) \
+-		-e 's,@libexecdir\@,$(libexecdir),g' \
+-		-e 's,@jwkdir\@,$(jwkdir),g' \
+-		-e 's,@cachedir\@,$(cachedir),g' \
+-		$(srcdir)/$@.in > $@
+-
+-AM_TESTS_ENVIRONMENT = SD_ACTIVATE="@SD_ACTIVATE@" PATH=$(srcdir)/src:$(builddir)/src:$(PATH)
+-TESTS = tests/adv tests/rec
+-
+-CLEANFILES += $(nodist_systemdsystemunit_DATA)
+-EXTRA_DIST = \
+-    $(foreach unit,$(nodist_systemdsystemunit_DATA),$(unit).in) \
+-    COPYING \
+-    $(TESTS) \
+-    $(man_ADOC_FILES)
+--- a/configure.ac
++++ /dev/null
+@@ -1,87 +0,0 @@
+-AC_PREREQ(2.59)
+-AC_INIT(tang, 7)
+-AC_CANONICAL_SYSTEM
+-AC_PROG_CC_C99
+-AC_PROG_SED
+-
+-AM_INIT_AUTOMAKE([subdir-objects foreign no-dist-gzip dist-bzip2 parallel-tests])
+-AM_SILENT_RULES([yes])
+-AM_PROG_CC_C_O
+-
+-PKG_PROG_PKG_CONFIG([0.25])
+-
+-AC_CHECK_LIB([dl], [dlopen], [AC_SUBST([dl_LIBS], [-ldl])],
+-             [AC_CHECK_LIB([dl], [dlopen], [AC_SUBST([dl_LIBS], [-ldl])],
+-	                   [AC_MSG_ERROR([unable to find dlopen])])])
+-
+-AC_CHECK_HEADER([http_parser.h], [],
+-		[AC_MSG_ERROR([http-parser required!])], [
+-#include <http_parser.h>
+-#ifndef HTTP_STATUS_MAP
+-#error HTTP_STATUS_MAP not defined!
+-#endif
+-])
+-
+-AC_CHECK_LIB([http_parser], [http_parser_execute],
+-             [AC_SUBST(http_parser_LIBS, [-lhttp_parser])],
+-             [AC_MSG_ERROR([http-parser required!])])
+-
+-PKG_CHECK_MODULES([jose], [jose >= 8])
+-PKG_CHECK_MODULES([systemd], [systemd])
+-
+-AC_ARG_WITH([systemdsystemunitdir],
+-            [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],
+-            [],
+-            [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
+-
+-AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
+-
+-for ac_prog in systemd-socket-activate systemd-activate; do
+-    AC_CHECK_PROG([SD_ACTIVATE], [$ac_prog], [$as_dir/$ac_prog], [],
+-		  [$PATH$PATH_SEPARATOR$($PKG_CONFIG --variable=systemdutildir systemd)])
+-    test -n "$SD_ACTIVATE" && break
+-done
+-
+-test -n "$SD_ACTIVATE" || AC_MSG_ERROR([systemd-socket-activate required!])
+-
+-AC_MSG_CHECKING([systemd-socket-activate inetd flag])
+-if $SD_ACTIVATE --help | grep -q inetd; then
+-    SD_ACTIVATE="$SD_ACTIVATE --inetd"
+-    AC_MSG_RESULT([--inetd])
+-else
+-    AC_MSG_RESULT([(default)])
+-fi
+-
+-AC_SUBST(SD_ACTIVATE)
+-
+-TANG_CFLAGS="\
+--Wall \
+--Wextra \
+--Werror \
+--Wstrict-aliasing \
+--Wchar-subscripts \
+--Wformat-security \
+--Wmissing-declarations \
+--Wmissing-prototypes \
+--Wnested-externs \
+--Wpointer-arith \
+--Wshadow \
+--Wsign-compare \
+--Wstrict-prototypes \
+--Wtype-limits \
+--Wunused-function \
+--Wno-missing-field-initializers \
+--Wno-unused-parameter \
+-"
+-AC_SUBST([TANG_CFLAGS])
+-
+-AC_CHECK_PROGS(A2X, [a2x])
+-
+-if test "x$A2X" = "x"; then
+-   AC_MSG_WARN([asciidoc / a2x not found -- man pages will not be generated and installed])
+-fi
+-
+-AM_CONDITIONAL(HAVE_A2X, [test -n "$A2X"])
+-
+-AC_CONFIG_FILES([Makefile])
+-AC_OUTPUT
+--- /dev/null
++++ b/doc/meson.build
+@@ -0,0 +1,4 @@
++mans += join_paths(meson.current_source_dir(), 'tang-show-keys.1')
++mans += join_paths(meson.current_source_dir(), 'tang.8')
++
++# vim:set ts=2 sw=2 et:
+--- /dev/null
++++ b/meson.build
+@@ -0,0 +1,85 @@
++project('tang', 'c',
++  version: '7',
++  license: 'GPL3+',
++  default_options: [
++    'c_std=c99',
++    'prefix=/usr',
++    'sysconfdir=/etc',
++    'localstatedir=/var',
++    'warning_level=3',
++    'werror=true'
++  ]
++)
++
++libexecdir = join_paths(get_option('prefix'), get_option('libexecdir'))
++sysconfdir = join_paths(get_option('prefix'), get_option('sysconfdir'))
++bindir = join_paths(get_option('prefix'), get_option('bindir'))
++systemunitdir = join_paths(get_option('prefix'), '../lib/systemd/system')
++licensedir = join_paths(get_option('prefix'), 'share', 'licenses', meson.project_name())
++cachedir = join_paths(get_option('localstatedir'), 'cache', meson.project_name())
++jwkdir = join_paths(get_option('localstatedir'), 'db', meson.project_name())
++
++data = configuration_data()
++data.set('libexecdir', libexecdir)
++data.set('sysconfdir', sysconfdir)
++data.set('systemunitdir', systemunitdir)
++data.set('cachedir', cachedir)
++data.set('jwkdir', jwkdir)
++
++add_project_arguments(
++  '-D_POSIX_C_SOURCE=200809L',
++  '-Wstrict-aliasing',
++  '-Wchar-subscripts',
++  '-Wformat-security',
++  '-Wmissing-declarations',
++  '-Wmissing-prototypes',
++  '-Wnested-externs',
++  '-Wpointer-arith',
++  '-Wshadow',
++  '-Wsign-compare',
++  '-Wstrict-prototypes',
++  '-Wtype-limits',
++  '-Wunused-function',
++  '-Wno-missing-field-initializers',
++  '-Wno-unused-parameter',
++  '-Wno-pedantic',
++  language: 'c'
++)
++
++jose = dependency('jose', version: '>=8')
++a2x = find_program('a2x', required: false)
++compiler = meson.get_compiler('c')
++if not compiler.has_header('http_parser.h')
++  error('http-parser devel files not found.')
++endif
++http_parser = compiler.find_library('http_parser')
++
++licenses = ['COPYING']
++libexecbins = []
++bins = []
++mans = []
++units = []
++
++subdir('doc')
++subdir('src')
++subdir('units')
++subdir('tests')
++
++install_data(libexecbins, install_dir: libexecdir)
++install_data(bins, install_dir: bindir)
++install_data(units, install_dir: systemunitdir)
++install_data(licenses, install_dir: licensedir)
++
++if a2x.found()
++  foreach m : mans
++    custom_target(m.split('/')[-1], input: m + '.adoc', output: m.split('/')[-1],
++      command: [a2x, '-f', 'manpage', '-D', meson.current_build_dir(), '@INPUT@'],
++      install_dir: join_paths(get_option('mandir'), 'man' + m.split('.')[-1]),
++      install: true
++    )
++  endforeach
++else
++  warning('Will not build man pages due to missing a2x (asciidoc) dependency!')
++endif
++
++# vim:set ts=2 sw=2 et:
+--- /dev/null
++++ b/src/meson.build
+@@ -0,0 +1,14 @@
++tangd = executable('tangd',
++  'http.h',
++  'http.c',
++  'tangd.c',
++  dependencies: [jose, http_parser],
++  install: true,
++  install_dir: libexecdir
++)
++
++bins += join_paths(meson.current_source_dir(), 'tang-show-keys')
++libexecbins += join_paths(meson.current_source_dir(), 'tangd-keygen')
++libexecbins += join_paths(meson.current_source_dir(), 'tangd-update')
++
++# vim:set ts=2 sw=2 et:
+--- /dev/null
++++ b/tests/meson.build
+@@ -0,0 +1,22 @@
++sd_activate = find_program(
++  'systemd-socket-activate',
++  'systemd-activate',
++  required: false
++)
++
++if sd_activate.found()
++  env = environment()
++  env.prepend('PATH',
++    join_paths(meson.source_root(), 'src'),
++    join_paths(meson.build_root(), 'src'),
++    separator: ':'
++  )
++  env.set('SD_ACTIVATE', sd_activate.path() + ' --inetd')
++
++  test('adv', find_program('adv'), env: env)
++  test('rec', find_program('rec'), env: env)
++else
++  warning('Will not run the tests due to missing dependencies!')
++endif
++
++# vim:set ts=2 sw=2 et:
+--- /dev/null
++++ b/units/meson.build
+@@ -0,0 +1,31 @@
++tangd_keygen_service = configure_file(
++  input: 'tangd-keygen.service.in',
++  output: 'tangd-keygen.service',
++  configuration: data
++)
++
++tangd_service = configure_file(
++  input: 'tangd@.service.in',
++  output: 'tangd@.service',
++  configuration: data
++)
++
++tangd_update_path = configure_file(
++  input: 'tangd-update.path.in',
++  output: 'tangd-update.path',
++  configuration: data
++)
++
++tangd_update_service = configure_file(
++  input: 'tangd-update.service.in',
++  output: 'tangd-update.service',
++  configuration: data
++)
++
++units += join_paths(meson.current_source_dir(), 'tangd.socket')
++units += tangd_keygen_service
++units += tangd_service
++units += tangd_update_path
++units += tangd_update_service
++
++# vim:set ts=2 sw=2 et:
+--- /dev/null
++++ b/units/tangd.socket
+@@ -0,0 +1,14 @@
++[Unit]
++Description=Tang Server socket
++Requires=tangd-keygen.service
++Requires=tangd-update.service
++Requires=tangd-update.path
++After=tangd-keygen.service
++After=tangd-update.service
++
++[Socket]
++ListenStream=80
++Accept=true
++
++[Install]
++WantedBy=multi-user.target
+--- a/units/tangd.socket.in
++++ /dev/null
+@@ -1,14 +0,0 @@
+-[Unit]
+-Description=Tang Server socket
+-Requires=tangd-keygen.service
+-Requires=tangd-update.service
+-Requires=tangd-update.path
+-After=tangd-keygen.service
+-After=tangd-update.service
+-
+-[Socket]
+-ListenStream=80
+-Accept=true
+-
+-[Install]
+-WantedBy=multi-user.target

+ 2 - 2
debian/patches/cherry-pick/1580371641.v7-4-g7778512.fixed-ordering-cycle-found-causing-spurious-issues-during-boot-no.patch

@@ -32,8 +32,8 @@ Date: Thu Jan 30 09:07:21 2020 +0100
     The requirement on tangd-update.service has been removed since it is
     useless: the service doesn't need tangd-update.service at all.
 
---- a/units/tangd.socket.in
-+++ b/units/tangd.socket.in
+--- a/units/tangd.socket
++++ b/units/tangd.socket
 @@ -1,14 +1,9 @@
  [Unit]
  Description=Tang Server socket

+ 28 - 19
debian/patches/for-upstream/2018-08-11.use-asciidoctor-to-build-manpages.patch

@@ -3,25 +3,34 @@ Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
 Date: 2018-08-11
 Bug: https://github.com/latchset/tang/issues/32
 
---- a/Makefile.am
-+++ b/Makefile.am
-@@ -32,7 +32,7 @@
+--- a/meson.build
++++ b/meson.build
+@@ -47,7 +47,7 @@
+ )
  
- $(top_builddir)/%.roff: %.adoc
- 	$(MKDIR_P) $$(dirname $@)
--	$(A2X) -f manpage $^ -D $(top_builddir)/$$(dirname $@)
-+	$(A2X) --attribute reproducible --backend=manpage  $^ -D $(top_builddir)/$$(dirname $@)
- 	$(INSTALL) -m 644 $(top_builddir)/$(@:.roff=) $(top_builddir)/$@
+ jose = dependency('jose', version: '>=8')
+-a2x = find_program('a2x', required: false)
++asciidoctor = find_program('asciidoctor', required: false)
+ compiler = meson.get_compiler('c')
+ if not compiler.has_header('http_parser.h')
+   error('http-parser devel files not found.')
+@@ -70,16 +70,16 @@
+ install_data(units, install_dir: systemunitdir)
+ install_data(licenses, install_dir: licensedir)
  
- man1_MANS += doc/tang-show-keys.1
---- a/configure.ac
-+++ b/configure.ac
-@@ -75,7 +75,7 @@
- "
- AC_SUBST([TANG_CFLAGS])
+-if a2x.found()
++if asciidoctor.found()
+   foreach m : mans
+     custom_target(m.split('/')[-1], input: m + '.adoc', output: m.split('/')[-1],
+-      command: [a2x, '-f', 'manpage', '-D', meson.current_build_dir(), '@INPUT@'],
++      command: [asciidoctor, '--attribute', 'reproducible', '--backend=manpage', '-D', meson.current_build_dir(), '@INPUT@'],
+       install_dir: join_paths(get_option('mandir'), 'man' + m.split('.')[-1]),
+       install: true
+     )
+   endforeach
+ else
+-  warning('Will not build man pages due to missing a2x (asciidoc) dependency!')
++  warning('Will not build man pages due to missing asciidoctor (asciidoc) dependency!')
+ endif
  
--AC_CHECK_PROGS(A2X, [a2x])
-+AC_CHECK_PROGS(A2X, [asciidoctor])
- 
- if test "x$A2X" = "x"; then
-    AC_MSG_WARN([asciidoc / a2x not found -- man pages will not be generated and installed])
+ # vim:set ts=2 sw=2 et:

+ 5 - 3
debian/patches/for-upstream/2018-08-12.add-systemd-documentation-key.patch

@@ -5,10 +5,12 @@ Bug: https://github.com/latchset/tang/issues/49
 
 --- a/units/tangd@.service.in
 +++ b/units/tangd@.service.in
-@@ -1,5 +1,6 @@
+@@ -1,7 +1,6 @@
  [Unit]
  Description=Tang Server
+-Requires=tangd-keygen.service
+-After=tangd-keygen.service
 +Documentation=man:tangd(8)
- Requires=tangd-keygen.service
- After=tangd-keygen.service
  
+ [Service]
+ StandardInput=socket

+ 1 - 0
debian/patches/series

@@ -1,5 +1,6 @@
 
 # cherry-picked commits. Keep in upstream's chronological order
+cherry-pick/1576775046.v7-2-gfed9020.move-build-system-to-meson.patch
 cherry-pick/1580371641.v7-4-g7778512.fixed-ordering-cycle-found-causing-spurious-issues-during-boot-no.patch
 
 # patches for upstream

+ 5 - 1
debian/rules

@@ -5,4 +5,8 @@ DPKG_EXPORT_BUILDFLAGS = 1
 include /usr/share/dpkg/buildflags.mk
 
 %:
-	dh $@
+	dh $@ --buildsystem=meson
+
+override_dh_auto_install:
+	dh_auto_install --buildsystem=meson
+	rm -rf debian/tang/usr/share/licenses