Open gfrankliu opened 3 months ago
Looks like release 1.0.0 introduced pkg_tar create_parents attribute that I can set to False to fix the issue in my test example above where "file2.tar" only includes the file, not the parent directory.
The new create_parents attribute wouldn't help if file2.tar includes the parent directory, eg, using the new file2.tar:
gfrankliu@gfrankliu /tmp/test $ tar cvf file2.tar ./bin
./bin/
./bin/test
gfrankliu@gfrankliu /tmp/test $ tar tvf file2.tar
drwxr-xr-x gfrankliu/primarygroup 0 2024-06-23 10:47 ./bin/
-rw-r--r-- gfrankliu/primarygroup 0 2024-06-23 10:47 ./bin/test
In the real world use case where
The data.tar.xz from most deb files has the parent directory included. eg: data.tar.xz from iproute2 deb package has:
...
drwxr-xr-x root/root 0 2023-05-22 13:19 ./bin/
-rwxr-xr-x root/root 691016 2023-05-22 13:19 ./bin/ip
-rwxr-xr-x root/root 193680 2023-05-22 13:19 ./bin/ss
drwxr-xr-x root/root 0 2023-05-22 13:19 ./usr/bin/
-rwxr-xr-x root/root 27224 2023-05-22 13:19 ./usr/bin/lnstat
-rwxr-xr-x root/root 106952 2023-05-22 13:19 ./usr/bin/nstat
-rwxr-xr-x root/root 184936 2023-05-22 13:19 ./usr/bin/rdma
-rwxr-xr-x root/root 1658 2023-05-22 13:19 ./usr/bin/routel
...
So "bin" (parent directory) is there, just like in my new test file2.tar. Adding this new iproute2 tar would remove the Debian 12 bin -> usr/bin symlink, and create a new bin with only files from iproute2. In this case, /bin/sh will be gone, since bin->usr/bin link is gone.
I tried pkg_tar to flatten the tar files:
I created 2 test tar files:
If I manually untar file1 and then file2, I get correct result:
If I use pkg_tar:
The resulting tar tvf flatten.tar looks like this:
If I extract the flatten.tar (tar -xvf ...), I get
As you can see, the symlink /bin got deleted, so pkg_tar doesn't seem to create the correct flatten tar file. The exploded directories from if I manually untar file1.tar, file2.tar, vs if I untar the flatten.tar look different.