Implement RFE #2664

Add a `-p` flag to %setup which ensures that the sources will be extracted in 
the root of the build directory.
It works by inspecting the archive and stripping the first path entry if the 
archive has a top level directory alone in the root.

The archive inspection and path stripping is implemented in rpmuncompress which 
now has a new `-p` flag:

    $ ~/rpm/usr/lib/rpm/rpmuncompress -x -v -p source-1.0.0 
source-singleroot.tar.gz
    mkdir 'source-1.0.0' ;  /usr/bin/gzip -dc  
'source-singleroot.tar.gz' | /usr/bin/tar -xvvof -  -C 
'source-1.0.0' --strip-components=1
    -rw-r--r-- root/root        32 2024-01-16 19:13 source-xxxxxxxxxx/file1
    -rw-r--r-- root/root     33886 2024-01-16 19:13 source-xxxxxxxxxx/file2
    drwxr-xr-x root/root         0 2024-01-16 19:13 source-xxxxxxxxxx/dir1/
    -r--r--r-- root/root       210 2024-01-16 19:13 source-xxxxxxxxxx/dir1/file3

    $ find source-1.0.0 -ls
        92341      0 drwxr-xr-x   1 teknoraver teknoraver       28 Jan 16 19:16 
source-1.0.0
        92342      4 -rw-r--r--   1 teknoraver teknoraver       32 Jan 16 19:13 
source-1.0.0/file1
        92343     36 -rw-r--r--   1 teknoraver teknoraver    33886 Jan 16 19:13 
source-1.0.0/file2
        92344      0 drwxr-xr-x   1 teknoraver teknoraver       10 Jan 16 19:13 
source-1.0.0/dir1
        92345      4 -r--r--r--   1 teknoraver teknoraver      210 Jan 16 19:13 
source-1.0.0/dir1/file3

    $ ~/rpm/usr/lib/rpm/rpmuncompress -x -v -p source-2.0.0 source-noroot.tar.gz
    mkdir 'source-2.0.0' ;  /usr/bin/gzip -dc  
'source-noroot.tar.gz' | /usr/bin/tar -xvvof -  -C 
'source-2.0.0'
    drwxr-xr-x root/root         0 2024-01-16 19:13 dir1/
    -r--r--r-- root/root       210 2024-01-16 19:13 dir1/file3
    -rw-r--r-- root/root        32 2024-01-16 19:13 file1
    -rw-r--r-- root/root     33886 2024-01-16 19:13 file2

    $ find source-2.0.0 -ls
        92346      0 drwxr-xr-x   1 teknoraver teknoraver       28 Jan 16 19:17 
source-2.0.0
        92347      0 drwxr-xr-x   1 teknoraver teknoraver       10 Jan 16 19:13 
source-2.0.0/dir1
        92348      4 -r--r--r--   1 teknoraver teknoraver      210 Jan 16 19:13 
source-2.0.0/dir1/file3
        92349      4 -rw-r--r--   1 teknoraver teknoraver       32 Jan 16 19:13 
source-2.0.0/file1
        92350     36 -rw-r--r--   1 teknoraver teknoraver    33886 Jan 16 19:13 
source-2.0.0/file2
You can view, comment on, or merge this pull request online at:

  https://github.com/rpm-software-management/rpm/pull/2859

-- Commit Summary --

  * add build directory auto path to setup step

-- File Changes --

    M CMakeLists.txt (5)
    M build/parsePrep.c (13)
    M docs/manual/spec.md (3)
    M tools/CMakeLists.txt (1)
    M tools/rpmuncompress.c (75)

-- Patch Links --

https://github.com/rpm-software-management/rpm/pull/2859.patch
https://github.com/rpm-software-management/rpm/pull/2859.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/2859
You are receiving this because you are subscribed to this thread.

Message ID: <rpm-software-management/rpm/pull/2...@github.com>
_______________________________________________
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint

Reply via email to