I want to build a tar file as regular (non-root) user with some prepared binaries and configuration files like this;
etc/binaries.conf
usr/bin/binary1
usr/bin/binary2
that are mean to be extracted into the file system under the /
directory.
Like a traditional software package .deb, .rpm etc but I need to be "package manager independent". So probably I will just have a .tar file (maybe some gzip, bzip, lzip should be added to the mix but that's outside).
PROBLEM / QUESTION
My problem here is that I don't want to build this tar as the root user, and I want to know if there is a way to build this tar as a regular (non-root) user and then, when the .tar file is distributed to the machines and the real root
user extract those binaries, they will be installed as files owned by the root user or the user who extract the binaries ?
EXAMPLE
Because right now, when I just create the .tar file as a regular (non-root) user with
$ tar cf dist.tar dist/
And then extract the .tar as root user with
# tar xf dist.tar -C /
I see the binaries and the config file with the regular user as owner, not the root user.
$ ls -la /usr/bin/binary1
-rwxr-xr-x 1 user user 30232 jun 20 19:06 /usr/bin/binary1
And I wan to have
$ ls -la /usr/bin/binary1
-rwxr-xr-x 1 root root 30232 jun 20 19:06 /usr/bin/binary1
Just to clarify, this hand made packaging is very specific for some task in a closed infrastructure, so right now, using .deb, .rpm or any other more sophisticated packaging system is not an option.