Unify and make customizable output of obtained upstream data

This commit is contained in:
Michael Raskin 2012-11-08 22:59:57 +04:00
parent 8af08d0d36
commit a73aa0458a

View File

@ -107,20 +107,36 @@ target () {
echo "Target set to: $CURRENT_TARGET" echo "Target set to: $CURRENT_TARGET"
} }
marker () {
BEGIN_EXPRESSION="$1"
}
update_found () { update_found () {
echo "Compare: $CURRENT_VERSION vs $PACKAGED_VERSION" echo "Compare: $CURRENT_VERSION vs $PACKAGED_VERSION"
[ "$CURRENT_VERSION" != "$PACKAGED_VERSION" ] [ "$CURRENT_VERSION" != "$PACKAGED_VERSION" ]
} }
do_write_expression () {
echo "${1}rec {"
echo "${1} baseName=\"$CURRENT_NAME\";"
echo "${1} version=\"$CURRENT_VERSION\";"
echo "${1} name=\"$CURRENT_NAME-$CURRENT_VERSION\";"
echo "${1} hash=\"$CURRENT_HASH\";"
echo "${1} url=\"$CURRENT_URL\";"
echo "${1} sha256=\"$CURRENT_HASH\";"
echo "$2"
}
do_regenerate () { do_regenerate () {
cat "$1" | grep -F '# Generated upstream information' -B 999999; BEFORE="$(cat "$1" | grep -F "$BEGIN_EXPRESSION" -B 999999;)"
echo " rec {" AFTER_EXPANDED="$(cat "$1" | grep -F "$BEGIN_EXPRESSION" -A 999999 | grep -E '^ *[}] *; *$' -A 999999;)"
echo " baseName=\"$CURRENT_NAME\";" AFTER="$(echo "$AFTER_EXPANDED" | tail -n +2)"
echo " version=\"$CURRENT_VERSION\";" CLOSE_BRACE="$(echo "$AFTER_EXPANDED" | head -n 1)"
echo ' name="${baseName}-${version}";' SPACING="$(echo "$CLOSE_BRACE" | sed -re 's/[^ ].*//')"
echo " hash=\"$CURRENT_HASH\";"
echo " url=\"$CURRENT_URL\";" echo "$BEFORE"
cat "$1" | grep -F '# Generated upstream information' -A 999999 | grep -E '^ *[}]; *$' -A 999999; do_write_expression "$SPACING" "$CLOSE_BRACE"
echo "$AFTER"
} }
do_overwrite () { do_overwrite () {
@ -132,6 +148,7 @@ do_overwrite () {
process_config () { process_config () {
CONFIG_DIR="$(directory_of "$1")" CONFIG_DIR="$(directory_of "$1")"
source "$CONFIG_DIR/$(basename "$1")" source "$CONFIG_DIR/$(basename "$1")"
BEGIN_EXPRESSION='# Generated upstream information';
retrieve_version retrieve_version
ensure_version ensure_version
update_found && do_overwrite "$CURRENT_TARGET" update_found && do_overwrite "$CURRENT_TARGET"