📜 ⬆️ ⬇️

Build GNU Emacs for Ubuntu

Issues related to OS administration are beyond my area of ​​interest, so when I need to solve one of these issues, I first try to find a short howto, if nothing is found, I sit down to read the manuals, which I safely forget after solving the problem. Therefore, for rarely solvable, but all the same from time to time problems that arise, I write myself cheat sheets. This article is one of them. What it is more about: “quick'n'dirty creating a deb package” or “briefly about assembling emacs.deb” - I don’t presume to judge, it will be suitable both as one and the other. The following is the build of GNU Emacs 24.0.92 from the source code in Ubuntu 11.10.

We start with the preparation of the site:

mkdir ~/build
cd ~/build


and creating, in case of its absence, a GPG-key with which the assembled package will be signed:

gpg --gen-key
gpg -a --output ~/.gnupg/john_doe.gpg --export 'John Doe'


A number of questions will be asked, the answers to which are intuitive. There is only one subtle point when creating the key - specify the same name that you will use later when creating the package.
')
Install the packages needed to build .deb:

sudo apt-get install build-essential autoconf automake autotools-dev dh-make debhelper devscripts fakeroot xutils lintian pbuilder

Now you need to get the source code for GNU Emacs:

bzr co --lightweight -v bzr://bzr.savannah.gnu.org/emacs/trunk emacs-24.0.92

Please note that the directory name for receiving the original codes - emacs-24.0.92 - must be chosen in accordance with the naming requirements for the directory containing the source codes for the .deb package: packagename-packageversion in lower case. You can check the version number of the program in the trunk by looking at the README here: http://bzr.savannah.gnu.org/lh/emacs/trunk/files .

We put in the state of readiness for the assembly directory with source codes. Ready state is the existence of a configure script. Run to generate it:

cd emacs-24.0.92
./autogen.sh


Now you need to make an archive-copy of the existing directory and put it on the same level with it:

tar -czvf ../emacs-24.0.92.tgz ../emacs-24.0.92/

We begin debianization:

dh_make -p emacs -e john.doe@gmail.com -c gpl3 -f ../emacs-24.0.92.tgz

where john.doe@gmail.com is replaced by your e-mail, we answer the question:

Type of package: single binary, indep binary, multiple binary, library, kernel module, kernel patch?

Choose "single binary".

As a result, a debian directory will be created (I always write the names of the files and directories relative to the current directory), which contains the files controlling the build of the package. We'll move on to editing them a bit later, but for now we’ll find out what needs to be written there as necessary packages for building. To do this, run:

dpkg-depcheck -d ./configure

If the system lacks something to build:

checking for library containing tputs... no
configure: error: The required function `tputs' was not found in any library.
These libraries were tried: libncurses, libterminfo, libtermcap, libcurses.
Please try installing whichever of these libraries is most appropriate
for your system, together with its header files.
For example, a libncurses-dev(el) or similar package.


then simply install the necessary:

sudo apt-get install libncurses5-dev

Search for the necessary (you can use regular expressions):

apt-cache search .*libncurses.*dev

Look at the output of the command ( dpkg-depcheck -d ./configure ) at the very end of a long listing:

Packages needed:
libgtk-3-dev


You will need to add this to the listed packages in the debian/control file in the “Build-Depends” line, separating the listed packages with a comma and a space. Look at the other fields in this file, edit them if necessary. Here are the contents of my file for comparison:

Source: emacs
Section: editors
Priority: extra
Maintainer: John Doe <john.doe@gmail.com>
Build-Depends: debhelper (>= 8.0.0), autotools-dev, libgtk-3-dev
Standards-Version: 3.9.2
Homepage: www.gnu.org/software/emacs

Package: emacs
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: GNU Emacs is an extensible, customizable text editor.


Detailed information on the contents of the debian/control file can be found here: http://www.debian.org/doc/manuals/maint-guide/dreq.ru.html#control .

Returning to the output of the configure command, look at what GNU Emacs will be built with, find the following lines:

What operating system and machine description files should Emacs use?
`s/gnu-linux.h' and `m/amdx86-64.h'
What compiler should emacs be built with? gcc -std=gnu99 -g -O2
Should Emacs use the GNU version of malloc? yes
(Using Doug Lea's new malloc from the GNU C Library.)
Should Emacs use a relocating allocator for buffers? no
Should Emacs use mmap(2) for buffer allocation? no
What window system should Emacs use? x11
What toolkit should Emacs use? GTK
Where do we find X Windows header files? Standard dirs
Where do we find X Windows libraries? Standard dirs
Does Emacs use -lXaw3d? no
Does Emacs use -lXpm? yes
Does Emacs use -ljpeg? yes
Does Emacs use -ltiff? yes
Does Emacs use a gif library? yes -lgif
Does Emacs use -lpng? yes
Does Emacs use -lrsvg-2? yes
Does Emacs use imagemagick? yes
Does Emacs use -lgpm? yes
Does Emacs use -ldbus? yes
Does Emacs use -lgconf? no
Does Emacs use GSettings? yes
Does Emacs use -lselinux? yes
Does Emacs use -lgnutls? yes
Does Emacs use -lxml2? yes
Does Emacs use -lfreetype? yes
Does Emacs use -lm17n-flt? yes
Does Emacs use -lotf? yes
Does Emacs use -lxft? yes
Does Emacs use toolkit scroll bars? yes


If support of some library is required (where there is “no”), deliver the necessary -dev packages to the system. The INSTALL file describes options for the configure script, using which you can configure the GNU Emacs assembly in different ways. Keep in mind that you are currently doing a test run of configure and doing dpkg-depcheck -d ./configure --without-png , for example, you do not affect the .deb package you create with compiled GNU Emacs. To pass the required parameters to the configure script during the build of a .deb package, add the following lines to the debian/rules :

override_dh_auto_configure:
dh_auto_configure -- --without-png


Please note that the second line should and starts with a tab character (here the parser has devoured everything and the indent is not visible).

And now a few words about the contents of debian/ . The build requires debian/{control, rules, copyright, changelog} all generated by running dh_make . In principle, you can not edit anything else, but paying tribute to the work of people, I suggest putting the debian/copyright file in order. Here is an example:

Format: dep.debian.net/deps/dep5
Upstream-Name: emacs
Source: savannah.gnu.org/bzr/?group=emacs
Maintainer: John Doe <john.doe@gmail.com>

Files: *
Copyright: Copyright (C) 2007 Free Software Foundation, Inc. <fsf.org>
License: GPL-3.0+

Files: debian/*
Copyright: 2011 John Doe <john.doe@gmail.com>
License: GPL-3.0+

License: GPL-3.0+
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <www.gnu.org/licenses>.
.
On Debian systems, the complete text of the GNU General
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".


Now, everything is ready for assembly. There was one problem - “make check”. Makefile built in such a way that there is a check target and it will be launched by the .deb build system. And since we leaked a trunk, and not a prepared release, the tests may not pass. At least I have it now. To skip the tests, you must set the environment variable DEB_BUILD_OPTIONS="nocheck" . So, run the assembly:

DEB_BUILD_OPTIONS="nocheck" dpkg-buildpackage -rfakeroot

without missing tests, the team looks like this:

dpkg-buildpackage -rfakeroot

By default, GNU Emacs is going with gtk3 support; you gtk3 not gtk3 to parameterize configure to build a nice- Gtk3 GUI version with Gtk3 support and Xft (freetype fonts), just repeat the steps in the as is article and get a normal full GNU Emacs assembly. If you did everything correctly, the package creation will be completed with the question of the secret phrase that was set when generating the PGP key. After that, a level above the current directory will contain the assembled .deb package, which can be installed into the system:

dpkg -i ../emacs_24.0.92-1_amd64.deb

That's all.

Information sources:
www.debian.org/doc/manuals/maint-guide/index.ru.html
www.webupd8.org/2010/01/how-to-create-deb-package-ubuntu-debian.html

Source: https://habr.com/ru/post/134951/


All Articles