Skip to content

Instantly share code, notes, and snippets.

@Mno-hime
Last active January 15, 2019 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mno-hime/b28f069ab566ab86186e4d33fbe5f1b0 to your computer and use it in GitHub Desktop.
Save Mno-hime/b28f069ab566ab86186e4d33fbe5f1b0 to your computer and use it in GitHub Desktop.
Rebuild updated components in oi-userland
#!/bin/bash
CWD="${PWD}"
if [[ ! $PWD =~ 'oi-userland/components' ]]; then
echo "ERROR: Current working directory ($PWD) is not 'oi-userland/components' directory"
exit 1
fi
function run {
local exit_status=1
local command="$*"
while [[ $exit_status != 0 ]]; do
echo -n "[\e[32m${component}\e[m] RUN: \e[33m${command}\e[m \e[34mS\e[mkip/\e[34mI\e[mnteractive/\e[34mProceed\e[m: "
read reply
case $reply in
s|S)
echo "\tStep skipped"
return 2
;;
i|I)
interactive_session
continue
;;
esac
${command}
exit_status=$?
done
}
function interactive_session {
local message="$*"
echo "This is interactive shell session. When done close the session by 'exit' command"
echo "\n${message}\n"
bash
}
function list_latest_userland_packages {
echo "\nUserland packages built today:"
echo "==============================================================="
pkgrepo list -s ${CWD}/../i386/repo/ | awk '{ print $2"@"$3 }' | grep :$(date +%Y%m%d)T
echo "==============================================================="
pkgrepo list -s ${CWD}/../i386/encumbered-repo/ | awk '{ print $2"@"$3 }' | grep :$(date +%Y%m%d)T
echo "==============================================================="
}
components="$(git diff | grep '+++ b.*Makefile' | sed -e 's|+++ b/components/\(.*\)/Makefile|\1|' | sort | uniq)"
echo "Components for publication:\n\n${components}\n"
for component in $components; do
echo -n ">>> Build \e[32m${component}\e[m? \e[34mS\e[mkip/\e[34mProceed\e[m: "
read reply
if [[ "${reply}" == 's' || "${reply}" == 'S' ]]; then
continue
fi
pushd $component > /dev/null && echo "Entering '${component}' directory"
run gmake clean env-prep
run gmake sample-manifest
run git diff -- manifests/sample-manifest.p5m
if [[ "$?" == "0" ]]; then
interactive_session "Review following component .p5m files:\n\n$(ls -l *.p5m)"
fi
run gmake REQUIRED_PACKAGES
if [[ "$?" == "0" ]]; then
interactive_session "Review component Makefile"
fi
run gmake MAKEFILE_PREREQ= publish
run git commit -e -v -m Rebuild .
popd > /dev/null
done
list_latest_userland_packages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment