Allow update-walker to run directly from meta attributes

This commit is contained in:
Michael Raskin 2014-07-01 11:28:35 +04:00
parent 5ed1adbbd4
commit 2e12709a26

View File

@ -2,12 +2,14 @@
own_dir="$(cd "$(dirname "$0")"; pwd)" own_dir="$(cd "$(dirname "$0")"; pwd)"
URL_WAS_SET=
CURRENT_URL= CURRENT_URL=
CURRENT_REV= CURRENT_REV=
PREFETCH_COMMAND= PREFETCH_COMMAND=
NEED_TO_CHOOSE_URL=1 NEED_TO_CHOOSE_URL=1
url () { url () {
URL_WAS_SET=1
CURRENT_URL="$1" CURRENT_URL="$1"
} }
@ -101,14 +103,25 @@ ensure_name () {
ensure_attribute_name () { ensure_attribute_name () {
echo "Ensuring attribute name. CURRENT_ATTRIBUTE_NAME: $CURRENT_ATTRIBUTE_NAME" >&2 echo "Ensuring attribute name. CURRENT_ATTRIBUTE_NAME: $CURRENT_ATTRIBUTE_NAME" >&2
ensure_name
[ -z "$CURRENT_ATTRIBUTE_NAME" ] && attribute_name "$CURRENT_NAME" [ -z "$CURRENT_ATTRIBUTE_NAME" ] && attribute_name "$CURRENT_NAME"
echo "Resulting attribute name: $CURRENT_ATTRIBUTE_NAME" echo "Resulting attribute name: $CURRENT_ATTRIBUTE_NAME"
} }
ensure_url () {
echo "Ensuring starting URL. CURRENT_URL: $CURRENT_URL" >&2
ensure_attribute_name
[ -z "$CURRENT_URL" ] && CURRENT_URL="$(retrieve_meta downloadPage)"
[ -z "$CURRENT_URL" ] && CURRENT_URL="$(retrieve_meta downloadpage)"
[ -z "$CURRENT_URL" ] && CURRENT_URL="$(retrieve_meta homepage)"
echo "Resulting URL: $CURRENT_URL"
}
ensure_choice () { ensure_choice () {
echo "Ensuring that choice is made." >&2 echo "Ensuring that choice is made." >&2
echo "NEED_TO_CHOOSE_URL: [$NEED_TO_CHOOSE_URL]." >&2 echo "NEED_TO_CHOOSE_URL: [$NEED_TO_CHOOSE_URL]." >&2
echo "CURRENT_URL: $CURRENT_URL" >&2 echo "CURRENT_URL: $CURRENT_URL" >&2
[ -z "$URL_WAS_SET" ] && [ -z "$CURRENT_URL" ] && ensure_url
[ -n "$NEED_TO_CHOOSE_URL" ] && { [ -n "$NEED_TO_CHOOSE_URL" ] && {
version_link '[.]tar[.]([^./])+$' version_link '[.]tar[.]([^./])+$'
unset NEED_TO_CHOOSE_URL unset NEED_TO_CHOOSE_URL
@ -153,8 +166,12 @@ attribute_name () {
echo "CURRENT_ATTRIBUTE_NAME: $CURRENT_ATTRIBUTE_NAME" >&2 echo "CURRENT_ATTRIBUTE_NAME: $CURRENT_ATTRIBUTE_NAME" >&2
} }
retrieve_meta () {
nix-instantiate --eval-only '<nixpkgs>' -A "$CURRENT_ATTRIBUTE_NAME".meta."$1" | xargs
}
retrieve_version () { retrieve_version () {
PACKAGED_VERSION="$(nix-instantiate --eval-only '<nixpkgs>' -A "$CURRENT_ATTRIBUTE_NAME".meta.version | xargs)" PACKAGED_VERSION="$(retrieve_meta version)"
} }
directory_of () { directory_of () {
@ -256,7 +273,24 @@ process_config () {
CONFIG_DIR="$(directory_of "$1")" CONFIG_DIR="$(directory_of "$1")"
CONFIG_NAME="$(basename "$1")" CONFIG_NAME="$(basename "$1")"
BEGIN_EXPRESSION='# Generated upstream information'; BEGIN_EXPRESSION='# Generated upstream information';
if [ -f "$CONFIG_DIR/$CONFIG_NAME" ] &&
[ "${CONFIG_NAME}" = "${CONFIG_NAME%.nix}" ]; then
source "$CONFIG_DIR/$CONFIG_NAME" source "$CONFIG_DIR/$CONFIG_NAME"
else
CONFIG_NAME="${CONFIG_NAME%.nix}"
ensure_attribute_name
[ -n "$(retrieve_meta updateWalker)" ] ||
[ -n "$FORCE_UPDATE_WALKER" ] || {
echo "Error: package not marked as safe for update-walker" >&2
echo "Set FORCE_UPDATE_WALKER=1 to override" >&2
exit 1;
}
[ -z "$(retrieve_meta fullRegenerate)" ] && eval "
do_overwrite(){
do_overwrite_just_version
}
"
fi
ensure_name ensure_name
ensure_attribute_name ensure_attribute_name
retrieve_version retrieve_version