Last active
January 8, 2021 07:58
-
-
Save Aftermath/f808be4ef678667ec91c293a759eb8af to your computer and use it in GitHub Desktop.
Script to create PULP_MANIFEST for 'file' repo type in Satellite 6.2+
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 | |
# | |
# PULP_MANIFEST Generator | |
# | |
REPO="$1" | |
if [ -z "$REPO" ]; then | |
echo "Please specify a directory to run against as an absolute path." | |
exit 1 | |
elif [ ! -d "$REPO" ]; then | |
echo "Please ensure you specify a directory!" | |
exit 1 | |
fi | |
if ! [[ "$REPO" =~ /$ ]]; then | |
REPO="$REPO/" | |
fi | |
if [ -e "$REPO/PULP_MANIFEST" ];then | |
rm -f "$REPO/PULP_MANIFEST" | |
echo "Cleaned old manifest at $REPO/PULP_MANIFEST, creating new!" | |
fi | |
function create_pulp_manifest () | |
{ | |
for file in `find $REPO -type f`;do | |
checksum=$(sha256sum $file | awk '{print $2","$1}') | |
size=$(stat -Lc "%s" $file) | |
echo "Adding File: $file.." | |
echo -e "$checksum,$size" >> "$REPO/PULP_MANIFEST" | |
done | |
} | |
create_pulp_manifest | |
# Ensure file names do not include paths to repo directory | |
sed -i -e 's-^./--g' $REPO/PULP_MANIFEST | |
sed -i -e "s-^$REPO--g" $REPO/PULP_MANIFEST | |
echo "Complete." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To avoid issues with directories containing a "-" in the name, change the seperator in the sed-commands to (for example) #.
It would read:
sed -i -e 's#^./##g' $REPO/PULP_MANIFEST
sed -i -e "s#^$REPO##g" $REPO/PULP_MANIFEST