From ead3168d812511a534c18502ec89578290c96233 Mon Sep 17 00:00:00 2001 From: William Brown Date: Nov 29 2017 07:59:08 +0000 Subject: Ticket 49475 - docker poc improvements. Bug Description: Improve the docker poc to support intree builds. Add a .mk file to help mak ethis easier for people to use. Fix Description: Improve our specfile dependencies, our makefile to use a with perl, and dockerfile to build from intree. https://pagure.io/389-ds-base/issue/49475 Author: wibrown Review by: mreynolds (Thanks!) --- diff --git a/Makefile.am b/Makefile.am index e3b30b6..8df31e5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -45,6 +45,12 @@ RUST_LDFLAGS = RUST_DEFINES = endif +if ENABLE_PERL +PERL_ON = 1 +else +PERL_ON = 0 +endif + # We can't add the lfds includes all the time as they have a "bomb" in them that # prevents compilation on unsupported hardware arches. if ATOMIC_QUEUE_OPERATIONS @@ -2297,6 +2303,7 @@ rpmbrprep: dist-bzip2 rpmroot -e "s/__VERSION_PREREL__/$(VERSION_PREREL)/" \ -e "s/__NUNC_STANS_ON__/$(NUNC_STANS_ON)/" \ -e "s/__RUST_ON__/$(RUST_ON)/" \ + -e "s/__PERL_ON__/$(PERL_ON)/" \ -e "s/__ASAN_ON__/$(ASAN_ON)/" < $(abs_builddir)/rpm/389-ds-base.spec > $(RPMBUILD)/SPECS/389-ds-base.spec # Requires rpmdevtools. Consider making this a dependancy of rpms. diff --git a/docker.mk b/docker.mk new file mode 100644 index 0000000..528ab2f --- /dev/null +++ b/docker.mk @@ -0,0 +1,4 @@ + + +poc: + docker build -t 389-poc:latest -f docker/389ds_poc/Dockerfile . diff --git a/docker/389ds_poc/Dockerfile b/docker/389ds_poc/Dockerfile index 6e9ebf4..95bea27 100644 --- a/docker/389ds_poc/Dockerfile +++ b/docker/389ds_poc/Dockerfile @@ -6,34 +6,30 @@ # See LICENSE for details. # --- END COPYRIGHT BLOCK --- -FROM centos:7 +FROM fedora:26 MAINTAINER 389-devel@lists.fedoraproject.org EXPOSE 389 636 ENV container docker -ARG lib389repository=https://pagure.io/lib389.git -ARG dsrepository=https://pagure.io/389-ds-base.git -ARG lib389branch=master -ARG dsbranch=master RUN mkdir -p /usr/local/src WORKDIR /usr/local/src -RUN yum upgrade -y && \ - yum install -y @buildsys-build rpm-build make epel-release bzip2 git && \ - yum clean all +ADD ./ /usr/local/src/389-ds-base -RUN git clone --depth=1 --branch=$lib389branch $lib389repository lib389 && \ - git clone --depth=1 --branch=$dsbranch $dsrepository 389-ds-base +RUN dnf upgrade -y && \ + dnf install --setopt=strict=False -y \ + @buildsys-build rpm-build make bzip2 git rsync \ + `grep -E "^(Build)?Requires" 389-ds-base/rpm/389-ds-base.spec.in | grep -v -E '(name|MODULE)' | awk '{ print $2 }' | sed 's/%{python3_pkgversion}/3/g' | grep -v "^/" | grep -v pkgversion | sort | uniq | tr '\n' ' '` && \ + dnf clean all -RUN yum install -y --skip-broken `grep -E "^(Build)?Requires" 389-ds-base/rpm/389-ds-base.spec.in lib389/python-lib389.spec | grep -v -E '(name|MODULE)' | awk '{ print $2 }' | grep -v "^/" | grep -v pkgversion | sort | uniq| tr '\n' ' '` && \ - yum clean all -RUN make -C lib389/ rpm +### CHANGE THIS TO A ./configure and build that way. -RUN cd 389-ds-base && make -f rpm.mk rpms +RUN cd 389-ds-base && \ + PERL_ON=0 RUST_ON=1 make -f rpm.mk rpms -RUN yum install -y 389-ds-base/dist/rpms/389*.rpm lib389/rpmbuild/RPMS/noarch/*lib389* && \ - yum clean all +RUN dnf install -y 389-ds-base/dist/rpms/*389*.rpm && \ + dnf clean all # Create the example setup inf. It's valid for containers! # Build the instance from the new installer tools. diff --git a/rpm.mk b/rpm.mk index 4254808..c15ff6c 100644 --- a/rpm.mk +++ b/rpm.mk @@ -11,6 +11,7 @@ TARBALL = $(NAME_VERSION).tar.bz2 NUNC_STANS_ON = 1 ASAN_ON = 0 RUST_ON = 0 +PERL_ON = 1 clean: rm -rf dist @@ -38,6 +39,7 @@ rpmroot: -e s/__NUNC_STANS_ON__/$(NUNC_STANS_ON)/ \ -e s/__RUST_ON__/$(RUST_ON)/ \ -e s/__ASAN_ON__/$(ASAN_ON)/ \ + -e s/__PERL_ON__/$(PERL_ON)/ \ rpm/$(PACKAGE).spec.in > $(RPMBUILD)/SPECS/$(PACKAGE).spec rpmdistdir: @@ -50,7 +52,6 @@ rpmbuildprep: cp dist/sources/$(TARBALL) $(RPMBUILD)/SOURCES/ cp rpm/$(PACKAGE)-* $(RPMBUILD)/SOURCES/ - srpms: rpmroot srpmdistdir tarballs rpmbuildprep rpmbuild --define "_topdir $(RPMBUILD)" -bs $(RPMBUILD)/SPECS/$(PACKAGE).spec cp $(RPMBUILD)/SRPMS/$(RPM_NAME_VERSION)*.src.rpm dist/srpms/ @@ -65,8 +66,7 @@ patch_srpms: rpmroot srpmdistdir tarballs rpmbuildprep rpms: rpmroot srpmdistdir rpmdistdir tarballs rpmbuildprep rpmbuild --define "_topdir $(RPMBUILD)" -ba $(RPMBUILD)/SPECS/$(PACKAGE).spec - cp $(RPMBUILD)/RPMS/*/$(RPM_NAME_VERSION)*.rpm dist/rpms/ - cp $(RPMBUILD)/RPMS/*/$(PACKAGE)-*-$(RPM_VERSION)*.rpm dist/rpms/ + cp $(RPMBUILD)/RPMS/*/*$(RPM_VERSION)$(RPM_VERSION_PREREL)*.rpm dist/rpms/ cp $(RPMBUILD)/SRPMS/$(RPM_NAME_VERSION)*.src.rpm dist/srpms/ rm -rf $(RPMBUILD) @@ -74,7 +74,6 @@ patch_rpms: rpmroot srpmdistdir rpmdistdir tarballs rpmbuildprep cp rpm/*.patch $(RPMBUILD)/SOURCES/ rpm/add_patches.sh rpm $(RPMBUILD)/SPECS/$(PACKAGE).spec rpmbuild --define "_topdir $(RPMBUILD)" -ba $(RPMBUILD)/SPECS/$(PACKAGE).spec - cp $(RPMBUILD)/RPMS/*/$(RPM_NAME_VERSION)*.rpm dist/rpms/ - cp $(RPMBUILD)/RPMS/*/$(PACKAGE)-*-$(RPM_VERSION)*.rpm dist/rpms/ + cp $(RPMBUILD)/RPMS/*/*$(RPM_VERSION)$(RPM_VERSION_PREREL)*.rpm dist/rpms/ cp $(RPMBUILD)/SRPMS/$(RPM_NAME_VERSION)*.src.rpm dist/srpms/ rm -rf $(RPMBUILD) diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in index d16ab5a..c79d4d0 100644 --- a/rpm/389-ds-base.spec.in +++ b/rpm/389-ds-base.spec.in @@ -20,6 +20,8 @@ # This enables rust in the build. %global use_rust __RUST_ON__ +%global use_perl __PERL_ON__ + %if %{use_asan} %global use_tcmalloc 0 %global variant base-asan @@ -115,6 +117,7 @@ BuildRequires: gperftools-devel # Now, attach the requires only to the package that needs them. # -libs has most of our runtime libs Requires: %{name}-libs = %{version}-%{release} +Requires: python%{python3_pkgversion}-lib389 = %{version}-%{release} # Attach to -base our script deps %if %{use_tcmalloc} Requires: gperftools-libs @@ -284,6 +287,10 @@ TCMALLOC_FLAGS="--enable-tcmalloc" RUST_FLAGS="--enable-rust" %endif +%if !%{use_perl} +PERL_FLAGS="--disable-perl" +%endif + # Rebuild the autotool artifacts now. autoreconf -fiv @@ -292,7 +299,7 @@ autoreconf -fiv --with-systemdsystemunitdir=%{_unitdir} \ --with-systemdsystemconfdir=%{_sysconfdir}/systemd/system \ --with-systemdgroupname=%{groupname} \ - $NSSARGS $TCMALLOC_FLAGS $ASAN_FLAGS $RUST_FLAGS \ + $NSSARGS $TCMALLOC_FLAGS $ASAN_FLAGS $RUST_FLAGS $PERL_FLAGS \ --enable-cmocka %if 0%{?rhel} >= 8 || 0%{?fedora} @@ -344,8 +351,11 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/%{pkgname}/*.la rm -f $RPM_BUILD_ROOT%{_libdir}/%{pkgname}/plugins/*.a rm -f $RPM_BUILD_ROOT%{_libdir}/%{pkgname}/plugins/*.la + +%if %{use_perl} # make sure perl scripts have a proper shebang sed -i -e 's|#{{PERL-EXEC}}|#!/usr/bin/perl|' $RPM_BUILD_ROOT%{_datadir}/%{pkgname}/script-templates/template-*.pl +%endif %check # This checks the code, if it fails it prints why, then re-raises the fail to shortcircuit the rpm build. @@ -386,6 +396,8 @@ if ! getent passwd $USERNAME >/dev/null ; then fi fi +%if %{use_perl} +# START UPGRADE SCRIPT echo looking for instances in %{_sysconfdir}/%{pkgname} > $output 2>&1 || : instbase="%{_sysconfdir}/%{pkgname}" for dir in $instbase/slapd-* ; do @@ -429,6 +441,9 @@ for inst in $instances ; do echo restarting instance $inst >> $output 2>&1 || : /bin/systemctl start $inst >> $output 2>&1 || : done +#END UPGRADE +%endif + exit 0 %preun @@ -471,6 +486,15 @@ fi %{_bindir}/* # We have to seperate this from being a glob to ensure the caps are applied. %caps(CAP_NET_BIND_SERVICE=pe) %{_sbindir}/ns-slapd +%{_sbindir}/dsconf +%{_sbindir}/dscreate +%{_sbindir}/dsctl +%{_sbindir}/dsidm +%{_sbindir}/ds_selinux_enabled +%{_sbindir}/ds_selinux_port_query +%{_sbindir}/ds_systemd_ask_password_acl +%if %{use_perl} +%{_sbindir}/monitor %{_sbindir}/bak2db %{_sbindir}/bak2db.pl %{_sbindir}/cleanallruv.pl @@ -483,16 +507,12 @@ fi %{_sbindir}/dbmon.sh %{_sbindir}/dbverify %{_sbindir}/dn2rdn -%{_sbindir}/ds_selinux_enabled -%{_sbindir}/ds_selinux_port_query -%{_sbindir}/ds_systemd_ask_password_acl %{_sbindir}/fixup-linkedattrs.pl %{_sbindir}/fixup-memberof.pl %{_sbindir}/ldif2db %{_sbindir}/ldif2db.pl %{_sbindir}/ldif2ldap %{_sbindir}/migrate-ds.pl -%{_sbindir}/monitor %{_sbindir}/ns-accountstatus.pl %{_sbindir}/ns-activate.pl %{_sbindir}/ns-inactivate.pl @@ -514,6 +534,7 @@ fi %{_sbindir}/verify-db.pl %{_sbindir}/vlvindex %{_libdir}/%{pkgname}/perl +%endif %{_libdir}/%{pkgname}/python %dir %{_libdir}/%{pkgname}/plugins %{_libdir}/%{pkgname}/plugins/*.so @@ -569,10 +590,6 @@ fi %files -n python%{python3_pkgversion}-lib389 %defattr(-,root,root,-) %doc LICENSE LICENSE.GPLv3+ -%{_sbindir}/dsconf -%{_sbindir}/dscreate -%{_sbindir}/dsctl -%{_sbindir}/dsidm %{python3_sitelib}/lib389* %endif