How to build snapd from source I'm using Red Hat Enterprise Linux 8?

How to build snapd from source I’m using Red Hat Enterprise Linux 8 ?
Since RHEL 8 is new and Epel release don’t support it yet

So how to install Snap from source?

Snap or snapd (the daemon that installs and manages snaps)?

If the latter, I suggest trying this:

git clone
cd snapd
git checkout 2.40
sudo dnf builddep packaging/fedora/snapd.spec -y
rpmbuild -bb --build-in-place packaging/fedora/snapd.spec

and let us know if it works for you.

1 Like

It’s been a hour around install indent decadency but still failed in
indent.texinfo; fi` Option number is ambiguous
/bin/sh: ./texinfo2man: No such file or directory
from latest version

it’s there’s guide to build from source indent package ?

Ok, just skip build indent … I could install it easily from centos 7 rpm. never knew it could install centos 7 rpm.
Anyway i think the last command was wrong
it’s return

error: Bad source: /home/haidar/rpmbuild/SOURCES/snapd_2.40.only-vendor.tar.xz: No such file or directory

Ok just download the vendor.tar but it’s error again

ln: failed to create symbolic link 'src/': File exists

The in place build is quite peculiar if you need to restart it, because of GOPATH. It’s enough to rm -rf src inside snapd directory.

Alternative way is to build the package like any other RPM inside ~/rpmbuild. Once you’ve checked out 2.40:

$ spectool -g ./packaging/fedora/snapd.spec
$ rpmbuild -bb ./packaging/fedora/snapd.spec

I did restart and install it with user but fails like this :slight_smile:

 /usr/lib/golang/pkg/tool/linux_amd64/link -o $WORK/b001/exe/a.out -importcfg $WORK/b001/ -installsuffix shared -buildmode=pie -buildid=8PrJN5iCfCpoJSpe8pj4/e_Mg5HaEOWc6ZVgQy16M/pyLFaIbXD9WozfldbxlG/8PrJN5iCfCpoJSpe8pj4 -compressdwarf=false -B 0x59e90ad2a19110bbe4414ef56858c55b1ca30ae9 -extldflags "-Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld" -extld=gcc $WORK/b001/_pkg_.a
/usr/lib/golang/pkg/tool/linux_amd64/buildid -w $WORK/b001/exe/a.out # internal
mkdir -p bin/
cp $WORK/b001/exe/a.out bin/snap-failure
rm -r $WORK/b001/
+ %gobuild_static -o bin/snap-exec
/var/tmp/rpm-tmp.xqWIad: line 60: fg: no job control
error: Bad exit status from /var/tmp/rpm-tmp.xqWIad (%build)

RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.xqWIad (%build)
[haidar@haidar snapd]$ tail /var/tmp/rpm-tmp.xqWIad
pushd ./data
make BINDIR="/usr/bin" LIBEXECDIR="/usr/libexec" \
     SYSTEMDSYSTEMUNITDIR="/usr/lib/systemd/system" \
     SNAP_MOUNT_DIR="/var/lib/snapd/snap" \


What path should in GOPATH ? and here’s the root error

/usr/lib/golang/pkg/tool/linux_amd64/link -o $WORK/b001/exe/a.out -importcfg $WORK/b001/ -installsuffix shared -buildmode=pie -buildid=uDw0zZ6cjO2_-reBrAjd/Agx-h22olpLq64uWsAWA/qpQpGFO3OOXiFXqXBPsP/uDw0zZ6cjO2_-reBrAjd -compressdwarf=false -B 0xa5196f649a959e5801ff2a7c974dddeae8ee210a -extldflags "-Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld" -extld=gcc $WORK/b001/_pkg_.a
/usr/lib/golang/pkg/tool/linux_amd64/buildid -w $WORK/b001/exe/a.out # internal
mkdir -p bin/
mv $WORK/b001/exe/a.out bin/snap-failure
rm -r $WORK/b001/
+ %gobuild_static -o bin/snap-exec
/var/tmp/rpm-tmp.tDbrqN: line 60: fg: no job control
error: Bad exit status from /var/tmp/rpm-tmp.tDbrqN (%build)

Looks like %gobuild_static was not expanded. This is part of go-rpm-macros package. Normally you’d get those from Fedora repos (on Fedora) or from EPEL (on CentOS/RHEL).

AFAIK, Go was dropped from the main repositories. You may need to enable and install the proper go toolset. Hopefully it’ll come with RPM macros.

I enable some repo from RHEL 8 and It’s already Installed
Updating Subscription Management repositories.
Last metadata expiration check: 2:11:39 ago on Tue 06 Aug 2019 12:55:22 PM WIB.
Package cmake-rpm-macros-3.11.4-3.el8.noarch is already installed.
Package efi-srpm-macros-3-2.el8.noarch is already installed.
Package ghc-srpm-macros-1.4.2-7.el8.noarch is already installed.
Package go-srpm-macros-2-16.el8.noarch is already installed.
Package kernel-rpm-macros-116-1.el8.noarch is already installed.
Package ocaml-srpm-macros-5-4.el8.noarch is already installed.
Package openblas-srpm-macros-2-2.el8.noarch is already installed.
Package perl-srpm-macros-1-25.el8.noarch is already installed.
Package python-qt5-rpm-macros-5.11.2-3.el8.noarch is already installed.
Package python-rpm-macros-3-37.el8.noarch is already installed.
Package python-srpm-macros-3-37.el8.noarch is already installed.
Package python2-rpm-macros-3-38.module+el8.0.0+2961+596d0223.noarch is already installed.
Package python3-rpm-macros-3-37.el8.noarch is already installed.
Package python36-rpm-macros-3.6.8-2.module+el8.0.0+2975+e0f02136.noarch is already installed.
Package qt5-rpm-macros-5.11.1-2.el8.noarch is already installed.
Package qt5-srpm-macros-5.11.1-2.el8.noarch is already installed.
Package rust-srpm-macros-5-2.el8.noarch is already installed.
Package go-toolset-1.11.6-1.module+el8.0.1+3226+60b863d2.x86_64 is already installed.

it’s that enough ?
how to check missing dependency ?

@mborzecki are you still available to help me :slight_smile:

Sorry for the delay. I’m at currently and will be back next week. In the meantime, I’ll try to find out what’s the deal with go-rpm-macros and RHEL8.

Thanks, take your time. I’m not in urgent or critial

I’ve opened a pull request to snapd with some fixes:
Once that lands it will be possible to build the package on RHEL8 using the RPM spec directly form snapd source tree.

For future reference, in order to have all dependencies available, one needs to:

  • enable rhel-8-for-x86_64-appstream-rpms repo
  • enable codeready-builder-for-rhel-8-x86_64-rpms repo
  • enable go-toolset module

I have those repos enabled and the module installed.

I get

RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.PhXd9A (%build)


rpmbuild -bb --build-in-place packaging/fedora/snapd.spec

I have changed the snapd.spec accordingly to your pull request.

Do you have more of the log? Can you upload the last 50-100 lines to fpaste perhaps?

Here you go :slight_smile:

In place build seems to work differently than in Fedora. You should grab the source archives from the releases page: Download the and snapd_2.40.only-vendor.tar.xz and place them in ~/rpmbuild/SOURCES/.

Once you have that, you can use the spec from snapd tree if you additionally checkout the brach from my PR (or wait until it lands in master).

The PR is in master, so you suggest this should be the approach, right? I downloaded the files as you suggested and placed them in ~/rpmbuild/SOURCES/

➜  Downloads$ git clone
➜  Downloads$ cd snapd
➜  Downloads$ mv snapd ~/rpmbuild
➜  Downloads$ cd ~/rpmbuild/snapd
➜  snapd$ spectool -g ./packaging/fedora/snapd.spec
➜  snapd$ rpmbuild -bb ./packaging/fedora/snapd.spec

That approach ended up in this:

The errors from the end of the paste are:

RPM build errors:
    File not found: /home/my_user/rpmbuild/BUILDROOT/snapd-2.40-0.el8.x86_64/usr/lib/systemd/user/snapd.session-agent.service
    File not found: /home/my_user/rpmbuild/BUILDROOT/snapd-2.40-0.el8.x86_64/usr/lib/systemd/user/snapd.session-agent.socket

These files are related to a newly merged feature that hasn’t appeared in a release yet. My guess at what is happening is that the spec file from git master is being used to try and build the 2.40 tarball release. I’m not sure what the best way forward for you is.

Unfortunately master is a bit of a moving target and the spec was already updated with entries that are in master only.

I’ve opened a PR to the 2.40 branch right here: Once that lands, and you checkout release/2.40 branch locally, things should build fine.

Cheers mate.

I did the changes locally and installed, and got everything working. Have a nice weekend!