Skip to content

Instantly share code, notes, and snippets.

@Bubblemelon
Last active March 12, 2024 23:29
Show Gist options
  • Save Bubblemelon/a78b7abde2dd0b90e24eb183b1550990 to your computer and use it in GitHub Desktop.
Save Bubblemelon/a78b7abde2dd0b90e24eb183b1550990 to your computer and use it in GitHub Desktop.
Additional information on the [Building](https://github.com/ostreedev/ostree#building) section of ostree

Building ostree

These commands are for building on Fedora, it will not work on Ubuntu(Debian) OS(s).

# Optional since ./autogen.sh checks if the submodule needs to be updated
git submodule update --init
./autogen.sh --prefix=/usr --libdir=/usr/lib64 --sysconfdir=/etc
./configure --prefix=/usr
make 
make install DESTDIR=/path/to/install/the/content

Overview

The dependencies listed here can be resolved by running:

sudo dnf builddep ostree

For a Debian based OS:

sudo apt build-dep ostree.

This guide would be useful if you didn't run builddep and encountered one of these errors.

rpm dependencies

This package, redhat-rpm-config, does not come with builddep. You will encounter this error, missing: usr/lib/rpm/redhat/redhat-hardened-cc1, if not installed.

Run sudo dnf install redhat-rpm-config to resolve.

redhat-rpm-config provides default flags for the complier and linker in ostree and most rpm packages.

A bugzilla discussion about redhat-rpm-config.

You may run, sudo dnf install @buildsys-build. This includes redhat-rpm-config and a set of packages in the base buildroot to generate RPMs.

libbuild.sh contains the required packages to build ostree in a container.

Dependencies when running ./autogen.sh

env NOCONFIGURE=1 ./autogen.sh
You don't have gtk-doc installed, and thus won't be able to generate the documentation.
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal -I buildutil -I libglnx ${ACLOCAL_FLAGS} --output=aclocal.m4t
sh: aclocal: command not found
autoreconf: aclocal failed with exit status: 127

Resolve by, running:

sudo dnf install autoconf && \
sudo dnf install gtk-doc

env NOCONFIGURE=1 ./autogen.sh
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force -I buildutil -I libglnx ${ACLOCAL_FLAGS}
configure.ac:108: warning: macro 'AM_PATH_GLIB_2_0' not found in library
configure.ac:216: warning: macro 'AM_PATH_GPGME_PTHREAD' not found in library
autoreconf: configure.ac: tracing
autoreconf: configure.ac: not using Libtool
autoreconf: running: /usr/bin/autoconf --force
configure.ac:108: error: possibly undefined macro: AM_PATH_GLIB_2_0
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
autoreconf: /usr/bin/autoconf failed with exit status: 1

To resolve warning: macro 'AM_PATH_GPGME_PTHREAD' not found in library, run:

sudo dnf install gpgme-devel

To resolve warning: macro 'AM_PATH_GPGME_PTHREAD' not found in library, run:

sudo dnf install glib2-devel

error: Libtool library used but 'LIBTOOL' is undefined
The usual way to define 'LIBTOOL' is to add 'LT_INIT'
to 'configure.ac' and run 'aclocal' and 'autoconf' again.
If 'LT_INIT' is in 'configure.ac', make sure
its definition is in aclocal's search path.

To resolve the above warning, run: sudo dnf install libtool

Dependencies when running ./configure

configure: error: bison not found but required

Will require m4, i.e. sudo dnf install m4

To resolve, run sudo dnf install bison

If install error occurs, may need to install libiconv.


checking for OT_DEP_LZMA... no
configure: error: Package requirements (liblzma >= 5.0.5) were not met:

Package 'liblzma', required by 'virtual:world', not found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables OT_DEP_LZMA_CFLAGS
and OT_DEP_LZMA_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

Resolve by:

sudo dnf install xz-devel

checking for OT_DEP_E2P... no
configure: error: Package requirements (e2p) were not met:

Package 'e2p', required by 'virtual:world', not found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables OT_DEP_E2P_CFLAGS
and OT_DEP_E2P_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

Resolve by, running:

sudo dnf install e2fsprogs-devel

configure: error: Package requirements (fuse >= 2.9.2) were not met:

Package 'fuse', required by 'virtual:world', not found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables BUILDOPT_FUSE_CFLAGS
and BUILDOPT_FUSE_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

Resolve by, running:

sudo dnf install fuse-devel

Dependencies when running make

  CC       src/ostree/ostree-parse-datetime.o
  CCLD     ostree
./.libs/libostree-1.so: error: undefined reference to 'gpg_strerror_r'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:3831: ostree] Error 1
make[2]: Leaving directory '/home/user/github/ostree'
make[1]: *** [Makefile:7031: all-recursive] Error 1
make[1]: Leaving directory '/home/user/github/ostree'
make: *** [Makefile:2799: all] Error 2

Checked if these were installed:

  • libgcrypt
  • libgpg-error and libgpg-error-devel

If error persists, this may be a linker issue with ELF:

update-alternatives --config ld

Information on:

There are 2 programs which provide 'ld'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/bin/ld.bfd
   2           /usr/bin/ld.gold

The + sign should be on selection 1.

Ostree currently uses the GNU linker as the default linker in compiling the executable. Having fuse-ld=gold in a Fedora 28 the buildroot will break the build as gold doesn't search indirect dependencies.

Development on a container:

See Hacking.md from the rpm-ostree repo and the libbuild script from ostree.

Example Dockerfile:

FROM fedora:latest

# install dependencies
RUN dnf update -y && \
    dnf -y install dnf-plugins-core  && \
    dnf -y builddep ostree  && \
    dnf -y install make redhat-rpm-config && \
    dnf clean all

# clone bubblemelon repo
RUN git clone https://github.com/Bubblemelon/ostree.git

# pull patch-branch + set upstream
RUN cd ostree && \
    git pull origin del-alias-refs-patch && \
    git checkout del-alias-refs-patch && \
    git remote add upstream https://github.com/ostreedev/ostree.git

WORKDIR /ostree
 
COPY ostree-test.sh /

# BUILDING
# docker build -t ostree-fedora-test .

# RUNNING
# docker run -it --rm --entrypoint /bin/sh --name ostree-testing ostree-fedora-test
# Run without --rm to keep this container
# Run `docker pause ostree-fedora-testing` to suspend
# Run `docker unpase ostree-fedora-testing` to resume
@rfairley
Copy link

rfairley commented Jul 24, 2018

Helpful to see this summary! Having a record of resolving the dependencies will help me not forget, as I ran into similar issues. May try running in a container next time.

Something to add could be on enabling build options like https://github.com/ostreedev/ostree/blob/master/src/ostree/main.c#L119. It took some searching for me as I was not familiar with autotools. Some tests needed this, e.g. network tests giving the --random-500s option. For this I did the following when configuring:

./configure --prefix=/usr --enable-trivial-httpd-cmdline=yes

After building, there would be a trivial-httpd option after running ostree --help.

@Bubblemelon
Copy link
Author

Bubblemelon commented Jul 24, 2018

Interesting. So you've resolved 500 errors with the --enable-trivial-httpd-cmdline option ? Im not very familiar with this 😅

Could you elaborate some more?

@rfairley
Copy link

rfairley commented Jul 24, 2018

For sure! To clarify on the cmdline option, the --enable-trivial-httpd-cmdline=yes was needed to get ./configure to append a #define in a .h file (it seems configure.ac generates this condition in configure from here https://github.com/ostreedev/ostree/blob/master/configure.ac#L194). The #define BUILDOPT_ENABLE_TRIVIAL_HTTPD_CMDLINE 1 ended up in config.h, after running ./configure. I think this is how src/ostree/main.c knows how to build ostree with the trivial-httpd option in, as config.h is included in there.

The --random-500s was needed in a test: https://github.com/ostreedev/ostree/blob/master/tests/test-pull-repeated.sh#L31 - just to generate a lot of 500 errors whenever a pull was made and make sure it failed. The --random-408s also was used to make sure the --network-retries option improved things with transient errors. Overall I think trivial-httpd is just needed for testing - seems it is is not normally built into ostree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment