Skip to content

Commit 125c482

Browse files
cgwaltersrh-atomic-bot
authored andcommitted
Switch to using libhif as a git submodule
So I was trying to hack on my host's copy of rpm-ostree inside a pet docker container, but ran into a conflict with libhif since dnf uses it. I think we basically need to *always* build the bundled path, rather than what I'm doing with CAHC and FADC where it's built as a regular RPM. It's not really sustainable right now for us to have both bundled and not-bundled build paths - and we need to support co-installation with dnf. Another major issue is that we want to version lock with libhif - right now our CI and both CAHC/FADC track libhif master, but that means everything breaks if libhif breaks and we don't immediately port. git submodules solve all of these problems - the same as we're doing with libglnx. libglnx is *designed* for use as a git submodule, where as libhif needs to support being both bundled and not-bundled. So we end up with some hacks on our side, but I think it's all not too bad. I've marked build rules with `# bundled libhif` so we know where to find them later when libhif is stable. Closes: coreos#357 Approved by: jlebon
1 parent 4f68f73 commit 125c482

12 files changed

+103
-47
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "libglnx"]
22
path = libglnx
33
url = https://git.gnome.org/browse/libglnx
4+
[submodule "libhif"]
5+
path = libhif
6+
url = https://github.com/rpm-software-management/libhif

HACKING.md

+30
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
Raw build instructions
2+
----------------------
3+
4+
First, releases are available as GPG signed git tags, and most recent
5+
versions support extended validation using
6+
[git-evtag](https://github.com/cgwalters/git-evtag).
7+
8+
You'll need to get the submodules too: `git submodule update --init`
9+
10+
rpm-ostree has a hard requirement on a bleeding edge version of
11+
[libhif](https://github.com/rpm-software-management/libhif/) - we now
12+
consume this as a git submodule automatically.
13+
14+
We also require a few other libraries like
15+
[librepo](https://github.com/rpm-software-management/librepo).
16+
17+
So the build process now looks like any other autotools program:
18+
19+
```
20+
env NOCONFIGURE=1 ./autogen.sh
21+
./configure --prefix=/usr --libdir=/usr/lib64 --sysconfdir=/etc
22+
make
23+
```
24+
25+
At this point you can run some of the unit tests with `make check`.
26+
For more information on this, see `CONTRIBUTING.md`.
27+
28+
Using the Vagrant box
29+
=====================
30+
131
The easiest way to get started hacking on `rpm-ostree` is to
232
use the vagrant machine. This is also the set up used for
333
our integration tests.

Makefile-daemon.am

-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ librpmostreed_la_CFLAGS = \
5959
$(NULL)
6060

6161
librpmostreed_la_LIBADD = \
62-
$(AM_LDFLAGS) \
6362
$(PKGDEP_RPMOSTREE_LIBS) \
6463
librpmostreepriv.la \
6564
librpmostree-1.la \
@@ -81,7 +80,6 @@ rpm_ostreed_CFLAGS = \
8180

8281
rpm_ostreed_LDADD = \
8382
librpmostreed.la \
84-
$(AM_LDFLAGS) \
8583
$(PKGDEP_RPMOSTREE_LIBS) \
8684
$(NULL)
8785

Makefile-decls.am

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
ACLOCAL_AMFLAGS =
2020
AM_CPPFLAGS =
2121
AM_CFLAGS =
22+
AM_LDFLAGS =
2223
DISTCHECK_CONFIGURE_FLAGS =
2324
SUBDIRS =
2425
NULL =

Makefile-hif.am

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Makefile for C source code
2+
#
3+
# Copyright (C) 2016 Colin Walters <[email protected]>
4+
#
5+
# This library is free software; you can redistribute it and/or
6+
# modify it under the terms of the GNU Lesser General Public
7+
# License as published by the Free Software Foundation; either
8+
# version 2 of the License, or (at your option) any later version.
9+
#
10+
# This library is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
# Lesser General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU Lesser General Public
16+
# License along with this library; if not, write to the
17+
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18+
# Boston, MA 02111-1307, USA.
19+
20+
libhif.so.3:
21+
cd libhif-build && $(MAKE)
22+
ln -s libhif-build/libhif/libhif.so.3 .
23+
CLEANFILES += libhif.so.3
24+
GITIGNOREFILES += libhif-build/
25+
26+
install-libhif-hook:
27+
install -d -m 0755 $(DESTDIR)$(libdir)/rpm-ostree
28+
install -m 0755 $$(readlink libhif.so.3) $(DESTDIR)$(libdir)/rpm-ostree
29+
INSTALL_DATA_HOOKS += install-libhif-hook

Makefile-lib.am

+4-1
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@ librpmostree_1_la_SOURCES = \
3232
librpmostree_1_la_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/libglnx -I$(srcdir)/src/libpriv -I$(srcdir)/src/lib \
3333
-fvisibility=hidden '-D_RPMOSTREE_EXTERN=__attribute((visibility("default"))) extern' \
3434
$(PKGDEP_RPMOSTREE_CFLAGS)
35-
librpmostree_1_la_LDFLAGS = -version-number 1:0:0 -Bsymbolic-functions
35+
librpmostree_1_la_LDFLAGS = $(AM_LDFLAGS) -version-number 1:0:0 -Bsymbolic-functions
3636
librpmostree_1_la_LIBADD = $(PKGDEP_RPMOSTREE_LIBS) librpmostreepriv.la
3737

38+
# bundled libhif
39+
INTROSPECTION_SCANNER_ENV = env LD_LIBRARY_PATH=$(top_builddir)/libhif-build/libhif
40+
3841
if BUILDOPT_INTROSPECTION
3942
RpmOstree-1.0.gir: librpmostree-1.la Makefile
4043
RpmOstree_1_0_gir_EXPORT_PACKAGES = rpm-ostree-1

Makefile-libpriv.am

+3-1
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@ librpmostreepriv_la_CFLAGS = \
5454
$(NULL)
5555

5656
librpmostreepriv_la_LIBADD = \
57-
$(AM_LDFLAGS) \
5857
$(PKGDEP_RPMOSTREE_LIBS) \
5958
libglnx.la \
6059
$(CAP_LIBS) \
6160
$(NULL)
6261

62+
# bundled libhif
63+
EXTRA_librpmostreepriv_la_DEPENDENCIES = libhif.so.3
64+
6365
gperf_gperf_sources = src/libpriv/rpmostree-script-gperf.gperf
6466
BUILT_SOURCES += $(gperf_gperf_sources:-gperf.gperf=-gperf.c)
6567
CLEANFILES += $(gperf_gperf_sources:-gperf.gperf=-gperf.c)

Makefile-rpm-ostree.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ rpm_ostree_SOURCES += \
5353
endif
5454

5555
rpm_ostree_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/src/app -I$(srcdir)/src/lib -I$(srcdir)/src/libpriv -I$(libglnx_srcpath) -DPKGLIBDIR=\"$(pkglibdir)\" $(PKGDEP_RPMOSTREE_CFLAGS)
56-
rpm_ostree_LDADD = $(AM_LDFLAGS) $(PKGDEP_RPMOSTREE_LIBS) librpmostreepriv.la librpmostree-1.la
56+
rpm_ostree_LDADD = $(PKGDEP_RPMOSTREE_LIBS) librpmostreepriv.la librpmostree-1.la
5757

5858
privdatadir=$(pkglibdir)
5959
privdata_DATA = src/app/rpm-ostree-0-integration.conf

Makefile.am

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ AM_CPPFLAGS += -DDATADIR='"$(datadir)"' \
3030
-DRPM_OSTREE_FEATURES='"$(RPM_OSTREE_FEATURES)"' \
3131
-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_40 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_40_
3232
AM_CFLAGS += -std=gnu99 $(WARN_CFLAGS)
33+
# bundled libhif
34+
AM_LDFLAGS += "-Wl,-rpath=$(libdir)/rpm-ostree"
3335

3436
EXTRA_DIST += autogen.sh COPYING
3537

@@ -51,6 +53,7 @@ TYPELIBS = $(GIRS:.gir=.typelib)
5153
include libglnx/Makefile-libglnx.am.inc
5254
noinst_LTLIBRARIES += libglnx.la
5355
include Makefile-libpriv.am
56+
include Makefile-hif.am
5457
include Makefile-lib.am
5558
include Makefile-daemon.am
5659
include Makefile-rpm-ostree.am

README.md

-37
Original file line numberDiff line numberDiff line change
@@ -31,43 +31,6 @@ Using rpm-ostree to build OS images/trees
3131

3232
See [Compose Server](docs/manual/compose-server.md).
3333

34-
Building
35-
--------
36-
37-
Releases are available as GPG signed git tags, and most recent
38-
versions support extended validation using
39-
[git-evtag](https://github.com/cgwalters/git-evtag).
40-
41-
However, in order to build from a git clone, you must update the
42-
submodules. If you're packaging and want a tarball, I recommend using
43-
a "recursive git archive" script. There are several available online;
44-
[this code](https://git.gnome.org/browse/ostree/tree/packaging/Makefile.dist-packaging#n11)
45-
in OSTree is an example.
46-
47-
Once you have a git clone or recursive archive, the next step is to
48-
install the build dependencies. At the moment, rpm-ostree has a hard
49-
requirement on a bleeding edge version of
50-
[libhif](https://github.com/rpm-software-management/libhif/). It also
51-
requires a few other libraries like
52-
[librepo](https://github.com/rpm-software-management/librepo).
53-
54-
Once you have the dependencies, building is the same as every
55-
autotools project:
56-
57-
```
58-
env NOCONFIGURE=1 ./autogen.sh
59-
./configure --prefix=/usr --libdir=/usr/lib64 --sysconfdir=/etc
60-
make
61-
```
62-
63-
At this point you can run some of the unit tests with `make check`.
64-
For more information on this, see `CONTRIBUTING.md`.
65-
66-
More documentation
67-
------------------
68-
69-
New! See the docs online at [Read The Docs (rpm-ostree)](https://rpm-ostree.readthedocs.org/en/latest/ )
70-
7134
Hacking
7235
-------
7336

configure.ac

+28-5
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,11 @@ PKG_CHECK_MODULES(PKGDEP_GIO_UNIX, [gio-unix-2.0])
6464
PKG_CHECK_MODULES(PKGDEP_RPMOSTREE, [gio-unix-2.0 >= 2.40.0 json-glib-1.0
6565
ostree-1 >= 2015.1 libgsystem >= 2015.1
6666
libsystemd
67-
rpm libhif librepo
67+
rpm librepo
6868
libarchive])
69-
save_LIBS=$LIBS
70-
LIBS=$PKGDEP_RPMOSTREE_LIBS
71-
AC_CHECK_FUNCS(hif_source_set_required)
72-
LIBS=$save_LIBS
69+
dnl bundled libhif
70+
PKGDEP_RPMOSTREE_CFLAGS="-I $(pwd)/libhif -I $(pwd)/libhif-build $PKGDEP_RPMOSTREE_CFLAGS"
71+
PKGDEP_RPMOSTREE_LIBS="-L$(pwd)/libhif-build/libhif -lhif $PKGDEP_RPMOSTREE_LIBS"
7372

7473
AC_PATH_PROG([XSLTPROC], [xsltproc])
7574

@@ -109,6 +108,30 @@ AS_IF([test x$enable_compose_tooling = xyes], [
109108
])
110109
if test x$enable_compose_tooling != xno; then RPM_OSTREE_FEATURES="$RPM_OSTREE_FEATURES +compose"; fi
111110

111+
dnl Try to automatically determine cmake type from CFLAGS
112+
if $(echo $CFLAGS |grep -q -e "-O0"); then
113+
cmake_args="-DCMAKE_BUILD_TYPE=Debug \
114+
-DCMAKE_C_FLAGS_DEBUG:STRING='-ggdb -O0' \
115+
-DCMAKE_CXX_FLAGS_DEBUG:STRING=-ggdb -O0'"
116+
export cmake_args
117+
else
118+
cmake_args=-DCMAKE_BUILD_TYPE=RelWithDebugInfo
119+
export cmake_args
120+
fi
121+
122+
dnl I picked /usr/libexec/rpm-ostree just because we need an
123+
dnl arbitrary path - we don't actually install there.
124+
(set -euo pipefail; mkdir -p libhif-build && cd libhif-build &&
125+
set -x &&
126+
cmake \
127+
-DCMAKE_INSTALL_PREFIX:PATH=/usr/libexec/rpm-ostree \
128+
-DINCLUDE_INSTALL_DIR:PATH=/usr/libexec/rpm-ostree/include \
129+
-DLIB_INSTALL_DIR:PATH=/usr/libexec/rpm-ostree \
130+
-DSYSCONF_INSTALL_DIR:PATH=/usr/libexec/rpm-ostree/etc \
131+
-DSHARE_INSTALL_PREFIX:PATH=/usr/libexec/rpm-ostree/share \
132+
-DBUILD_SHARED_LIBS:BOOL=ON \
133+
${cmake_args} ../libhif)
134+
112135
AC_CONFIG_FILES([
113136
Makefile
114137
api-doc/Makefile

libhif

Submodule libhif added at 07618db

0 commit comments

Comments
 (0)