Created
October 28, 2019 17:28
-
-
Save brunerd/6a0104cab32c0c372653555b072a98db to your computer and use it in GitHub Desktop.
Repack expired packages and strip off certs
This file contains 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 | |
#Joel "brunerd" Bruner - repack and expired pkg, stripping off all certs | |
#we can specify a target as an argument | |
target="$1" | |
#if target not specified we ask | |
while [ ! -d "${target}" -a ! -f "${target}" ]; do | |
read -p "Please provide a target file or folder: " target | |
done | |
#if directory get all the pkg files inside | |
if [ -d "${target}" ]; then | |
fileList=$(find "${target}" -name '*pkg') | |
else | |
fileList="${target}" | |
fi | |
#ignore spaces and only respect newlines in for loop | |
IFS=$'\n' | |
#got through each file | |
for file in ${fileList}; do | |
#expand the pkg to folder with the extension removed | |
pkgutil --expand "${file}" "${file%.*}" | |
#flatten the package with "-repack.pkg" appended to the name | |
pkgutil --flatten "${file%.*}" "${file%.*}"-repack.pkg | |
#delete the expanded temp folder | |
rm -rf "${file%.*}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment