4

I am interested to build a deb package for ubuntu 18.04. I have found this article help me, How to create NGINX debian package from souce?.

My question is, Is it safe to build deb package using root privilege? Because I have to use sudo checkinstall, instead of checkinstall.

So far I know, we should not build rpm package using root privilege. And I am wondering if this term is not available for deb package.

TIA

1 Answer 1

4

This forum thread outlines a basic way to create a .deb package for distribution, and indeed, this does not involve a need for root privileges. I replicate it here with credit to the forum user curvedinfinity, as a very nice illustration of the basics involved.

The checkinstall tool described in the link you provided is not primarily intended for general .deb package preparation. It is primarily intended to install software you compile yourself in a way that the package manager knows about it. Accordingly, it requires root privileges. The trick used indeed is to create a .deb file specific for your system, and then install that one. The .deb it creates may not be suited for general distribution.

Excerpt from Ubuntuforums by curedfinity:

Decide on the name of your package. Standard debian notation is all lowercase in the following format:

<project>_<major version>.<minor version>-<package revision>

For example, you could name your first package...

helloworld_1.0-1

Create a directory to make your package in. The name should be the same as the package name.

mkdir helloworld_1.0-1

Pretend that the packaging directory is actually the root of the file system. Put the files of your program where they would be installed to on a system.

mkdir helloworld_1.0-1/usr
mkdir helloworld_1.0-1/usr/local
mkdir helloworld_1.0-1/usr/local/bin
cp "~/Projects/Hello World/helloworld" helloworld_1.0-1/usr/local/bin

Now create a special metadata file with which the package manager will install your program...

mkdir helloworld_1.0-1/DEBIAN
gedit helloworld_1.0-1/DEBIAN/control

Put something like this in that file...

Package: helloworld
Version: 1.0-1
Section: base
Priority: optional
Architecture: i386
Depends: libsomethingorrather (>= 1.2.13), anotherDependency (>= 1.2.6)
Maintainer: Your Name <[email protected]>
Description: Hello World
 When you need some sunshine, just run this
 small program!

(the space before each line in the description is important)

Now, supposing your current directory is the one containing the folder helloworld_1.0-1, you just need to make the package:

dpkg-deb --build helloworld_1.0-1

And you're done!

End of citation.

9
  • So, it is a security when install the deb package that is created by sudo checkinstall on vps production server, isnt it?
    – Abdul
    Apr 2, 2019 at 9:48
  • What I outlined would be standard procedure, which does not need root permissions. The deb produced by checkinstall may serve your purposes, but involves using root permissions. The general safety caution associated with running processes with elevated permissions apply if you go that way. Your question is primarily focused to create a deb without the need for root permissions, as suggested by the title and the first and last paragraphs.
    – vanadium
    Apr 2, 2019 at 10:40
  • Is it safe doing this and then install it to on another machine ?
    – Abdul
    Apr 3, 2019 at 14:55
  • Feel free to ask a new question. Comments are intended to improve the question and the answers, not for discussion.
    – vanadium
    Apr 3, 2019 at 16:21
  • Pardon me the confusion. I am just a newbie with no where linux basic knowledge.
    – Abdul
    Apr 4, 2019 at 2:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .