kych

OAuth 2.0 API for Swiyu to enable Taler integration of Swiyu for KYC (experimental)
Log | Files | Refs | Submodules | README | LICENSE

rules (7123B)


      1 #!/usr/bin/make -f
      2 
      3 # The Cargo crate lives in a subdirectory, not at the top of the source tree.
      4 # It has one path dependency, taler-config/, which cargo builds along with it.
      5 CRATE = kych_oauth2_gateway
      6 VENDORED = taler-config
      7 
      8 # Man pages are generated from the reStructuredText that also feeds the website
      9 # build in the taler-docs repository, so that there is a single source for
     10 # them.  documentation/sphinx-man/conf.py is a minimal Sphinx configuration
     11 # holding just the man_pages entries; the sources themselves use only core
     12 # directives, so python3-sphinx alone is enough.
     13 MANSRC = documentation/taler-docs/manpages
     14 MANCONF = documentation/sphinx-man
     15 MANOUT = debian/man
     16 
     17 # The SWIYU Generic Verifier: a separate upstream, maintained by the Swiss
     18 # Confederation and pinned to a release tag in this submodule.  The checkout
     19 # has to be there before the build -- "git submodule update --init" -- which
     20 # the build step checks for rather than producing a confusing Maven error.
     21 VERIFIER = swiyu-verifier/upstream
     22 
     23 # Where the jar lands, under a name that does not carry the version, so that
     24 # debian/swiyu-verifier.install and the systemd unit do not have to change
     25 # with every upstream release.
     26 VERIFIER_JAR = debian/jar/swiyu-verifier.jar
     27 
     28 # The jar is built for Java 25 since the verifier's 5.0.0 release, so the JDK
     29 # is named explicitly: a host that also has an older default JDK would
     30 # otherwise fail the build with a release-version error.
     31 DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
     32 JAVA_HOME ?= /usr/lib/jvm/java-25-openjdk-$(DEB_HOST_ARCH)
     33 
     34 # Keep Maven's repository inside the build tree, for the same reason as
     35 # CARGO_HOME below: the build fetches from Maven Central and must not write to
     36 # $HOME under Rules-Requires-Root: no.
     37 #
     38 # "clean" removes it, as it must for a package build, which means every build
     39 # re-downloads some 300 MB from Maven Central.  For repeated builds while
     40 # developing, point it at a cache outside the tree -- it is then not removed
     41 # either:
     42 #     MAVEN_REPO=$HOME/.m2/repository dpkg-buildpackage -b -uc -us
     43 MAVEN_REPO ?= $(CURDIR)/debian/m2
     44 
     45 # -Dpgpverify.skip=true: upstream binds the pgpverify plugin to the "validate"
     46 # phase, which checks the PGP signature of every dependency against
     47 # pgp/keys.list by querying public keyservers.  That is a worthwhile check in
     48 # upstream's CI, where its key cache is warm, but in a package build it makes
     49 # the build depend on keys.openpgp.org being reachable and is upstream's own
     50 # documented escape hatch (see the comment in their pom.xml).
     51 #
     52 # -DskipTests: the verifier's own test suite needs Testcontainers, hence a
     53 # container runtime, which a package build does not have.
     54 MAVEN_FLAGS = -B -DskipTests -Dpgpverify.skip=true -Dmaven.repo.local=$(MAVEN_REPO)
     55 
     56 # Keep cargo's registry and cache inside the build tree.  cargo fetches crates
     57 # from the network at build time (this is not an archive-policy-clean offline
     58 # build), and without this it would write to $HOME, which is not ours to touch
     59 # under Rules-Requires-Root: no.
     60 export CARGO_HOME = $(CURDIR)/debian/cargo
     61 
     62 # --with installsysusers: dh_installsysusers (which turns debian/kych.sysusers
     63 # into the /usr/lib/sysusers.d entry that creates the "kych" system user) only
     64 # joins the sequence automatically from debhelper compat 14 onwards.  Without
     65 # this the package would install but the service could not start.
     66 %:
     67 	dh $@ --no-parallel --with installsysusers
     68 
     69 # Nothing to configure: debian/kych.install names explicit paths and the build
     70 # only needs a cargo from $PATH (see Build-Depends).  The step is still
     71 # overridden so that dh does not try to auto-detect a build system in the
     72 # top-level directory, which holds no build files of its own.
     73 override_dh_auto_configure:
     74 
     75 override_dh_auto_build:
     76 	cargo build --release --manifest-path $(CRATE)/Cargo.toml
     77 	sphinx-build -b man -q -c $(MANCONF) $(MANSRC) $(MANOUT)
     78 # The submodule is not part of a plain "git clone" and is not in a source
     79 # tarball either, so say so clearly instead of letting Maven complain about a
     80 # missing pom.
     81 	@test -f $(VERIFIER)/pom.xml || { \
     82 	  echo "$(VERIFIER) is empty: run 'git submodule update --init'" >&2; \
     83 	  exit 1; \
     84 	}
     85 	@test -x $(JAVA_HOME)/bin/javac || { \
     86 	  echo "No JDK at $(JAVA_HOME); install openjdk-25-jdk-headless" >&2; \
     87 	  exit 1; \
     88 	}
     89 	cd $(VERIFIER) && JAVA_HOME=$(JAVA_HOME) mvn $(MAVEN_FLAGS) package
     90 	mkdir -p $(dir $(VERIFIER_JAR))
     91 # Exactly one jar, and not the ".jar.original" that the Spring Boot plugin
     92 # leaves next to it: a glob that matched both would install the wrong one.
     93 	cp $(VERIFIER)/verifier-application/target/swiyu-verifier-application-*.jar \
     94 	  $(VERIFIER_JAR)
     95 
     96 # The unit tests would run without a database, but the two integration suites
     97 # in $(CRATE)/tests/ need a live PostgreSQL reachable through $DATABASE_URL and
     98 # silently skip themselves when it is absent -- running them here would report
     99 # a pass without having tested anything.  Test against a database instead:
    100 #   DATABASE_URL=postgres:///kych_test cargo test --manifest-path $(CRATE)/Cargo.toml
    101 override_dh_auto_test:
    102 
    103 override_dh_auto_install:
    104 
    105 override_dh_auto_clean:
    106 	rm -rf $(CARGO_HOME) $(CRATE)/target $(VENDORED)/target $(MANOUT)
    107 	rm -rf $(dir $(VERIFIER_JAR))
    108 # Only the in-tree Maven repository; one the developer pointed elsewhere with
    109 # MAVEN_REPO is a cache of theirs and not ours to delete.
    110 	test "$(MAVEN_REPO)" != "$(CURDIR)/debian/m2" || rm -rf $(MAVEN_REPO)
    111 # Only if the submodule is actually checked out; "clean" has to work on a
    112 # tree where it is not.
    113 	@test ! -f $(VERIFIER)/pom.xml || \
    114 	  rm -rf $(VERIFIER)/verifier-application/target $(VERIFIER)/verifier-service/target
    115 
    116 # Both kych units ship disabled, and so does swiyu-verifier.service.  The
    117 # gateway cannot run before the administrator has created the database and
    118 # edited kych.conf (see README.Debian), and
    119 # kych.socket is only correct once SERVE is switched to "systemd" -- with the
    120 # shipped SERVE = unix the daemon binds UNIXPATH itself and an enabled socket
    121 # unit would fight it for the same path.  The verifier is in the same
    122 # position: without a DID and a signing key of its own it has nothing to
    123 # verify with.
    124 #
    125 # Being disabled is also what keeps a first install from starting anything,
    126 # which is why the flags are only --no-enable: debhelper's default
    127 # --restart-after-upgrade then generates a postinst that calls
    128 # "deb-systemd-invoke start" on a first install and "... restart" on an
    129 # upgrade.  deb-systemd-invoke skips a disabled unit on "start", so nothing
    130 # comes up on a first install, but on "restart" it does act on a disabled unit
    131 # that is running -- which is what makes an upgrade pick up the new binary,
    132 # even for a service an administrator started without enabling it.  The
    133 # service is not stopped during the unpack either, so the restart is the only
    134 # interruption.
    135 #
    136 # Do NOT add --no-stop-on-upgrade here: despite the name it also turns off the
    137 # restart (see its description in dh_installsystemd(1)), leaving the old
    138 # binary running after an upgrade.
    139 override_dh_installsystemd:
    140 	dh_installsystemd --no-enable --restart-after-upgrade