From 359b91a9f9674b1b4d39ee41c223b475fe617fed Mon Sep 17 00:00:00 2001 From: Michal Vyskocil Date: Mon, 9 Jan 2017 21:46:13 +0100 Subject: [PATCH 1/2] Problem: can't install additional files via project.xml Solution: introduce zinstall, the zero model for file installation The beauty of this model (as opposite of PR#539) is that it impose clear protocol between model and rest of the generators. This protocol are files in builds/zinstall/, which are then included in generated files. This has two main advantages over older attempts 1. installation model fully implemented in ONE place 2. because of the protocol, there can be more models w/o any impact on backend Design goals are stated in README.txt, but let's repease 1. KISS - the less options the better 2. No conditionals - please don't create an another half-baked XML programming langugage like ant 3. Real problems - don't add more options because you can ... or you will get replaced by zinstall2 ;-) --- README.txt | 22 ++++++++++++++++++++++ zproject.gsl | 3 +++ zproject_autotools.gsl | 4 ++++ zproject_debian.gsl | 1 + zproject_redhat.gsl | 1 + 5 files changed, 31 insertions(+) diff --git a/README.txt b/README.txt index 8979ead0..4391e8c5 100644 --- a/README.txt +++ b/README.txt @@ -432,6 +432,28 @@ Using autotools or CMake, you can specify --with-drafts to enable draft APIs, an make uninstall ``` +## Additional files +Installation of third party files is a *hard* problem. It is not platform +independent, became hard to maintain and impossible to use correctly. One of +zproject's goals is a simplicity. There is a simple installation model + +### Design goals +* KISS, less configuration options the better +* no conditionals in the model, those SHALL be handled in background +* each option solves a REAL problem, avoid extending it because you can + +### Example +``` +
+ +
+``` + +This will add install information about systemd tmpfiles.d configuration files +to autotools, packaging, and so. The resulting file +/usr/lib/tmpfiles.d/MAIN.conf will be installed only if configure was called +with --with-systemd-units. + ## Notes for Writing Language Targets This is the general form of a target: diff --git a/zproject.gsl b/zproject.gsl index e7480e46..cb9206f0 100644 --- a/zproject.gsl +++ b/zproject.gsl @@ -172,6 +172,9 @@ gsl from "zproject_bench.gsl" gsl from "zproject_git.gsl" gsl from "zproject_valgrind.gsl" +# zinstall must run before all the targets +gsl from "zproject_install.gsl" + # Load all targets gsl from "zproject_android.gsl" gsl from "zproject_autotools.gsl" diff --git a/zproject_autotools.gsl b/zproject_autotools.gsl index 1bcf1eee..fd9e98e2 100644 --- a/zproject_autotools.gsl +++ b/zproject_autotools.gsl @@ -635,6 +635,8 @@ AM_COND_IF([WITH_SYSTEMD_UNITS], .endif +.zinstall_include ("builds/zinstall/configure.ac") + AC_OUTPUT # Print configure summary and list make options @@ -1073,6 +1075,8 @@ coverage: src/$(project.prefix)_selftest \t@echo "call make clean && configure --with-gcov to enable code coverage" \t@exit 1 endif +.zinstall_include ("builds/zinstall/Makemodule.am") + $(project.GENERATED_WARNING_HEADER:) .# diff --git a/zproject_debian.gsl b/zproject_debian.gsl index 7f5c1cd1..7a5a3007 100644 --- a/zproject_debian.gsl +++ b/zproject_debian.gsl @@ -220,6 +220,7 @@ usr/bin/$(bin.name) etc/$(project.name)/$(main.name).cfg lib/systemd/system/$(main.name){,@*}.{service,*} . endfor +.zinstall_include ("builds/zinstall/$(project.name).install") .endif .if project.exports_classes diff --git a/zproject_redhat.gsl b/zproject_redhat.gsl index 5e36effb..76980c4c 100644 --- a/zproject_redhat.gsl +++ b/zproject_redhat.gsl @@ -214,6 +214,7 @@ find %{buildroot} -name '*.la' | xargs rm -f .if etc_exists ?= 1 %dir %{_sysconfdir}/$(project.name) .endif +.zinstall_include ("builds/zinstall/$(project.name).spec") .if systemd ?= 1 %if 0%{?suse_version} > 1315 %post From 1222479f839ea531fa19d1a2e623dada1050534d Mon Sep 17 00:00:00 2001 From: Michal Vyskocil Date: Mon, 9 Jan 2017 21:58:54 +0100 Subject: [PATCH 2/2] Problem: missing zproject_install.gsl Solution: add it to git --- zproject_install.gsl | 52 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 zproject_install.gsl diff --git a/zproject_install.gsl b/zproject_install.gsl new file mode 100644 index 00000000..1c09c7ee --- /dev/null +++ b/zproject_install.gsl @@ -0,0 +1,52 @@ +# Generate install files snippets for zproject +# +# This is a code generator built using the iMatix GSL code generation +# language. See https://github.com/imatix/gsl for details. +# +# Copyright (c) the Contributors as noted in the AUTHORS file. +# This file is part of zproject. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +function zinstall_include (filename) + if file.exists ("$(my.filename:)") + input = file.open ("$(my.filename:)") + xline = file.read (input) + while defined (xline) + >$(string.replace (xline, "\n|")) + xline = file.read (input)? + endwhile + endif +endfunction + +echo "###### zinstall #####" +directory.create ("builds/zinstall") +for project.main where defined (main->install) + for install + if install.type = "systemd-tmpfiles" + + output "builds/zinstall/configure.ac" +>AM_COND_IF([WITH_SYSTEMD_UNITS], +> [AC_CONFIG_FILES([ +> src/$(main.name).conf +> ])], +> []) + output "builds/zinstall/Makemodule.am" +>if WITH_SYSTEMD_UNITS +>$(main.name:c)_tmpfiles_ddir = /usr/lib/tmpfiles.d/ +>$(main.name:c)_tmpfiles_d_DATA = src/$(main.name).conf +>endif #WITH_SYSTEMD_UNITS + + output "builds/zinstall/$(project.name).spec" +>%dir /usr/lib/tmpfiles.d/ +>%config /usr/lib/tmpfiles.d/$(main.name).conf + + output "builds/zinstall/$(project.name).install" +>usr/lib/tmpfiles.d/$(main.name).conf + + endif #systemd-tmpfiles + endfor +endfor