Skip to content

Instantly share code, notes, and snippets.

@Aftermath
Last active January 8, 2021 07:58
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Aftermath/f808be4ef678667ec91c293a759eb8af to your computer and use it in GitHub Desktop.
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+
#!/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."
@pvdmarel
Copy link

pvdmarel commented Jan 8, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment