Created
October 24, 2015 17:30
-
-
Save Ram-Z/24c9ba6e01d3b8ef0043 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dest=$1 | |
for pkg in *.pkg.tar.xz; do | |
if tar -xaO --force-local -f "$pkg" .PKGINFO | grep -q "gitrepo = $dest"; then | |
echo "$pkg skipped" | |
continue | |
fi | |
pkgbase="${pkg%.tar.xz}" | |
echo -n "$pkg ..." | |
sudo tar -xa --one-top-level="$pkgbase" --force-local -f "$pkg" | |
sudo sed "s/^\(gitrepo = \).*/\1$dest/" -i "$pkgbase/.PKGINFO" | |
# zcat $pkgbase/.MTREE | sed "/^\.\/\.PKGINFO/{ | |
# s/md5digest=[^ ]*/md5digest=$(md5sum .PKGINFO|cut -d' ' -f1)/; | |
# s/sha256digest=[^ ]*/sha256digest=$(sha256sum .PKGINFO|cut -d' ' -f1)/ | |
# }" | gzip > .MTREE | |
# mv .MTREE $pkgbase/.MTREE | |
sudo bsdtar cf - -C"$pkgbase" $(find "$pkgbase" -printf "%P ") | xz -c -z - > "$pkg" | |
sudo rm -r "$pkgbase" | |
echo "done" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment