Skip to content
This repository was archived by the owner on Oct 19, 2021. It is now read-only.

Commit f25c71f

Browse files
Use fakeroot to build debs unless run as root
Use 'fakeroot' to build Debian packages when EPM is not run as root and the 'fakeroot' command is available. This ensures that ownerships and permisssions inside the generated package are correct.
1 parent e7b5b4c commit f25c71f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

deb.c

+5
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,11 @@ make_subpackage(const char *prodname,
584584
if (Verbosity)
585585
printf("Building Debian %s binary distribution...\n", name);
586586

587+
// run with 'fakeroot' if command available and epm not run as root
588+
if (geteuid() && !run_command(NULL, "fakeroot --version")) {
589+
if (run_command(directory, "fakeroot dpkg --build %s", name))
590+
return (1);
591+
}
587592
if (run_command(directory, "dpkg --build %s", name))
588593
return (1);
589594

epm.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -558,9 +558,11 @@ main(int argc, /* I - Number of command-line args */
558558
i = make_slackware(prodname, directory, platname, dist, &platform);
559559
break;
560560
case PACKAGE_DEB :
561-
if (geteuid())
561+
// check whether EPM is run as root or fakeroot is available
562+
if (geteuid() && run_command(NULL, "fakeroot --version"))
562563
fputs("epm: Warning - file permissions and ownership may not be correct\n"
563-
" in Debian packages unless you run EPM as root!\n", stderr);
564+
" in Debian packages unless you run EPM as root or the 'fakeroot'\n"
565+
" command is available!\n", stderr);
564566

565567
i = make_deb(prodname, directory, platname, dist, &platform);
566568
break;

0 commit comments

Comments
 (0)