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

Commit

Permalink
Use fakeroot to build debs unless run as root
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
michaelweghorn committed Feb 7, 2018
1 parent e7b5b4c commit 47ccec5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion deb.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,11 @@ make_subpackage(const char *prodname,
if (Verbosity)
printf("Building Debian %s binary distribution...\n", name);

if (run_command(directory, "dpkg --build %s", name))
// run with 'fakeroot' if command available and epm not run as root
if (geteuid() && !run_command(NULL, "fakeroot --version")) {
if (run_command(directory, "fakeroot dpkg --build %s", name))
return (1);
} else if (run_command(directory, "dpkg --build %s", name))
return (1);

/*
Expand Down
6 changes: 4 additions & 2 deletions epm.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,9 +558,11 @@ main(int argc, /* I - Number of command-line args */
i = make_slackware(prodname, directory, platname, dist, &platform);
break;
case PACKAGE_DEB :
if (geteuid())
// check whether EPM is run as root or fakeroot is available
if (geteuid() && run_command(NULL, "fakeroot --version"))
fputs("epm: Warning - file permissions and ownership may not be correct\n"
" in Debian packages unless you run EPM as root!\n", stderr);
" in Debian packages unless you run EPM as root or the 'fakeroot'\n"
" command is available!\n", stderr);

i = make_deb(prodname, directory, platname, dist, &platform);
break;
Expand Down

0 comments on commit 47ccec5

Please sign in to comment.