Created
July 31, 2015 14:46
-
-
Save smoser/e447db5ae65606660a1f to your computer and use it in GitHub Desktop.
hack-install cloud-init from source over the top of a install
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/sh | |
# this just hacks the current directory (cloud-init source) over the top | |
# of a install'd deb version | |
target_d="" | |
src_d="$PWD" | |
python="/usr/bin/python3" | |
error() { echo "$@" 1>&2; } | |
fail() { [ $# -eq 0 ] || error "$@"; exit 1; } | |
ref="cloudinit/cloud.py" | |
if [ -z "$target_d" ]; then | |
out=$(dpkg -L cloud-init) || fail "couldnt find installed cloud-init" | |
path=$(echo "$out" | grep "$ref$") && [ -f "$path" ] || | |
fail "could not find $ref in installed cloud-init" | |
target_d=$(cd "${path%/*}/.." && pwd) | |
fi | |
[ -f "$src_d/$ref" ] || fail "$src_d: doesnt have $ref" | |
echo "target_d=$target_d" | |
echo "src_d=$src_d" | |
bins=$(cd "$src_d" && find bin/ -type f) || fail "failed to find bins" | |
for bin in $bins; do | |
[ -f "/usr/bin/${bin#*/}" ] || | |
{ error "skipping $bin"; continue; } | |
error "binary $bin" | |
tfile="/usr/bin/${bin##*/}" | |
cp "$bin" "$tfile" || fail "failed cp $bin" | |
sed -i '1{/#!.usr.bin.python/s,.*,#!'"$python"',}' "$tfile" || | |
fail "failed fix launcher in $bin" | |
done | |
for path in $(cd "$src_d" && find cloudinit -name "*.py" -type f); do | |
echo "$path" 1>&2 | |
cp "$src_d/$path" "$target_d/$path" || fail "failed copy" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment