Permissions cannot be restored for a tar

Question: Permissions cannot be restored for a tar

Answer: only root can.

Reference: read this informative Q&A on askubuntu:

even if you use tar's --same-owner flag, you will still need to extract the files as root to preserve ownership.

Update: Here's some more details about tar's behaviour. Let's say we are user1 and have created an archive with tar cvpzf test.tar.gz . that includes files owned by user2. If we extract the archive in a directory owned by user2 with permissions 777, here's the outcome:

$ tar xpvzf test.tar.gz
./
./file1
./file2
tar: .: Cannot utime: Operation not permitted
tar: .: Cannot change mode to rwxrwxr-x: Operation not permitted
tar: Exiting with failure status due to previous errors

$ ls -al
drwxrwxrwx 2 user2 user2 .
-rw-rw-r-- 1 user1 user1 file1
-rw-rw-r-- 1 user1 user1 file2

tar throws an error because it cannot change ownership and permissions for files owned by user2. The files are however extracted, although owned by user1.

Here's what happens if the extraction is performed in a directory owned by user1 instead:

$ tar xpvzf test.tar.gz
./
./file1
./file2

$ ls -al
drwxrwxr-x 2 user1 user1 .
-rw-rw-r-- 1 user1 user1 file1
-rw-rw-r-- 1 user1 user1 file2

Permissions are restored for both the folder and the files, and no error is thrown even though user2 ownership could not be restored.

Judging from the OP's own answer, it seems then that the installer checks tar's exit code and stops if an error was encountered. chowning the folder to the current user makes tar fail silently so the installer can continue.


chmod -R 777 Downloads/* sudo chmod -R 777 /opt/* mkdir /opt/pkg cd /home/my_ubuntu/Downloads chmod +x petalinux-v2017.1-final-installer.run ./petalinux-v2017.1-final-installer.run /opt/pkg

now it will install and tar file permissions are restored when u create the directory pkg as normal user and not the root user.