I’m making a deb package to install a custom application. I changed all files/folders ownership to root in order to avoid the warnings I was getting during installation, and in Ubuntu all runs smoothly, as Ubuntu changes the ownership of the files/folders to the user installing the package.
But when I’m installing on Debian, root remains the owner. The application uses a folder to write data, and here is the problem. Running as a standard user, the app does not have permission to write on the folder.
Now, how should I deal with this problem? Should I make a post install script on the deb package, doing the chmod o+w? Should I package the directory already with those permissions set?
Or is there any way of setting the owner of the files to the user that installs the app automatically (like Ubuntu does)?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
I’m not sure what the behaviour is in Ubuntu, but in general for a .deb package containing files or directories with non-standard permissions you need to ensure those permissions are set after dh_fixperms is run. If you’re using a dh-style rules, you can do this as follows:
override_dh_fixperms:
dh_fixperms
chmod 777 yourfolder
or
execute_after_dh_fixperms:
chmod 777 yourfolder
You can also do this in a postinst:
if [ "$1" = "configure" ]; then
chmod 777 yourfolder
fi
but the rules approach is simpler (at least, I prefer doing that rather than relying on maintainer scripts).
Method 2
I don’t have the reputation to comment, so I’m providing another answer.
I created a directory using dh_installdirs, but I couldn’t get “override_dh_fixperms” or the newer “execute_after_dh_fixperms” rules to work. I tried a variety of paths including “debian/<package_name>/path/to/dir” as per “https://manpages.debian.org/testing/debhelper/dh.1.en.html”
Ultimately, the only thing that worked was providing a “postinst” script. I would have preferred to specify the permissions in “rules”, but sometimes you just have to do what it takes.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0