Last active
February 26, 2016 18:25
-
-
Save tuxmea/069dd382cc373cfc4a78 to your computer and use it in GitHub Desktop.
Get all modules from voxpupuli usng myrepos (mr)
This file contains hidden or 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 | |
set -e | |
# Strongly adapted from | |
# http://anonscm.debian.org/gitweb/?p=pkg-ruby-extras/pkg-ruby-extras.git;a=blob;f=make-mrconfig | |
function msg() { | |
echo "I: $1" | |
} | |
function output() { | |
echo "$1" >> $OUTPUT | |
} | |
msg "Setting up output file" | |
OUTPUT="$1" | |
if [ -z "$OUTPUT" ] ; then | |
OUTPUT=".mrconfig" | |
fi | |
msg "Retrieving puppet voxpupuli modules list" | |
# Modules hosted on github | |
GIT_PKGS=`curl https://api.github.com/orgs/voxpupuli/repos?per_page=200 | grep clone_url | cut -d '"' -f 4 | cut -d '/' -f 5 | cut -d '.' -f1` | |
msg "Generating mrconfig file in $OUTPUT" | |
# Backup the output file if it exists | |
if [ -f $OUTPUT ]; then | |
mv $OUTPUT ${OUTPUT}\~ | |
fi | |
# Setting up mr lib | |
output "[DEFAULT] | |
lib= | |
msg () { | |
echo \"I: \$1\" | |
} | |
git_checkout () { | |
git clone https://github.com/voxpupuli/\$1.git | |
} | |
git_fetch () { | |
git fetch --all | |
} | |
" | |
# Sections for Git repositories | |
for i in $GIT_PKGS; do | |
output "[$i] | |
checkout = git_checkout $i | |
fetch = git_fetch $i | |
" | |
done | |
# Warn if changes have been made | |
if which colordiff >/dev/null; then | |
diff=colordiff | |
else | |
diff=diff | |
fi | |
if [ -f ${OUTPUT}\~ ] && $diff -u ${OUTPUT}\~ ${OUTPUT}; then | |
rm ${OUTPUT}\~ | |
msg "no changes" | |
else | |
msg "$OUTPUT changed!" | |
fi | |
# Finish | |
msg "all done, enjoy: mr [checkout,update,...]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment