Ticket #7667: ipkg-tar-preserve-permissions.patch

File ipkg-tar-preserve-permissions.patch, 1.2 KB (added by ermo <rune.morling+openwrt@…, 6 years ago)

ipkg -- preserve permissions when unpacking .ipk

  • scripts/ipkg

    old new  
    739739        local ext="`echo $filename | sed 's/.*\.//'`" 
    740740        local pkg_extract_stdout 
    741741        if [ "$ext" = "ipk" ]; then 
    742                 pkg_extract_stdout="tar -xzOf" 
     742            # Preserve permissions when extracting tar archives as a non-root user (-p). 
     743                pkg_extract_stdout="tar -xzpOf" 
    743744        elif [ "$ext" = "deb" ]; then 
    744745                pkg_extract_stdout="ar p" 
    745746        else 
     
    803804        set -o noglob 
    804805        rm -r $IPKG_TMP/$pkg/control 
    805806 
    806         if ! $pkg_extract_stdout $filename ./data.tar.gz | (cd $IPKG_TMP/$pkg/data; zcat | tar -xf - ) ; then 
     807        # Preserve permissions when extracting data.tar.gz as non-root user (-p). 
     808        if ! $pkg_extract_stdout $filename ./data.tar.gz | (cd $IPKG_TMP/$pkg/data; zcat | tar -xpf - ) ; then 
    807809                echo "ipkg_install_file: ERROR unpacking data.tar.gz from $filename" 
    808810                return 1 
    809811        fi 
     
    871873        fi 
    872874 
    873875        local owd="`pwd`" 
    874         (cd $IPKG_TMP/$pkg/data/; tar cf - . | (cd $owd; cd $dest; tar xf -)) 
     876        # Preserve permissions when creating/extracting tar archives as non-root user (-p). 
     877        (cd $IPKG_TMP/$pkg/data/; tar -cpf - . | (cd $owd; cd $dest; tar -xpf -)) 
    875878        rm -rf $IPKG_TMP/$pkg/data 
    876879        rmdir $IPKG_TMP/$pkg 
    877880        rm -f $info_dir/$pkg.list