URL: https://github.com/freeipa/freeipa/pull/233
Author: pspacek
 Title: #233: Build phase 6: %install cleanup
Action: opened

PR body:
"""
This patch set is based on phase 5 - PR #226.

Now all the installation steps (except Python2/3) are handled by make install.

Python 2/3 support will deserve separate PR.
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/233/head:pr233
git checkout pr233
From 426cb96d11776215fca9aea144482087e4bef244 Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Wed, 9 Nov 2016 15:42:30 +0100
Subject: [PATCH 01/11] Build: remove unused and redundant code from
 configure.ac and po/Makefile.in

https://fedorahosted.org/freeipa/ticket/6418
---
 configure.ac   | 4 ----
 po/Makefile.in | 1 -
 2 files changed, 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6e82c62..5646cb0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,9 +17,6 @@ AC_HEADER_STDC
 
 AM_CONDITIONAL([HAVE_GCC], [test "$ac_cv_prog_gcc" = yes])
 
-AC_SUBST(VERSION)
-AC_SUBST([INSTALL_DATA], ['$(INSTALL) -m 644 -p'])
-
 dnl ---------------------------------------------------------------------------
 dnl - Check for NSPR/NSS
 dnl ---------------------------------------------------------------------------
@@ -359,7 +356,6 @@ AC_ARG_WITH([vendor-suffix],
             [VENDOR_SUFFIX=${withval}],
 	    [VENDOR_SUFFIX=""])
 
-dnl TODO: IPA_VENDOR_RELEASE
 AC_SUBST([API_VERSION], [IPA_API_VERSION])
 AC_SUBST([DATA_VERSION], [IPA_DATA_VERSION])
 AC_SUBST([NUM_VERSION], [IPA_NUM_VERSION])
diff --git a/po/Makefile.in b/po/Makefile.in
index b42d8fc..0ab449c 100644
--- a/po/Makefile.in
+++ b/po/Makefile.in
@@ -5,7 +5,6 @@ datadir = ${datarootdir}
 localedir = ${datarootdir}/locale
 
 INSTALL = @INSTALL@
-INSTALL_DATA = @INSTALL@ -m 644
 AWK = @AWK@
 SED = @SED@
 MKDIR_P = @MKDIR_P@

From 30997f510be880339face8656343536705e5d359 Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Wed, 9 Nov 2016 16:15:19 +0100
Subject: [PATCH 02/11] Build: IPA_VERSION_IS_GIT_SNAPSHOT checks if source
 directory is Git repo

https://fedorahosted.org/freeipa/ticket/6418
---
 configure.ac | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/configure.ac b/configure.ac
index 5646cb0..1b672fb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -350,6 +350,17 @@ AC_MSG_RESULT([${IPAPLATFORM}])
 dnl ---------------------------------------------------------------------------
 dnl Version information from VERSION.m4 and command line
 dnl ---------------------------------------------------------------------------
+dnl Are we in source tree?
+AM_CONDITIONAL([IS_GIT_SNAPSHOT], [test "IPA_VERSION_IS_GIT_SNAPSHOT" == "yes"])
+AM_COND_IF([IS_GIT_SNAPSHOT], [
+	AC_MSG_CHECKING([if source directory is a Git reposistory])
+	if test ! -d "${srcdir}/.git"; then
+		AC_MSG_ERROR([Git reposistory is required by VERSION.m4 IPA_VERSION_IS_GIT_SNAPSHOT but not found])
+	else
+		AC_MSG_RESULT([yes])
+	fi
+])
+
 AC_ARG_WITH([vendor-suffix],
             AS_HELP_STRING([--with-vendor-suffix=STRING],
 			   [Vendor string used by package system, e.g. "-1.fc24"]),

From 4ad2581cbbd97f180cc19af8f746df378a595284 Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Wed, 9 Nov 2016 16:21:51 +0100
Subject: [PATCH 03/11] Build: use POSIX 1003.1-1988 (ustar) file format for
 tar archives

Default format used by Autotools limits length of paths to
99 characters. This is not enough for tarballs with Git snapshots.

https://fedorahosted.org/freeipa/ticket/6418
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 1b672fb..53d5dab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6,7 +6,7 @@ AC_INIT([freeipa],
 
 AC_CONFIG_HEADERS([config.h])
 
-AM_INIT_AUTOMAKE([foreign])
+AM_INIT_AUTOMAKE([foreign 1.9 tar-ustar])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
 
 AC_PROG_CC_C99

From 535bb2c18bc2b977d3b836743e88a8f6d80654c4 Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Wed, 9 Nov 2016 16:16:45 +0100
Subject: [PATCH 04/11] Build: IPA_VERSION_IS_GIT_SNAPSHOT re-generates version
 number on RPM build

This is a huge hack. rpms target will touch VERSION.m4 file. This change
is then detected by automake Makefiles which subsequently re-execute configure
and make.

We have to workaround fact that variables in new make targets
(executed after new configure) are different than original ones.

Also, we have to 'bake-in' precise snapshot version from Git to
VERSION.m4 inside of RPM tarball so the RPM does not depend on git
anymore.

All this magic slows build down a bit.
Do not enable IPA_VERSION_IS_GIT_SNAPSHOT if you want fastest possible builds.

The option IPA_VERSION_IS_GIT_SNAPSHOT is now enabled by default as it
was before we started the build system refactoring effort.

https://fedorahosted.org/freeipa/ticket/6418
---
 .gitignore   |  2 ++
 Makefile.am  | 51 +++++++++++++++++++++++++++++++++++++++++++++------
 VERSION.m4   | 24 ++++++++++++++----------
 configure.ac |  1 +
 4 files changed, 62 insertions(+), 16 deletions(-)

diff --git a/.gitignore b/.gitignore
index e1a42d6..de61aff 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,6 +28,8 @@ build/
 compile
 test-driver
 freeipa-*.tar.gz
+.tarball_name
+.version
 
 # Python compilation
 *.pyc
diff --git a/Makefile.am b/Makefile.am
index 031aef4..8953375 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,8 +4,7 @@ MOSTLYCLEANFILES = ipasetup.pyc ipasetup.pyo \
 		   ignore_import_errors.pyc ignore_import_errors.pyo \
 		   ipasetup.pyc ipasetup.pyo \
 		   lite-server.pyc lite-server.pyo \
-		   pylint_plugins.pyc pylint_plugins.pyo \
-		   $(TARBALL)
+		   pylint_plugins.pyc pylint_plugins.pyo
 
 # user-facing scripts
 dist_bin_SCRIPTS = ipa
@@ -34,8 +33,12 @@ clean-local:
 	rm -rf "$(RPMBUILD)"
 	rm -rf "$(top_builddir)/dist"
 	rm -rf "$(top_srcdir)/__pycache__"
+	rm -f "$(top_builddir)"/$(PACKAGE)-*.tar.gz
+
 
 # convenience targets for RPM build
+.PHONY: rpmroot rpmdistdir version-update _dist-version-bakein _rpms-prep \
+	rpms _rpms-body
 RPMBUILD ?= $(abs_builddir)/rpmbuild
 TARBALL = $(PACKAGE)-$(VERSION).tar.gz
 rpmroot:
@@ -49,11 +52,47 @@ rpmdistdir:
 	mkdir -p $(top_builddir)/dist/rpms
 	mkdir -p $(top_builddir)/dist/srpms
 
-rpms: dist-gzip rpmroot rpmdistdir
-	cp $(top_builddir)/$(TARBALL) $(RPMBUILD)/SOURCES/
+# force IPA version re-generation (useful for build from Git)
+version-update:
+	touch $(srcdir)/VERSION.m4
+
+# convert Git snapshot version to static value usable from inside of tarball
+_dist-version-bakein:
+if !IS_GIT_SNAPSHOT
+	@echo "version-bakein target requires IPA_VERSION_IS_GIT_SNAPSHOT=yes"
+	exit 1
+endif !IS_GIT_SNAPSHOT
+	chmod u+w $(top_distdir)/VERSION.m4
+	$(SED) -e 's/^define(IPA_VERSION_IS_GIT_SNAPSHOT,.*)/define(IPA_VERSION_IS_GIT_SNAPSHOT, no)/' -i $(top_distdir)/VERSION.m4
+	$(SED) -e 's/^define(IPA_VERSION_PRE_RELEASE,\(.*\))/define(IPA_VERSION_PRE_RELEASE,\1.$(GIT_VERSION))/' -i $(top_distdir)/VERSION.m4
+	cd $(top_distdir) && autoconf  # re-generate configure from VERSION.m4
+
+if IS_GIT_SNAPSHOT
+VERSION_UPDATE_TARGET = version-update
+VERSION_BAKEIN_TARGET = _dist-version-bakein
+endif IS_GIT_SNAPSHOT
+
+# HACK to support IPA_VERSION_IS_GIT_SNAPSHOT:
+# touch VERSION.m4 will reexecute configure and change $(VERSION) used by dist
+# but it will not change $(VERSION) in already running target rpms.
+# We need to record new $(TARBALL) value used by dist for furher use
+# in rpms target.
+dist-hook: $(VERSION_BAKEIN_TARGET)
+	echo "$(TARBALL)" > $(top_builddir)/.tarball_name
+	echo "$(VERSION)" > $(top_builddir)/.version
+
+_rpms-prep: dist-gzip rpmroot rpmdistdir
+	cp $(top_builddir)/$$(cat $(top_builddir)/.tarball_name) $(RPMBUILD)/SOURCES/
+	rm -f $(top_builddir)/.tarball_name
+
+rpms: $(VERSION_UPDATE_TARGET)
+	$(MAKE) _rpms-body
+
+_rpms-body: _rpms-prep
 	rpmbuild --define "_topdir $(RPMBUILD)" -ba $(top_builddir)/$(PACKAGE).spec
-	cp $(RPMBUILD)/RPMS/*/*.rpm $(top_builddir)/dist/rpms/
-	cp $(RPMBUILD)/SRPMS/*.src.rpm $(top_builddir)/dist/srpms/
+	cp $(RPMBUILD)/RPMS/*/*$$(cat $(top_builddir)/.version)*.rpm $(top_builddir)/dist/rpms/
+	cp $(RPMBUILD)/SRPMS/*$$(cat $(top_builddir)/.version)*.src.rpm $(top_builddir)/dist/srpms/
+	rm -f rm -f $(top_builddir)/.version
 
 .PHONY: lint
 if WITH_POLINT
diff --git a/VERSION.m4 b/VERSION.m4
index 236a406..75326fb 100644
--- a/VERSION.m4
+++ b/VERSION.m4
@@ -46,7 +46,7 @@ define(IPA_VERSION_PRE_RELEASE, )
 # This option works only with GNU m4:                  #
 # it requires esyscmd m4 macro.                        #
 ########################################################
-define(IPA_VERSION_IS_GIT_SNAPSHOT, no)
+define(IPA_VERSION_IS_GIT_SNAPSHOT, yes)
 
 ########################################################
 # The version of IPA data. This is used to identify    #
@@ -105,24 +105,28 @@ dnl helper for translit in IPA_VERSION
 define(NEWLINE,`
 ')
 
-define(IPA_VERSION, translit(dnl remove new lines from version (from esyscmd)
+dnl Git snapshot: 20170102030405.GITabcdefg
+define(IPA_GIT_VERSION, translit(dnl remove new lines from version (from esyscmd)
 ifelse(IPA_VERSION_IS_GIT_SNAPSHOT, yes,dnl
-dnl Git snapshot: 1.0.0.20170102030405.GITabcdefg
-IPA_VERSION_MAJOR.IPA_VERSION_MINOR.IPA_VERSION_RELEASE.dnl 1.0.0
 esyscmd(date -u +'%Y%m%d%H%M')dnl 20170102030405
 .GIT
 esyscmd(git log -1 --format="%h" HEAD),dnl abcdefg
-dnl Git end
-ifelse(IPA_VERSION_PRE_RELEASE, ,
-dnl Release version: 1.0.0
-IPA_VERSION_MAJOR.IPA_VERSION_MINOR.IPA_VERSION_RELEASE,
-dnl Pre-release: 1.0.0rc1; newline separates m4 tokens
+), NEWLINE))
+dnl IPA_GIT_VERSION end
+
+define(IPA_VERSION, translit(dnl remove new lines from version (from esyscmd)
+dnl 1.0.0
 IPA_VERSION_MAJOR.IPA_VERSION_MINOR.IPA_VERSION_RELEASE
-IPA_VERSION_PRE_RELEASE)),
+IPA_VERSION_PRE_RELEASE
+dnl version with Git snapshot: 1.0.0.20170102030405.GITabcdefg
+ifelse(IPA_VERSION_IS_GIT_SNAPSHOT, yes,
+.
+IPA_GIT_VERSION),
 NEWLINE)) dnl IPA_VERSION end
 
 dnl DEBUG: uncomment following lines and run command m4 VERSION.m4
 dnl `IPA_VERSION: ''IPA_VERSION'
+dnl `IPA_GIT_VERSION: ''IPA_GIT_VERSION'
 dnl `IPA_API_VERSION: ''IPA_API_VERSION'
 dnl `IPA_DATA_VERSION: ''IPA_DATA_VERSION'
 dnl `IPA_NUM_VERSION: ''IPA_NUM_VERSION'
diff --git a/configure.ac b/configure.ac
index 53d5dab..4d0b09c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -372,6 +372,7 @@ AC_SUBST([DATA_VERSION], [IPA_DATA_VERSION])
 AC_SUBST([NUM_VERSION], [IPA_NUM_VERSION])
 AC_SUBST(VENDOR_SUFFIX)
 AC_SUBST([VERSION], [IPA_VERSION])
+AC_SUBST([GIT_VERSION], [IPA_GIT_VERSION])
 
 dnl ---------------------------------------------------------------------------
 dnl Finish

From 65d81b49ed146625201441a40006ab8be3d9960e Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Thu, 10 Nov 2016 10:14:32 +0100
Subject: [PATCH 05/11] Build: add make srpms target

https://fedorahosted.org/freeipa/ticket/6418
---
 Makefile.am | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index 8953375..159d396 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -38,7 +38,7 @@ clean-local:
 
 # convenience targets for RPM build
 .PHONY: rpmroot rpmdistdir version-update _dist-version-bakein _rpms-prep \
-	rpms _rpms-body
+	rpms _rpms-body srpms _srpms-body
 RPMBUILD ?= $(abs_builddir)/rpmbuild
 TARBALL = $(PACKAGE)-$(VERSION).tar.gz
 rpmroot:
@@ -94,6 +94,14 @@ _rpms-body: _rpms-prep
 	cp $(RPMBUILD)/SRPMS/*$$(cat $(top_builddir)/.version)*.src.rpm $(top_builddir)/dist/srpms/
 	rm -f rm -f $(top_builddir)/.version
 
+srpms: $(VERSION_UPDATE_TARGET)
+	$(MAKE) _srpms-body
+
+_srpms-body: _rpms-prep
+	rpmbuild --define "_topdir $(RPMBUILD)" -bs $(top_builddir)/$(PACKAGE).spec
+	cp $(RPMBUILD)/SRPMS/*$$(cat $(top_builddir)/.version)*.src.rpm $(top_builddir)/dist/srpms/
+	rm -f rm -f $(top_builddir)/.version
+
 .PHONY: lint
 if WITH_POLINT
 POLINT_TARGET = polint

From 4720d4bd3977f4134ab99b535abb7d8b9237710e Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Thu, 10 Nov 2016 10:55:59 +0100
Subject: [PATCH 06/11] Build: update IPA_VERSION_IS_GIT_SNAPSHOT to comply
 with PEP440

Python setuptools started to warn about forward incompatibility.
Now we are following PEP440 so it should not cause any problems
with future versions of setuptools.

https://fedorahosted.org/freeipa/ticket/6418
---
 VERSION.m4 | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/VERSION.m4 b/VERSION.m4
index 75326fb..7d9e107 100644
--- a/VERSION.m4
+++ b/VERSION.m4
@@ -5,7 +5,7 @@
 # 1.0.x                  New production series         #
 # 1.0.x{alpha,beta,rc}y  Alpha/Preview/Testing, Beta,  #
 #                           Release Candidate          #
-# 1.0.0.20170102030405.GITabcdefg  Build from GIT      #
+# 1.0.0.dev20170102030405+gitabcdefg  Build from GIT   #
 #                                                      #
 ########################################################
 
@@ -38,10 +38,10 @@ define(IPA_VERSION_PRE_RELEASE, )
 # in the development BRANCH, and set to 'no' only in   #
 # the IPA_X_X_RELEASE BRANCH                           #
 #                                                      #
-# <MAJOR>.<MINOR>.<RELEASE>.<TIMESTAMP>.GIT<hash>      #
+# <MAJOR>.<MINOR>.<RELEASE>.dev<TIMESTAMP>+git<hash>   #
 #                                                      #
 # e.g. define(IPA_VERSION_IS_GIT_SNAPSHOT, yes)        #
-#  ->  "1.0.0.20170102030405.GITabcdefg"               #
+#  ->  "1.0.0.dev20170102030405+gitabcdefg"            #
 #                                                      #
 # This option works only with GNU m4:                  #
 # it requires esyscmd m4 macro.                        #
@@ -105,11 +105,12 @@ dnl helper for translit in IPA_VERSION
 define(NEWLINE,`
 ')
 
-dnl Git snapshot: 20170102030405.GITabcdefg
+dnl Git snapshot: dev20170102030405+gitabcdefg
 define(IPA_GIT_VERSION, translit(dnl remove new lines from version (from esyscmd)
 ifelse(IPA_VERSION_IS_GIT_SNAPSHOT, yes,dnl
+dev
 esyscmd(date -u +'%Y%m%d%H%M')dnl 20170102030405
-.GIT
++git
 esyscmd(git log -1 --format="%h" HEAD),dnl abcdefg
 ), NEWLINE))
 dnl IPA_GIT_VERSION end
@@ -118,7 +119,7 @@ define(IPA_VERSION, translit(dnl remove new lines from version (from esyscmd)
 dnl 1.0.0
 IPA_VERSION_MAJOR.IPA_VERSION_MINOR.IPA_VERSION_RELEASE
 IPA_VERSION_PRE_RELEASE
-dnl version with Git snapshot: 1.0.0.20170102030405.GITabcdefg
+dnl version with Git snapshot: 1.0.0.dev20170102030405+gitabcdefg
 ifelse(IPA_VERSION_IS_GIT_SNAPSHOT, yes,
 .
 IPA_GIT_VERSION),

From d9fd0f092d009d8b1b6665b67fe7a5585247316e Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Thu, 10 Nov 2016 11:09:51 +0100
Subject: [PATCH 07/11] Build: pass down %{release} from SPEC to configure

This is required in order to bake-in precise vendor version to
version.py.

https://fedorahosted.org/freeipa/ticket/6418
---
 freeipa.spec.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/freeipa.spec.in b/freeipa.spec.in
index f2be4bc..53035f8 100644
--- a/freeipa.spec.in
+++ b/freeipa.spec.in
@@ -687,7 +687,7 @@ This package contains tests that verify IPA functionality under Python 3.
 %build
 # UI compilation segfaulted on some arches when the stack was lower (#1040576)
 export JAVA_STACK_SIZE="8m"
-%configure
+%configure --with-vendor-suffix=-%{release}
 %make_build
 
 

From 23163ad5d8334610d5d1d7661d86326d1af882ec Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Thu, 10 Nov 2016 12:07:03 +0100
Subject: [PATCH 08/11] Build: move client directory handling from SPEC to
 Makefile.am

This is next step towards fully functional make install.

https://fedorahosted.org/freeipa/ticket/6418
---
 client/Makefile.am | 3 +++
 freeipa.spec.in    | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/client/Makefile.am b/client/Makefile.am
index 0a451e5..45abdf6 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -122,3 +122,6 @@ MAINTAINERCLEANFILES =		\
 	version.m4		\
 	$(NULL)
 
+install-data-hook:
+	$(INSTALL) -d -D -m 755 $(DESTDIR)$(IPA_SYSCONF_DIR)/nssdb
+	$(INSTALL) -d -D -m 755 $(DESTDIR)$(localstatedir)/lib/ipa-client/sysrestore
diff --git a/freeipa.spec.in b/freeipa.spec.in
index 53035f8..c68e9d0 100644
--- a/freeipa.spec.in
+++ b/freeipa.spec.in
@@ -802,11 +802,8 @@ touch %{buildroot}%{_libdir}/krb5/plugins/libkrb5/winbind_krb5_locator.so
 mkdir -p %{buildroot}/%{_localstatedir}/lib/ipa/backup
 %endif # ONLY_CLIENT
 
-mkdir -p %{buildroot}%{_sysconfdir}/ipa/
 /bin/touch %{buildroot}%{_sysconfdir}/ipa/default.conf
 /bin/touch %{buildroot}%{_sysconfdir}/ipa/ca.crt
-mkdir -p %{buildroot}%{_sysconfdir}/ipa/nssdb
-mkdir -p %{buildroot}/%{_localstatedir}/lib/ipa-client/sysrestore
 
 %if ! %{ONLY_CLIENT}
 mkdir -p %{buildroot}%{_sysconfdir}/cron.d

From 9760aee9b3f1e7ed20f061b081550f3665b7a733 Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Thu, 10 Nov 2016 12:45:26 +0100
Subject: [PATCH 09/11] Build: move server directory handling from SPEC to
 Makefile.am

This is next step towards fully functional make install.

https://fedorahosted.org/freeipa/ticket/6418
---
 freeipa.spec.in     | 8 --------
 install/Makefile.am | 4 ++++
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/freeipa.spec.in b/freeipa.spec.in
index c68e9d0..23c40eb 100644
--- a/freeipa.spec.in
+++ b/freeipa.spec.in
@@ -739,8 +739,6 @@ sed -i -e'1s/python\(3\|$\)/python2/' %{buildroot}%{_bindir}/ipa
 
 %find_lang %{gettext_domain}
 
-mkdir -p %{buildroot}%{_usr}/share/ipa
-
 %if ! %{ONLY_CLIENT}
 # Remove .la files from libtool - we don't want to package
 # these files
@@ -791,7 +789,6 @@ mkdir -p %{buildroot}%{_usr}/share/ipa/html/
 /bin/touch %{buildroot}%{_usr}/share/ipa/html/krb.js
 /bin/touch %{buildroot}%{_usr}/share/ipa/html/krb5.ini
 /bin/touch %{buildroot}%{_usr}/share/ipa/html/krbrealm.con
-mkdir -p %{buildroot}%{_initrddir}
 
 # Web UI plugin dir
 mkdir -p %{buildroot}%{_usr}/share/ipa/ui/js/plugins
@@ -799,7 +796,6 @@ mkdir -p %{buildroot}%{_usr}/share/ipa/ui/js/plugins
 mkdir -p %{buildroot}%{_libdir}/krb5/plugins/libkrb5
 touch %{buildroot}%{_libdir}/krb5/plugins/libkrb5/winbind_krb5_locator.so
 
-mkdir -p %{buildroot}/%{_localstatedir}/lib/ipa/backup
 %endif # ONLY_CLIENT
 
 /bin/touch %{buildroot}%{_sysconfdir}/ipa/default.conf
@@ -816,10 +812,6 @@ mkdir -p %{buildroot}%{_sysconfdir}/cron.d
     sed -e 's,\.py.*$,.*,g' | sort -u | \
     sed -e 's,\./,%%{python_sitelib}/ipatests/,g' ) >tests-python.list
 
-mkdir -p %{buildroot}%{_sysconfdir}/ipa/custodia
-
-mkdir -p %{buildroot}%{_usr}/share/ipa/schema.d
-
 %endif # ONLY_CLIENT
 
 
diff --git a/install/Makefile.am b/install/Makefile.am
index 2dcd927..58d67c6 100644
--- a/install/Makefile.am
+++ b/install/Makefile.am
@@ -19,6 +19,10 @@ SUBDIRS =			\
 	$(NULL)
 
 install-exec-local:
+	mkdir -p $(DESTDIR)$(IPA_SYSCONF_DIR)/custodia
+	chmod 700 $(DESTDIR)$(IPA_SYSCONF_DIR)/custodia
+	mkdir -p $(DESTDIR)$(localstatedir)/lib/ipa/backup
+	chmod 700 $(DESTDIR)$(localstatedir)/lib/ipa/backup
 	mkdir -p $(DESTDIR)$(localstatedir)/lib/ipa/sysrestore
 	chmod 700 $(DESTDIR)$(localstatedir)/lib/ipa/sysrestore
 	mkdir -p $(DESTDIR)$(localstatedir)/lib/ipa/sysupgrade

From 3d5485a71c51bd6c37fef39a5534a39cf9770d9f Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Thu, 10 Nov 2016 14:39:59 +0100
Subject: [PATCH 10/11] Build: move web UI file installation from SPEC to
 Makefile.am

This is next step towards fully functional make install.

https://fedorahosted.org/freeipa/ticket/6418
---
 freeipa.spec.in          | 19 -------------------
 install/html/Makefile.am | 13 +++++++++++++
 install/ui/Makefile.am   |  3 +++
 3 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/freeipa.spec.in b/freeipa.spec.in
index 23c40eb..081e3e2 100644
--- a/freeipa.spec.in
+++ b/freeipa.spec.in
@@ -761,28 +761,12 @@ rm %{buildroot}/%{plugin_dir}/libtopology.la
 rm %{buildroot}/%{_libdir}/krb5/plugins/kdb/ipadb.la
 rm %{buildroot}/%{_libdir}/samba/pdb/ipasam.la
 
-# Some user-modifiable HTML files are provided. Move these to /etc
-# and link back.
-mkdir -p %{buildroot}/%{_sysconfdir}/ipa/html
-mkdir %{buildroot}%{_usr}/share/ipa/html/
-ln -s ../../../..%{_sysconfdir}/ipa/html/ffconfig.js \
-    %{buildroot}%{_usr}/share/ipa/html/ffconfig.js
-ln -s ../../../..%{_sysconfdir}/ipa/html/ffconfig_page.js \
-    %{buildroot}%{_usr}/share/ipa/html/ffconfig_page.js
-ln -s ../../../..%{_sysconfdir}/ipa/html/ssbrowser.html \
-    %{buildroot}%{_usr}/share/ipa/html/ssbrowser.html
-ln -s ../../../..%{_sysconfdir}/ipa/html/unauthorized.html \
-    %{buildroot}%{_usr}/share/ipa/html/unauthorized.html
-ln -s ../../../..%{_sysconfdir}/ipa/html/browserconfig.html \
-    %{buildroot}%{_usr}/share/ipa/html/browserconfig.html
-
 # So we can own our Apache configuration
 mkdir -p %{buildroot}%{_sysconfdir}/httpd/conf.d/
 /bin/touch %{buildroot}%{_sysconfdir}/httpd/conf.d/ipa.conf
 /bin/touch %{buildroot}%{_sysconfdir}/httpd/conf.d/ipa-kdc-proxy.conf
 /bin/touch %{buildroot}%{_sysconfdir}/httpd/conf.d/ipa-pki-proxy.conf
 /bin/touch %{buildroot}%{_sysconfdir}/httpd/conf.d/ipa-rewrite.conf
-mkdir -p %{buildroot}%{_usr}/share/ipa/html/
 /bin/touch %{buildroot}%{_usr}/share/ipa/html/ca.crt
 /bin/touch %{buildroot}%{_usr}/share/ipa/html/kerberosauth.xpi
 /bin/touch %{buildroot}%{_usr}/share/ipa/html/krb.con
@@ -790,9 +774,6 @@ mkdir -p %{buildroot}%{_usr}/share/ipa/html/
 /bin/touch %{buildroot}%{_usr}/share/ipa/html/krb5.ini
 /bin/touch %{buildroot}%{_usr}/share/ipa/html/krbrealm.con
 
-# Web UI plugin dir
-mkdir -p %{buildroot}%{_usr}/share/ipa/ui/js/plugins
-
 mkdir -p %{buildroot}%{_libdir}/krb5/plugins/libkrb5
 touch %{buildroot}%{_libdir}/krb5/plugins/libkrb5/winbind_krb5_locator.so
 
diff --git a/install/html/Makefile.am b/install/html/Makefile.am
index c487f9f..36fcab0 100644
--- a/install/html/Makefile.am
+++ b/install/html/Makefile.am
@@ -16,3 +16,16 @@ EXTRA_DIST =                            \
 MAINTAINERCLEANFILES =                  \
         *~                              \
         Makefile.in
+
+# Default user-modifiable HTML files are installed into /etc.
+# /usr points to these modifiable files in /etc
+# This is ugly but we do not have time to change it right now.
+# Relative paths must be used to ensure that symlinks created in buildroot
+# work after installation.
+htmldatadir = $(datarootdir)/ipa/html
+install-data-hook:
+	$(INSTALL) -d -D -m 755 $(DESTDIR)$(htmldatadir)
+	RELATIVE_PATH=$$(python -c "import os.path; print(os.path.relpath('$(appdir)', '$(htmldatadir)'))");	\
+	for FILE in $(app_DATA); do										\
+		$(LN_S) --force $${RELATIVE_PATH}/$${FILE} $(DESTDIR)$(htmldatadir)/$${FILE};				\
+	done
diff --git a/install/ui/Makefile.am b/install/ui/Makefile.am
index 18fb9b4..1b8a590 100644
--- a/install/ui/Makefile.am
+++ b/install/ui/Makefile.am
@@ -34,3 +34,6 @@ MAINTAINERCLEANFILES =                  \
         *~                              \
         Makefile.in
 	$(NULL)
+
+install-data-hook:
+	$(INSTALL) -d -D -m 755 $(DESTDIR)$(appdir)/js/plugins

From 7e3a347f33dacfbe2fed2ef954d16447f2fa5893 Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Fri, 11 Nov 2016 12:21:58 +0100
Subject: [PATCH 11/11] Build: document what should be in %install section of
 SPEC file

https://fedorahosted.org/freeipa/ticket/6418
---
 freeipa.spec.in | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/freeipa.spec.in b/freeipa.spec.in
index 081e3e2..79a537d 100644
--- a/freeipa.spec.in
+++ b/freeipa.spec.in
@@ -700,6 +700,15 @@ make %{?_smp_mflags} client-check VERBOSE=yes LIBDIR=%{_libdir}
 
 
 %install
+# Please put as much logic as possible into make install. It allows:
+# - easier porting to other distributions
+# - rapid devel & install cycle using make install
+#   (instead of full RPM build and installation each time)
+#
+# %install section of SPEC file should handle ONLY packaging specialities.
+# All files and directories created by %install should be marked as %ghost
+# (these are typically configuration files created by IPA installer).
+# All other artifacts should be created by make install.
 %make_install
 # remove files which are useful only for make uninstall
 find %{buildroot} -wholename '*/site-packages/*/install_files.txt' -exec rm {} \;
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to