Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Repack expired packages and strip off certs
#!/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
You can’t perform that action at this time.