Should I login as root while creating packages?

General talk about packaging procedures and packages.
User avatar
gapan
Salix Wizard
Posts: 6241
Joined: 6. Jun 2009, 17:40

Re: Should I login as root while creating packages?

Post by gapan »

Ah, it's SlackBuild, not Slackbuild... Learn to use the tab key to avoid such errors.
Image
Image
User avatar
sqlpython
Donor
Posts: 310
Joined: 13. Aug 2010, 04:53
Location: Ct. USA

Re: Should I login as root while creating packages?

Post by sqlpython »

Here is my Question
I have been going su to build my packages happily since 1994.
Yet never had an issue.
What am I doing wrong?

Note: matter of fact the first time I encountered fakeroot was while using Arch about a year ago.
Slackware ( Manjaro ) Salix, AntiX, Bunsen, Calculate
User avatar
gapan
Salix Wizard
Posts: 6241
Joined: 6. Jun 2009, 17:40

Re: Should I login as root while creating packages?

Post by gapan »

sqlpython wrote:Here is my Question
I have been going su to build my packages happily since 1994.
Yet never had an issue.
That you were made aware of.
sqlpython wrote:What am I doing wrong?
The problem is not what you are doing wrong. The problem is what anyone else might have accidentally (or on purpose) done wrong with their SlackBuilds and their Makefiles. I'll give you a few examples where you'd be in real trouble (sometimes without knowing it):

1. A SlackBuild includes something like this:

Code: Select all

# we don't need /usr/bin in the package since it is empty
rm -rf $PGK/usr/bin
did you notice the typo? It's not easy to spot even in a single line of code, even more so in a SlackBuild with about a hundred lines of code. That is assuming that you check each and every SlackBuild that you run line by line for errors (which nobody really does). If you run this as root, it will wipe your entire /usr/bin, completely destroying your system. Run it with fakeroot and it's harmless.

2. A SlackBuild includes this:

Code: Select all

cp this_file /usr/share/mypkg/
running the SlackBuild as root, will create you a package that will run happily on the same system that you built the package on, but complain about missing files in any other system you try to install the package. Now start debugging... you might be lucky if you catch it within a couple of hours, if ever. Run it with fakeroot and package building errors out, so you know something is definitely wrong.

and lots of similar cases... If you insist that you indeed check (you'd be lying, nobody really does) each and every SlackBuild that you run (or that at least all the other people at SBo do that - which you don't really know) and there's no way that something like that will ever get past you, then I'm 100% sure that you don't check each and every Makefile that those SlackBuilds run, line by line. Consider those kinds of problems could be present in the Makefiles, instead of the SlackBuilds. I've seen a lot (and I really mean a lot) of Makefiles installing stuff directly on the system's / dir. That would render the respective SlackBuilds completely useless. I'm sure such cases are present in SBo, but since the vast majority of users only install packages for the same PC that they're building them, nobody ever notices anything.

Now, you tell me, what are the advantages of building packages as the root user?
Image
Image
User avatar
john256
Posts: 89
Joined: 1. Jun 2011, 07:52

Re: Should I login as root while creating packages?

Post by john256 »

gapan wrote:Ah, it's SlackBuild, not Slackbuild... Learn to use the tab key to avoid such errors.
Of course do I use the tab-key to autocomplete, so the issue is not a typo.
User avatar
gapan
Salix Wizard
Posts: 6241
Joined: 6. Jun 2009, 17:40

Re: Should I login as root while creating packages?

Post by gapan »

john256 wrote:Of course do I use the tab-key to autocomplete, so the issue is not a typo.
Are you running it from the same directory the slackbuild is present? Give the output of the

Code: Select all

ls -l
command in the same directory that you're running the command.
Image
Image
User avatar
john256
Posts: 89
Joined: 1. Jun 2011, 07:52

Re: Should I login as root while creating packages?

Post by john256 »

Here is the listing of the directory (I am on another PC now, so I re-created it):

Code: Select all

> ls -la
total 4772
drwxr-xr-x 2 jjbj users    4096 Jan 26 13:28 .
drwxr-xr-x 3 jjbj users    4096 Jan 26 13:27 ..
-rw-r--r-- 1 jjbj users      63 Jan 26 13:28 git-1.9.0-build.log
-rw-r----- 1 jjbj users 4839724 Jan 26 13:27 git-1.9.0.tar.gz
-rwxr-x--x 1 jjbj users    4863 Jan 26 13:26 git.SlackBuild
-rw-r----- 1 jjbj users      32 Jan 26 13:27 git.url
-rw-r----- 1 jjbj users     851 Jan 26 13:27 slack-desc.txt
User avatar
gapan
Salix Wizard
Posts: 6241
Joined: 6. Jun 2009, 17:40

Re: Should I login as root while creating packages?

Post by gapan »

Does the same thing happen to you in that other PC?
Image
Image
User avatar
john256
Posts: 89
Joined: 1. Jun 2011, 07:52

Re: Should I login as root while creating packages?

Post by john256 »

gapan wrote:Does the same thing happen to you in that other PC?
Yes, exactly the same error :-(
User avatar
gapan
Salix Wizard
Posts: 6241
Joined: 6. Jun 2009, 17:40

Re: Should I login as root while creating packages?

Post by gapan »

Create a new user, log in with that and try again.
Image
Image
User avatar
john256
Posts: 89
Joined: 1. Jun 2011, 07:52

Re: Should I login as root while creating packages?

Post by john256 »

Everything worked after I logged out and in again. I guess the problem was related to the messed-up $PATH during the various experiments. Thanks! :D
Post Reply