Skip to content

Instantly share code, notes, and snippets.

@jarosite
Last active August 29, 2015 14:19
Show Gist options
  • Save jarosite/9a663a68ff806e77d201 to your computer and use it in GitHub Desktop.
Save jarosite/9a663a68ff806e77d201 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -x
set -e
REPO_NAME=production
YUM_SERVER_URL=http://localhost:8888/yum-repo-server
FILES=*.rpm
curl -s -d "name=$REPO_NAME" $YUM_SERVER_URL/repo
for f in $FILES
do
echo "Processing $f file..."
SEARCH_RESULT=`curl -s $YUM_SERVER_URL/repo/?search=$f | python -c 'import sys, json; print json.dumps(json.load(sys.stdin)["items"])'`
if [ "$SEARCH_RESULT" != "[]" ]; then
ARCH_FROM=`python -c "import json; print json.loads('$SEARCH_RESULT')[0]['arch']"`
REPO_FROM=`python -c "import json; print json.loads('$SEARCH_RESULT')[0]['repo']"`
if [ "$REPO_FROM" != "$REPO_NAME" ]; then
curl -s -d "source=$REPO_FROM/$ARCH_FROM/$f&destination=$REPO_NAME" $YUM_SERVER_URL/propagation
fi
else
curl -s -F "rpmFile=@$f $YUM_SERVER_URL/repo/$REPO_NAME"
fi
done
curl -s -XPOST $YUM_SERVER_URL/repo/$REPO_NAME/repodata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment