LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   Building .deb package with Meson/Ninja (https://www.linuxquestions.org/questions/debian-26/building-deb-package-with-meson-ninja-4175670818/)

GeekBoy 03-05-2020 07:28 PM

Building .deb package with Meson/Ninja
 
I have seen a lot of guides/How-Tos on building .deb packages using the traditional configure & make method, and those work out great.

However, I am not seeing anything on building packages based on the Meson & Ninja build setup.

Not even Debian's own guide mentions anything on this.

Can anyone point me to something?

Thanks!

shruggy 03-14-2020 09:12 AM

As an example, see debian/rules for xed from Linux Mint.

OTOH, meson and ninja are listed among build systems recognized by debhelper, so I guess for most packages the standard dh magic should work, too. And if debhelper wrongly determines the used build system itself, you may always specify it explicitly:
Code:

%:
        dh $@ --buildsystem=meson


GeekBoy 03-31-2020 08:27 PM

When I tried the normal build, it would report not finding classic stuff like configure.


When I tried entering "dh $@ --buildsystem=meson" it reported back, "dh: error: Unknown sequence --buildsystem=meson (options should not come before the sequence)"

Thanks for responding.

shruggy 04-01-2020 02:29 AM

1. What's your distro?
Code:

grep ^PRETTY /etc/os-release
2. What's your version of debhelper? (meson/ninja support was added in debhelper 10.3, i.e. if you're on Debian 9 (Stretch) you should use debhelper from stretch-backports, and if you're still on Debian 8 (Jessie) or Ubuntu 16.04 LTS (Xenial) you're out of luck)
Code:

dpkg -l debhelper
3. What's the output of
Code:

dh build --no-act --buildsystem=meson
(run the last command from inside your package source directory, i.e. one level above the debian directory).

GeekBoy 04-01-2020 11:30 PM

Here are the responses.


Quote:

PRETTY_NAME="Debian GNU/Linux bullseye/sid"

Quote:

| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-============-============-=================================
ii debhelper 12.9 all helper programs for debian/rules
Quote:

dh_testdir -O--buildsystem=meson
dh_update_autotools_config -O--buildsystem=meson
dh_autoreconf -O--buildsystem=meson
debian/rules override_dh_auto_configure
debian/rules override_dh_auto_build
dh_auto_test -O--buildsystem=meson
create-stamp debian/debhelper-build-stamp

shruggy 04-02-2020 02:15 AM

I don't see anything wrong with your setup.

1. What software are you trying to build? Have you tried to build it manually, according to upstream instructions (they are usually in files named INSTALL*, README* and the like)? Did it work?

2. Please show the contents of debian/rules.

GeekBoy 04-03-2020 02:36 PM

It is Budgie Desktop 10.5.

And yes, I have tried the manual build


Here is the content of debian/rules

Code:

#!/usr/bin/make -f
export DH_VERBOSE = 1
export MAKE = ninja -v
export LC_ALL=C.UTF-8
export DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow

%:
        dh $@

override_dh_clean:
        dh_clean
        rm -rf debian/build
ifeq ($(shell dpkg-vendor --derives-from Ubuntu && echo ubuntu),ubuntu)

        @if [ -e ./debian/ubuntu/applied ]; then \
                patch -R -p1 < debian/ubuntu/show_nm-applet_in_tray.patch ; \
                rm ./debian/ubuntu/applied ; \
        fi
endif

override_dh_auto_configure:
        mkdir -p debian/build
ifeq ($(shell dpkg-vendor --derives-from Ubuntu && echo ubuntu),ubuntu)
        patch -p1 < debian/ubuntu/show_nm-applet_in_tray.patch
        touch ./debian/ubuntu/applied
endif
        cd debian/build && LDFLAGS="-Wl,-z,now -Wl,-z,relro -O1" meson -Dwith-desktop-icons=none --buildtype plain --prefix=/usr --libdir=/usr/lib --sysconfdir=/etc ../..

override_dh_auto_build:
        cd debian/build && $(MAKE)

override_dh_auto_install:
        dh_auto_install
        cd debian/build && DESTDIR=$(CURDIR)/debian/tmp $(MAKE) install
        mkdir -p "$(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/girepository-1.0"
        mv "$(CURDIR)/debian/tmp/usr/lib/girepository-1.0/Budgie-1.0.typelib" "$(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/girepository-1.0"
        rm -rf "$(CURDIR)/debian/tmp/usr/lib/girepository-1.0"

override_dh_installgsettings:
        # install override but budgie has to take precedence over
        # gnome-shell defaults
        dh_installgsettings --priority=15

override_dh_installchangelogs:
        dh_installchangelogs debian/changelog-announcement.txt


shruggy 04-04-2020 04:06 AM

budgie-desktop 10.5.1-3 is currently in sid. Why not just install it from the official repo?

Just to be sure, I've rebuilt budgie-desktop 10.5.1-6 currently in experimental from source. The only problem was package libmutter-6-dev still being in experimental. So I did
Code:

sudo pbuilder --update --override-config --distribution experimental
Update. Now I've also rebuilt budgie-desktop 10.5.1-3 from sid source with no changes and no problems whatsoever.

GeekBoy 04-09-2020 09:43 PM

Reason for not using packages is to learn how to make various packages, and learn how to make my own repos.

I had downloaded the source packages from the upstream developer repo on Github.
Maybe that is why I am having issues.

I tried downloading source from the Deb source repos using "apt-get source", but I guess I have to do that as sudo user.

shruggy 04-10-2020 12:31 AM

No, it's not necessary to be root in order to use apt-get source. From the apt-get(1) manpage:
Quote:

Note that source packages are not installed and tracked in the dpkg database like binary packages; they are simply downloaded to the current directory, like source tarballs.
But you should have enabled the corresponding deb-src line in /etc/apt/sources.list. From the same manpage:
Quote:

Source packages are tracked separately from binary packages via deb-src lines in the sources.list(5) file. This means that you will need to add such a line for each repository you want to get sources from; otherwise you will probably get either the wrong (too old/too new) source versions or none at all.
Alternatively to apt-get source you can try dget from package devscripts.

From Ubuntu's pbuilder Howto:
Quote:

There will be times when a package you want or need to build is not in the repositories of the current version of Ubuntu you are running. Rather than entering deb-src lines in your sources.list configuration for other versions of Ubuntu you are not running, you can use dget instead to download a package. dget is included in the devscripts package, hence why you should have installed it.

To use dget, first locate the .dsc file of the package you are going to build. Good places to look are http://packages.ubuntu.com/ or http://packages.debian.org/. Once you located the .dsc file, copy the link address to it and then in a command prompt run:
Code:

dget <link_address_to_foo.dsc>

Quote:

Originally Posted by GeekBoy (Post 6109780)
I had downloaded the source packages from the upstream developer repo on Github. Maybe that is why I am having issues.

I don't think so. Just compare your debian/rules with that from the official Debian package. Why are you overriding dh_auto_build? Why changing the MAKE variable?

GeekBoy 04-17-2020 11:57 PM

Been a while. With so many people at the house all the time now, I get endlessly interrupted, and hard to sit down and work on this stuff.



Anyway, I was trying to get the source from apt the wrong way.
Just running "apt-get source budgie-desktop" worked out fine.

Got a folder labeled "budgie-desktop-10.5," archive named, "budgie-desktop_10.5.orig.tar.xz," file named "budgie-desktop_10.5.orig.tar.xz.asc," another archive named "budgie-desktop_10.5-1.debian.tar.xz," and a file named "budgie-desktop_10.5-1.dsc."

At this point, I am not even sure what to do with all the different files as there seems to be no Debian documentation on what to to to get it to compile/patch/make .deb package.


Overriding dh_auto_build? Changing MAKE variable? Not sure what you mean. I have not changed anything. Just trying to learn how to build this, and make a repo package.

Any docs to point me to, or help on that?

Thanks again!

shruggy 04-18-2020 04:31 AM

Code:

sudo apt install build-essential devscripts
cd budgie-desktop-10.5
debuild -us -uc
ls ../*.deb

Quote:

Originally Posted by GeekBoy (Post 6113013)
Any docs to point me to, or help on that?

If all this is just in order to try your hand in rebuilding a Debian package, why not choose something simple like hello?

GeekBoy 04-19-2020 01:05 AM

[QUOTE=shruggy;6113082]
Code:

sudo apt install build-essential devscripts
cd budgie-desktop-10.5
debuild -us -uc
ls ../*.deb

That did not work out. It spit out about 100 or so errors.

I will check out the links.

Reason is because the simples are really not learning to build harder packages. Just do the commands and its done. Here we have something really to learn here.

Thanks

shruggy 04-19-2020 02:26 AM

Quote:

Originally Posted by GeekBoy (Post 6113344)
That did not work out. It spit out about 100 or so errors.

Are you sure the directory budgie-desktop-10.5 was unpacked by apt source and not left behind from your previous experiments?
Code:

rm -rf budgie-desktop-10.5
dpkg-source -x budgie-desktop-10.5-1.dsc

Lather, rinse, repeat :)

GeekBoy 04-19-2020 11:33 PM

No. I removed all previous ones, then made a special directory just for this project on April 17, then did the apt source.

However, I did go ahead and did those two commands above, and reran "debuild -us -uc" and got bit of a different result, but still a failure.



Quote:

[130/265] ccache cc -Isrc/wm/131f9c0@@budgie-wm@exe -Isrc/wm -I../../src/wm -I. -I../../ -Isrc/config -I../../src/config -I/usr/include/mutter -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/mutter/clutter-3 -I/usr/include/atk-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/json-glib-1.0 -I/usr/include/mutter/cogl -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libdrm -I/usr/include/gsettings-desktop-schemas -I/usr/include/gnome-desktop-3.0 -I/usr/include/ibus-1.0 -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -w -std=c11 -fstack-protector -pedantic -Wstrict-prototypes -Wundef -Werror-implicit-function-declaration -Wformat -Wformat-security -Werror=format-security -Wconversion -Wunused-variable -Wunreachable-code -Wall -W '-DGETTEXT_PACKAGE="budgie-desktop"' -g -O2 -fdebug-prefix-map=/home/trent/Developer/budgie/budgie-desktop-10.5=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -pthread -DGNOME_DESKTOP_USE_UNSTABLE_API -MD -MQ 'src/wm/131f9c0@@budgie-wm@exe/meson-generated_wm.c.o' -MF 'src/wm/131f9c0@@budgie-wm@exe/meson-generated_wm.c.o.d' -o 'src/wm/131f9c0@@budgie-wm@exe/meson-generated_wm.c.o' -c 'src/wm/131f9c0@@budgie-wm@exe/wm.c'
ninja: build stopped: subcommand failed.
make[1]: *** [debian/rules:30: override_dh_auto_build] Error 1
make[1]: Leaving directory '/home/trent/Developer/budgie/budgie-desktop-10.5'
make: *** [debian/rules:8: build] Error 2
dpkg-buildpackage: error: debian/rules build subprocess returned exit status 2
debuild: fatal error at line 1182:
dpkg-buildpackage -us -uc -ui failed

shruggy 04-20-2020 03:28 AM

There should be ninja build log somewhere (probably in debian/build). Try to find it:
Code:

find /home/trent/Developer/budgie/budgie-desktop-10.5/ -name .ninja_log
It may contain additional information related to the build failure.

You seem trying to build a buster package on sid. My instructions above (debuild) were for building packages for the same release you are on though. Building for other releases (and often even for the same one) is usually done via pbuilder.

GeekBoy 04-21-2020 08:36 PM

I happen to have another system up with Debian 9 which does not have any funny stuff going on.

I was able to grab source version 10.2.9 on there.


Running
Quote:

dh $@ --buildsystem=meson
again produced
Code:

dh: Unknown sequence --buildsystem=meson (options should not come before the sequence)

So, what is up with that?

Quote:

debuild -us -uc
did make successful packages. I am guessing all those extra ones are other requirements/dependencies?


Looks like I am going to have to put together a special system just for building packages.

Next up is for me to figure out to give them custom names.

Thanks a lot for this help.

shruggy 04-22-2020 02:54 AM

Quote:

Originally Posted by GeekBoy (Post 6114303)
Code:

dh $@ --buildsystem=meson
again produced
Code:

dh: Unknown sequence --buildsystem=meson (options should not come before the sequence)

This line is supposed to be written into debian/rules, not to be run from the command prompt. Sorry if I was not clear on this. $@ here is make's authomatic variable meaning name of the rule target. This can only work from inside a Makefile (which debian/rules happens to be). The command line equivalent for the build step only would be
Code:

dh build --buildsystem=meson
Quote:

Looks like I am going to have to put together a special system just for building packages.
Absolutely not. Check pbuilder links at the end of this post. As mentioned in #8 above, I successfully built budgie-desktop-10.5-3 from Debian sid on Ubuntu 18.04 (bionic) inside pbuilder chroot. Actually, this is the recommended way to build packages for a Debian-based system. debuild is mainly only used as a shortcut for quick test builds.

pbuilder links:

GeekBoy 05-11-2020 08:33 PM

So I finally was able to get around to this.


I added in "--buildsystem=meson" to the bottom of the ../debian/rules file.

Then ran the "dh build --buildsystem=meson" and it is getting errors.

Code:

dh_auto_configure -O--buildsystem=meson
dh_auto_configure: unable to load build system class 'meson': Can't locate Debian/Debhelper/Buildsystem/meson.pm in @INC (you may need to install the Debian::Debhelper::Buildsystem::meson module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.24.1 /usr/local/share/perl/5.24.1 /usr/lib/x86_64-linux-gnu/perl5/5.24 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.24 /usr/share/perl/5.24 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base .) at (eval 2) line 2.
BEGIN failed--compilation aborted at (eval 2) line 2.

This seems to me a perl module, but I am unable to locate it.


Thanks again!

shruggy 05-12-2020 12:40 AM

File meson.pm is in the package debhelper:
Code:

$ apt-file search meson.pm
debhelper: /usr/share/perl5/Debian/Debhelper/Buildsystem/meson.pm


GeekBoy 05-23-2020 11:34 AM

Quote:

Originally Posted by shruggy (Post 6122013)
File meson.pm is in the package debhelper:
Code:

$ apt-file search meson.pm
debhelper: /usr/share/perl5/Debian/Debhelper/Buildsystem/meson.pm


Quote:

apt install debhelper
Reading package lists... Done
Building dependency tree
Reading state information... Done
debhelper is already the newest version (10.2.5).



Executing
Code:

apt-file search meson.pm
returns nothing.

shruggy 05-23-2020 11:56 AM

Wait, now I'm confused. In #5 you were using Debian unstable (sid). It was debhelper 12.9 back then. Now, you're showing me you're using debhelper 10.2.5, which is the version in oldstable (Stretch). As I said in #4:
Quote:

Originally Posted by shruggy (Post 6106537)
if you're on Debian 9 (Stretch) you should use debhelper from stretch-backports


GeekBoy 05-24-2020 01:00 AM

Thanks for clearing that up. I guess I should of review the whole thread each time I come back.

I got debhelper from stretch-backport on now.

Now I am getting different errors.

When running dh build --buildsystem=meson

It returns:


Quote:

ERROR: Neither directory contains a build file meson.build.
dh_auto_configure: cd obj-x86_64-linux-gnu && LC_ALL=C.UTF-8 meson .. --wrap-mode=nodownload --buildtype=plain --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=lib/x86_64-linux-gnu --libexecdir=lib/x86_64-linux-gnu returned exit code 1
When doing debuild -us -uc

It gives me

Code:

dpkg-source: error: aborting due to unexpected upstream changes, see /tmp/budgie-desktop_10.2.9-2.diff.sAFm4E
dpkg-source: info: you can integrate the local changes with dpkg-source --commit
dpkg-buildpackage: error: dpkg-source -b budgie-desktop-10.2.9 gave error exit status 2
debuild: fatal error at line 1116:
dpkg-buildpackage -rfakeroot -us -uc failed


Thanks for all the help.

I guess I will go research those

bnopod 01-03-2021 10:20 AM

Quote:

Originally Posted by shruggy (Post 6114360)
This line is supposed to be written into debian/rules, not to be run from the command prompt. Sorry if I was not clear on this. $@ here is make's automatic variable meaning name of the rule target. This can only work from inside a Makefile (which debian/rules happens to be). The command line equivalent for the build step only would be
Code:

dh build --buildsystem=meson

Definitely from make script:
Code:

#! /usr/bin/make -f
#export DH_VERBOSE=1

%:
        dh $@ --with=python3 --buildsystem=meson

Here's mine , debhelper will attempt to pass through all build stages (clean, configure, build, test, install) launched:
Code:

  dpkg-buildpackage --no-sign

GeekBoy 01-18-2021 10:24 PM

I will certainly give that a look. I have not done anything on this since this post. I guess I need to start working on that again.

Thanks for the input


All times are GMT -5. The time now is 05:47 PM.