# first create a container to build in so as not to pollute your host with the build requirements: # the container name will be "builder" lxc launch ubuntu:17.10 builder lxc exec builder /bin/bash # at this point you have a root shell inside the container, totally isolated from the host file-system # the following is a transcript of the build I did including commands typed and output. Where commands # generated a LOT of output (as some do - especially the 'fakeroot debian/rules binary' command ) # I have replaced all but the first and last messages with ... # # where you see a shell prompt as in the line below you only type the command e.g: apt-get source avahi-daemon root@builder:~# apt-get source avahi-daemon Picking 'avahi' as source package instead of 'avahi-daemon' NOTICE: 'avahi' packaging is maintained in the 'Git' version control system at: git://anonscm.debian.org/pkg-utopia/avahi.git Please use: git clone git://anonscm.debian.org/pkg-utopia/avahi.git to retrieve the latest (possibly unreleased) updates to the package. Need to get 1334 kB of source archives. ... W: Download is performed unsandboxed as root as file 'avahi_0.6.32-1ubuntu1.dsc' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied) root@builder:~# wget https://launchpadlibrarian.net/319077549/avahi-rlimits-artful.debdiff --2018-03-04 13:49:00-- https://launchpadlibrarian.net/319077549/avahi-rlimits-artful.debdiff Resolving launchpadlibrarian.net (launchpadlibrarian.net)... 91.189.89.228, 91.189.89.229 Connecting to launchpadlibrarian.net (launchpadlibrarian.net)|91.189.89.228|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 6651 (6.5K) [text/plain] Saving to: ‘avahi-rlimits-artful.debdiff’ avahi-rlimits-artful.debdiff 100%[=====================================================================================================>] 6.50K --.-KB/s in 0.001s 2018-03-04 13:49:01 (5.92 MB/s) - ‘avahi-rlimits-artful.debdiff’ saved [6651/6651] root@builder:~# head avahi-rlimits-artful.debdiff diff -Nru avahi-0.6.32/debian/changelog avahi-0.6.32/debian/changelog --- avahi-0.6.32/debian/changelog 2016-07-04 09:28:53.000000000 -0400 +++ avahi-0.6.32/debian/changelog 2017-05-09 13:53:37.000000000 -0300 @@ -1,3 +1,13 @@ +avahi (0.6.32-1ubuntu2) artful; urgency=medium + + * d/p/0002-Remove-default-rlimit-nproc-3.patch, + 0003-Remove-default-rlimits-from-avahi-daemon.conf.patch: Patches from + upstream git to remove all overly restrictive default rlimit restrictions + in avahi-daemon.conf which can cause avahi to crash out of memory or fail root@builder:~# patch -p0 < avahi-rlimits-artful.debdiff patching file avahi-0.6.32/debian/changelog patching file avahi-0.6.32/debian/patches/0002-Remove-default-rlimit-nproc-3.patch patching file avahi-0.6.32/debian/patches/0003-Remove-default-rlimits-from-avahi-daemon.conf.patch patching file avahi-0.6.32/debian/patches/series root@builder:~# cd avahi-0.6.32/ root@builder:~/avahi-0.6.32# apt-get build-dep avahi-daemon Reading package lists... 100% Reading package lists... Done Picking 'avahi' as source package instead of 'avahi-daemon' Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: adwaita-icon-theme dconf-gsettings-backend dconf-service dh-systemd gir1.2-atk-1.0 gir1.2-atspi-2.0 gir1.2-freedesktop gir1.2-gdkpixbuf-2.0 gir1.2-gtk-2.0 gir1.2-gtk-3.0 gir1.2-pango-1.0 glib-networking glib-networking-common glib-networking-services gsettings-desktop-schemas gtk-update-icon-cache hicolor-icon-theme humanity-icon-theme icu-devtools intltool libatk-bridge2.0-0 libatk-bridge2.0-dev libatk1.0-0 libatk1.0-data libatk1.0-dev libatspi2.0-0 libatspi2.0-dev libaudio2 libavahi-client3 libcairo-gobject2 libcairo-script-interpreter2 libcairo2 libcairo2-dev libcap-dev libcapnp-0.5.3 libcolord2 libcups2 libdaemon-dev libdatrie1 libdbus-1-dev libdconf1 libdrm-amdgpu1 libdrm-dev libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libegl1-mesa libegl1-mesa-dev libepoxy-dev libepoxy0 libexpat1-dev libfontconfig1-dev libfreetype6-dev libgbm1 libgdbm-dev libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-common libgdk-pixbuf2.0-dev libgl1-mesa-dri libglapi-mesa libglib2.0-bin libglib2.0-dev libglib2.0-dev-bin libgraphite2-3 libgraphite2-dev libgtk-3-0 libgtk-3-common libgtk-3-dev libgtk2.0-0 libgtk2.0-common libgtk2.0-dev libharfbuzz-dev libharfbuzz-gobject0 libharfbuzz-icu0 libharfbuzz0b libice-dev libice6 libicu-dev libjbig0 libjpeg-turbo8 libjpeg8 libjson-glib-1.0-0 libjson-glib-1.0-common liblcms2-2 libllvm5.0 libmirclient-dev libmirclient9 libmircommon-dev libmircommon7 libmircookie-dev libmircookie2 libmircore-dev libmircore1 libmirprotobuf3 libmng2 libpango-1.0-0 libpango1.0-dev libpangocairo-1.0-0 libpangoft2-1.0-0 libpangoxft-1.0-0 libpciaccess0 libpcre16-3 libpcre3-dev libpcre32-3 libpcrecpp0v5 libpixman-1-0 libpixman-1-dev libpng-dev libprotobuf-dev libprotobuf-lite10 libprotobuf10 libproxy1v5 libpthread-stubs0-dev libpython-all-dev libpython-dev libpython2.7-dev libqt4-dbus libqt4-declarative libqt4-designer libqt4-dev libqt4-dev-bin libqt4-help libqt4-network libqt4-qt3support libqt4-script libqt4-scripttools libqt4-sql libqt4-svg libqt4-test libqt4-xml libqt4-xmlpatterns libqtcore4 libqtdbus4 libqtgui4 librest-0.7-0 librsvg2-2 librsvg2-common libsensors4 libsm-dev libsm6 libsoup-gnome2.4-1 libsoup2.4-1 libthai-data libthai0 libtiff5 libwayland-bin libwayland-client0 libwayland-cursor0 libwayland-dev libwayland-egl1-mesa libwayland-server0 libx11-dev libx11-xcb-dev libx11-xcb1 libxau-dev libxcb-dri2-0 libxcb-dri2-0-dev libxcb-dri3-0 libxcb-dri3-dev libxcb-glx0 libxcb-glx0-dev libxcb-present-dev libxcb-present0 libxcb-randr0 libxcb-randr0-dev libxcb-render0 libxcb-render0-dev libxcb-shape0 libxcb-shape0-dev libxcb-shm0 libxcb-shm0-dev libxcb-sync-dev libxcb-sync1 libxcb-xfixes0 libxcb-xfixes0-dev libxcb1-dev libxcomposite-dev libxcomposite1 libxcursor-dev libxcursor1 libxdamage-dev libxdamage1 libxdmcp-dev libxext-dev libxfixes-dev libxfixes3 libxft-dev libxft2 libxi-dev libxi6 libxinerama-dev libxinerama1 libxkbcommon-dev libxkbcommon0 libxml2-utils libxrandr-dev libxrandr2 libxrender-dev libxrender1 libxshmfence-dev libxshmfence1 libxt6 libxtst-dev libxtst6 libxxf86vm-dev libxxf86vm1 pkg-config python-all-dev python-cairo python-dbus python-dev python-gdbm python-gobject-2 python-gtk2 python2.7-dev qdbus qt4-linguist-tools qt4-qmake qtchooser qtcore4-l10n ubuntu-mono wayland-protocols x11-common x11proto-composite-dev x11proto-core-dev x11proto-damage-dev x11proto-dri2-dev x11proto-fixes-dev x11proto-gl-dev x11proto-input-dev x11proto-kb-dev x11proto-randr-dev x11proto-record-dev x11proto-render-dev x11proto-xext-dev x11proto-xf86vidmode-dev x11proto-xinerama-dev xmltoman xorg-sgml-doctools xtrans-dev zlib1g-dev 0 upgraded, 241 newly installed, 0 to remove and 46 not upgraded. Need to get 119 MB of archives. After this operation, 580 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://archive.ubuntu.com/ubuntu artful/main amd64 libjpeg-turbo8 amd64 1.5.2-0ubuntu5 [110 kB] ... Get:241 http://archive.ubuntu.com/ubuntu artful/universe amd64 dh-systemd all 10.7.2ubuntu2 [2600 B] Fetched 119 MB in 1min 49s (1088 kB/s) Extracting templates from packages: 100% Selecting previously unselected package libjpeg-turbo8:amd64. (Reading database ... 100% (Reading database ... 45182 files and directories currently installed.) Preparing to unpack .../000-libjpeg-turbo8_1.5.2-0ubuntu5_amd64.deb ... Unpacking libjpeg-turbo8:amd64 (1.5.2-0ubuntu5) ... ... Processing triggers for ureadahead (0.100.0-20) ... Processing triggers for libgdk-pixbuf2.0-0:amd64 (2.36.11-1ubuntu0.1) ... root@builder:~/avahi-0.6.32# fakeroot debian/rules binary dh binary --with autotools-dev,python2,systemd,autoreconf dh_update_autotools_config dh_autotools-dev_updateconfig debian/rules override_dh_autoreconf make[1]: Entering directory '/root/avahi-0.6.32' NOCONFIGURE=1 dh_autoreconf --as-needed ./autogen.sh ... Renaming avahi-ui-utils-dbgsym_0.6.32-1ubuntu2_amd64.deb to avahi-ui-utils-dbgsym_0.6.32-1ubuntu2_amd64.ddeb root@builder:~/avahi-0.6.32# ls ../*.deb root@builder:~/avahi-0.6.32# exit # at this point you are outside the container and back with the host so now copy the built debian packages mkdir $HOME/Downloads/avahi sudo cp /var/lib/lxd/containers/builder/rootfs/root/*.deb $HOME/Downloads/avahi/ sudo chown -R $USER:$USER $HOME/Downloads/avahi cd $HOME/Downloads/avahi/ ls # the next command finds out which avahi packages are currently installed, creates a list of the new packages, and installs them sudo dpkg -i $(dpkg -l '*avahi*' | awk '/^ii/ {print gensub(":.*","",1,$2)}' | uniq | while read pkg; do ls -1 "${pkg}"*; done )