Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
set -e
#
# Run through all package deps
#
for PACKAGE_NAME in $( cd packages ; find . -type d -depth 1 | cut -c3- ) ; do
[ -e "packages/${PACKAGE_NAME}/deps" ] || continue
for DEP_NAME in $( cd "packages/${PACKAGE_NAME}/deps" ; find . -type d -depth 1 | cut -c3- ) ; do
./bin/deps-upgrade "${PACKAGE_NAME}" "${DEP_NAME}"
done
done
#
# Check if we actually updated anything
#
DIFFS=$( echo $( git diff HEAD --name-only | wc -l ) )
if [ 0 -eq $DIFFS ] ; then
# no changes; nothing else to do
exit
elif [ 1 -eq $DIFFS ] ; then
COMMIT_HEADER="Upgraded 1 package dependency"
else
COMMIT_HEADER="Upgraded ${DIFFS} package dependencies"
fi
#
# Upload new blobs
#
bosh -n upload blobs
git add config/blobs.yml
#
# Generate the commit message
#
(
echo "${COMMIT_HEADER}"
PACKAGE_CURR=""
for VERSION_PATH in $(
git diff HEAD --name-only \
| grep -E "^packages/([^/]+)/deps/([^/]+)/VERSION$" \
| sort
) ; do
git add "${VERSION_PATH}"
DEP_NAME=$( basename $( dirname "${VERSION_PATH}" ) )
PACKAGE_NAME=$( basename $( dirname $( dirname $( dirname "${VERSION_PATH}" ) ) ) )
if [[ "$PACKAGE_CURR" != "$PACKAGE_NAME" ]] ; then
echo ""
echo "${PACKAGE_NAME}"
echo ""
PACKAGE_CURR="${PACKAGE_NAME}"
fi
VERSION_OLD=$( git show HEAD:$VERSION_PATH )
VERSION_NEW=$( cat "${VERSION_PATH}" )
echo " * ${DEP_NAME} now ${VERSION_NEW} (was ${VERSION_OLD})"
done
) > commit.msg
#
# Create the commit
#
git commit -F commit.msg
#
# Cleanup after ourselves
#
rm commit.msg
#!/bin/bash
# args: package-name dep-name
set -e
set -u
export PACKAGE_NAME="${1}"
export DEP_NAME="${2}"
DEP_DIR="${PWD}/packages/${PACKAGE_NAME}/deps/${DEP_NAME}"
DEP_BLOB_DIR="${PWD}/blobs/${PACKAGE_NAME}-blobs/${DEP_NAME}"
echo "==> ${PACKAGE_NAME}/${DEP_NAME}"
if [ -f "${DEP_DIR}/VERSION" ] ; then
VERSION_LOCAL=$( cat "${DEP_DIR}/VERSION" )
else
VERSION_LOCAL=missing
fi
echo "--| local ${VERSION_LOCAL}"
VERSION_CHECK=$( . "${DEP_DIR}/check" )
echo "--| check ${VERSION_CHECK}"
if [[ "${VERSION_CHECK}" == "${VERSION_LOCAL}" ]] ; then
exit
fi
echo "--> fetching new version"
rm -fr "${DEP_BLOB_DIR}-new"
mkdir -p "${DEP_BLOB_DIR}-new"
cd "${DEP_BLOB_DIR}-new"
export VERSION="${VERSION_CHECK}"
"${DEP_DIR}/get"
rm -fr "${DEP_BLOB_DIR}"
mv "${DEP_BLOB_DIR}-new" "${DEP_BLOB_DIR}"
echo "${VERSION}" > "${DEP_DIR}/VERSION"
echo "-->" $( du -sh ${DEP_BLOB_DIR} | cut -f1 )
#!/bin/bash
set -e
curl -s -l \
ftp://xmlsoft.org/libxml2/ \
| grep -E '^libxml2-.+.tar.gz$' \
| sed -E 's/^libxml2-(.+)\.tar.gz$/\1/' \
| grep -E '^\d+\.\d+\.\d+\w*$' \
| gsort -rV \
| head -n1
#!/bin/bash
set -e
wget \
-q \
-O- \
http://hg.nginx.org/nginx/tags?style=raw \
| cut -f1 \
| grep '^release-' \
| sed -E 's/^release-(.+)$/\1/' \
| gsort -rV \
| head -n1
#!/bin/bash
set -e
git ls-remote --tags https://github.com/openssl/openssl.git \
| cut -f2 \
| grep -Ev '\^{}' \
| grep -E '^refs/tags/OpenSSL_.+$' \
| sed -E 's/^refs\/tags\/OpenSSL_(.+)$/\1/' \
| tr '_' '.' \
| grep -E '^\d+\.\d+\.\d+\w*$' \
| gsort -rV \
| head -n1
#!/bin/bash
set -e
curl -s -l \
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ \
| grep -E '^pcre-.+.tar.gz$' \
| sed -E 's/^pcre-(.+)\.tar.gz$/\1/' \
| gsort -rV \
| head -n1
#!/bin/bash
set -e
wget -qO- "https://api.wordpress.org/plugins/info/1.0/$( echo $DEP_NAME | cut -c8- ).json" | jq -r '.version'
#!/bin/bash
set -e
git ls-remote --tags https://github.com/madler/zlib.git \
| cut -f2 \
| grep -Ev '\^{}' \
| grep -E '^refs/tags/v.+$' \
| sed -E 's/^refs\/tags\/v(.+)$/\1/' \
| tr '_' '.' \
| grep -v '-' \
| gsort -rV \
| head -n1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment