Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use jinja2 for templating #19630

Merged
merged 36 commits into from
May 19, 2021
Merged

Use jinja2 for templating #19630

merged 36 commits into from
May 19, 2021

Conversation

keszybz
Copy link
Member

@keszybz keszybz commented May 16, 2021

m4 use is dropped, and the two parallel substitution systems in meson are unified.

@keszybz
Copy link
Member Author

keszybz commented May 16, 2021

I guess the CI will fail with missing deps… This will need to be figured out.

@bluca
Copy link
Member

bluca commented May 16, 2021

I guess the CI will fail with missing deps… This will need to be figured out.

Pushed to Salsa for the bionic tests. PR for the CentOS tests: systemd/systemd-centos-ci#382

bluca added a commit to bluca/systemd-centos-ci that referenced this pull request May 16, 2021
.mkosi/mkosi.arch Outdated Show resolved Hide resolved
mrc0mmand pushed a commit to systemd/systemd-centos-ci that referenced this pull request May 16, 2021
@bluca
Copy link
Member

bluca commented May 16, 2021

Looks very nice! But the CI is a bit unhappy:

305/890 test-sysusers                           FAIL     0.02 s (exit status 127)

--- command ---
18:45:07 /usr/bin/env /home/runner/work/systemd/systemd/build/test/test-sysusers.sh /home/runner/work/systemd/systemd/build/systemd-sysusers
--- stderr ---
/usr/bin/env: ‘/home/runner/work/systemd/systemd/build/test/test-sysusers.sh’: No such file or directory

@bluca bluca added the ci-fails/needs-rework 🔥 Please rework this, the CI noticed an issue with the PR label May 16, 2021
@evverx
Copy link
Member

evverx commented May 16, 2021

@bluca judging by https://autopkgtest.ubuntu.com/results/autopkgtest-bionic-upstream-systemd-ci-systemd-ci/bionic/amd64/s/systemd-upstream/20210516_223707_2a255@/log.gz (from #19598)

dpkg-checkbuilddeps: error: Unmet build dependencies: python3-jinja2:native
dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting
dpkg-buildpackage: warning: (Use -d flag to override.)
blame: https://salsa.debian.org/systemd-team/systemd.git#upstream-ci
badpkg: rules build failed with exit code 3
autopkgtest [22:36:55]: ERROR: erroneous package: rules build failed with exit code 3
Creating nova instance adt-bionic-amd64-systemd-upstream-20210516-223416 from image adt/ubuntu-bionic-amd64-server-20210516.img (UUID ef35f45b-f21e-48c4-a39c-82ebd5575ffa)... 

Ubuntu CI is broken

@bluca
Copy link
Member

bluca commented May 16, 2021

@bluca judging by https://autopkgtest.ubuntu.com/results/autopkgtest-bionic-upstream-systemd-ci-systemd-ci/bionic/amd64/s/systemd-upstream/20210516_223707_2a255@/log.gz (from #19598)

dpkg-checkbuilddeps: error: Unmet build dependencies: python3-jinja2:native
dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting
dpkg-buildpackage: warning: (Use -d flag to override.)
blame: https://salsa.debian.org/systemd-team/systemd.git#upstream-ci
badpkg: rules build failed with exit code 3
autopkgtest [22:36:55]: ERROR: erroneous package: rules build failed with exit code 3
Creating nova instance adt-bionic-amd64-systemd-upstream-20210516-223416 from image adt/ubuntu-bionic-amd64-server-20210516.img (UUID ef35f45b-f21e-48c4-a39c-82ebd5575ffa)... 

Ubuntu CI is broken

Ah yes, jijnja is arch:all so the :native suffix is wrong - removed

@keszybz
Copy link
Member Author

keszybz commented May 17, 2021

Updated:

  • no "2" for arch
  • add depends:... in test-sysusers tests.

Let's see if this helps.

@keszybz
Copy link
Member Author

keszybz commented May 17, 2021

Updated:

  • env python3 not env python

DavidKorczynski pushed a commit to google/oss-fuzz that referenced this pull request May 17, 2021
For systemd/systemd#19630:
m4 is being replaced by jinja2. Let's pull in both until the dust settles.
@bluca
Copy link
Member

bluca commented May 17, 2021

I'm not sure where semaphore is getting the list of build-dependencies - it's not from the upstream-ci branch in Salsa, as I've updated it. Maybe from the uploaded package - in which case python3-jinja2 needs to be added manually to .semaphore/semaphore-runner.sh for now

@bluca
Copy link
Member

bluca commented May 17, 2021

This is a strange one, in CentOS:

tmpfiles.d/meson.build:35:8: ERROR:  Tried to create target "systemd.conf", but a target of that name already exists.

@keszybz
Copy link
Member Author

keszybz commented May 17, 2021

One more attempt:

  • the oss-fuzz pr has been merged
  • workaround for old meson
  • python3-jinja2 is mentioned in .semaphore/semaphore-runner.sh

@keszybz
Copy link
Member Author

keszybz commented May 17, 2021

Another attempt:

  • require bash explicitly where dash is not enough

keszybz added 22 commits May 19, 2021 10:24
We were using both in various places. To keep things simple, let
rpm do the substitution.
The naming of variables is very inconsistent. I tried to use more
modern style naming (UNDERSCORED_TITLE_CASE), but I didn't change existing
names too much. Only SYSTEM_DATA_UNIT_PATH is renamed to SYSTEM_DATA_UNIT_DIR
to match SYSTEM_CONFIG_UNIT_DIR.
One stanza had "if install_sysconfdir_samples", while the other
"if install_sysconfdir", which looks like a mistake.
install_sysconfdir_samples is now used for both.
We had two big 'configuration_data' objects in meson config. (There are in fact
more. On is added in this series, and there's one for efi… But those others
have a handful variables only for specific purposes and don't matter). The two
sets are 'conf' and 'substs', and were inherited from the original autotools
system. In the past there was even a third set ('m4_defines'), but @yuwata
removed it in 348b443. And those two/three
systems had very similar data, but with different variable names, because of
historical reasons. They also used subtly different quoting (.set()
vs. .set10() vs. .set_quoted()), which was required because the templating
engines were not flexible enough. This meants we had more work when changing
things, and we needed to search for different variable names, etc.

With a more flexible templating engine we can do with just one
configuration_data object.
This doesn't matter too much, but makes things a bit more consistent.
A minor advantage is that the file is not a configuration file for meson
anymore, so:
 a) It is not built unless pulled in by another target. Since
    we don't usually build man pages by default, this saves a tiny
    amount of work.
 b) When the .in file is updated, meson does not reconfigure everything,
    but just rebuilds the dependent targets.

Now that the conversion is finished, time for benchmarking:
a full build with default settings (and -Dstandalonebinaries=true), yields

before this pull request: 1687 targets, 148.13s user 35.17s system 317% cpu 57.697 total
with the full pull request: 1714 targets, 143.07s user 27.87s system 314% cpu 54.369 total

The difference doesn't seem significant. Partial rebuilds might be faster as
mentioned before.
We can generate the right string in the template directly.
Let's use the same names as in the jinja2 substitutions.
The order was a complete mess. Let's make it a bit more tidy.
Recent meson versions include the directory name in the target name,
so there is no conflict for files with the same name in different
directories. But at least with meson-0.49.2 in buster we have conflict
with sysusers.d/systemd.conf.
@yuwata
Copy link
Member

yuwata commented May 19, 2021

Rebased and force-pushed. CIs were already green. Merging.

@yuwata yuwata merged commit 6b87254 into systemd:main May 19, 2021
@keszybz keszybz deleted the jinja2 branch May 19, 2021 08:30
ddstreet pushed a commit to ddstreet/systemd that referenced this pull request Jul 1, 2021
DaanDeMeyer pushed a commit to DaanDeMeyer/systemd-rpm that referenced this pull request Jul 7, 2022
python3-devel hasn't been needed since we split out the python module,
a few years ago.

Pull in jinja2 for systemd/systemd#19630.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

5 participants