View Single Post
coderus's Avatar
Posts: 6,436 | Thanked: 12,701 times | Joined on Nov 2011 @ Ängelholm, Sweden
#76
faster refhashlist script on shell
Code:
#!/bin/sh
#refhashlist patcher

cp /var/lib/aegis/refhashlist /var/lib/aegis/refhashlist.backup

pathname=$1
if [ "$pathname" == "" ]; then exit 1; fi

line=$(grep "${pathname}" /var/lib/aegis/refhashlist)
if [ "$line" == "" ]; then exit 2;
else
        #oldsha1=$(for ii in $(sha1sum /${pathname}); do echo $ii; break; done) #real file sha1
        #oldsha1=$(i=0; for ii in $line; do i=$((i+1)); if [ $i -eq 6 ]; then echo $ii; break; fi; done;) #sha1 parsed from line, not real sha1
        oldsha1=$(echo ${line} | sed -re "s/.*([a-f0-9]{40}).*/\1/") #faster sha1 extraction using regexp
        newsha1=$(for ii in $(sha1sum "/${pathname}"); do echo $ii; break; done)
        newline=$(echo ${line} | sed -e "s/${oldsha1}/${newsha1}/")
        sed -i -e "s@${line}@${newline}@" /var/lib/aegis/refhashlist

        accli -c tcb-sign -F /var/lib/aegis/refhashlist < /var/lib/aegis/refhashlist
fi
changing sha1 only for choosed file
refhashlist.sh usr/bin/grob #without first slash
__________________
Telegram | Openrepos | GitHub | Revolut donations