aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ingmar Vanhassel <ingmar@exherbo.org> 2008-10-11 18:28:57 +0200
committerAvatar Ingmar Vanhassel <ingmar@exherbo.org> 2009-03-20 01:31:04 +0100
commitb66e82ad199907124c3de966ecbc12f4cca113ea (patch)
tree0908d9414248e80f7bc3eb2183ab7ba95a58a056
parent7baab3f67d5f4aab261bd13795266ac66b0b24ce (diff)
downloadpaludis-b66e82ad199907124c3de966ecbc12f4cca113ea.tar.gz
paludis-b66e82ad199907124c3de966ecbc12f4cca113ea.tar.xz
ever: Add remaining commands. fixes:327.
-rw-r--r--paludis/repositories/e/e_repository_TEST_ever.cc5
-rwxr-xr-xpaludis/repositories/e/e_repository_TEST_ever_setup.sh127
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/ever_functions.bash22
-rw-r--r--paludis/repositories/e/pipe_command_handler.cc81
4 files changed, 226 insertions, 9 deletions
diff --git a/paludis/repositories/e/e_repository_TEST_ever.cc b/paludis/repositories/e/e_repository_TEST_ever.cc
index 830cba8..52ae1ec 100644
--- a/paludis/repositories/e/e_repository_TEST_ever.cc
+++ b/paludis/repositories/e/e_repository_TEST_ever.cc
@@ -169,5 +169,10 @@ namespace test_cases
EverTest test_at_least("ever-at-least");
EverTest test_major("ever-major");
EverTest test_range("ever-range");
+ EverTest test_remainder("ever-remainder");
+ EverTest test_replace("ever-replace");
+ EverTest test_replace_all("ever-replace_all");
+ EverTest test_delete("ever-delete");
+ EverTest test_delete_all("ever-delete_all");
}
diff --git a/paludis/repositories/e/e_repository_TEST_ever_setup.sh b/paludis/repositories/e/e_repository_TEST_ever_setup.sh
index d5ffdb8..c412b62 100755
--- a/paludis/repositories/e/e_repository_TEST_ever_setup.sh
+++ b/paludis/repositories/e/e_repository_TEST_ever_setup.sh
@@ -69,7 +69,7 @@ LICENCES="GPL-2"
PLATFORMS="test"
check() {
- a=$(ever split $1 )
+ a=$(ever split "$1" )
[[ "${a}" == "${2}" ]] || die "got $a wanted $2"
}
@@ -91,7 +91,7 @@ LICENCES="GPL-2"
PLATFORMS="test"
check() {
- a=$(ever split_all $1 )
+ a=$(ever split_all "$1" )
[[ "${a}" == "${2}" ]] || die "got $a wanted $2"
}
@@ -113,7 +113,7 @@ LICENCES="GPL-2"
PLATFORMS="test"
check() {
- a=$(ever major $1 )
+ a=$(ever major "$1" )
[[ "${a}" == "${2}" ]] || die "got $a wanted $2"
}
@@ -137,7 +137,7 @@ LICENCES="GPL-2"
PLATFORMS="test"
check() {
- a=$(ever range $1 $2 )
+ a=$(ever range "$1" "$2" )
[[ "${a}" == "${3}" ]] || die "got $a wanted $3"
}
@@ -149,6 +149,125 @@ pkg_setup() {
check "1" "" "1"
}
END
+mkdir -p "packages/cat/ever-remainder"
+cat <<'END' > packages/cat/ever-remainder/ever-remainder-1.ebuild || exit 1
+HOMEPAGE="http://example.com/"
+DOWNLOADS=""
+SLOT="0"
+MYOPTIONS="spork"
+LICENCES="GPL-2"
+PLATFORMS="test"
+
+check() {
+ a=$(ever remainder "$1" )
+ [[ "${a}" == "${2}" ]] || die "got $a wanted $2"
+}
+
+pkg_setup() {
+ check "" ""
+ check "1" ""
+ check "1.2" "2"
+ check "1.2.3" "2.3"
+ check "7-scm" "scm"
+ check "scm" ""
+ check "1_pre7" "pre7"
+ check "2_beta1" "beta1"
+ check "1.3b" "3b"
+ check "123b" "b"
+}
+END
+mkdir -p "packages/cat/ever-replace"
+cat <<'END' > packages/cat/ever-replace/ever-replace-1.ebuild || exit 1
+HOMEPAGE="http://example.com/"
+DOWNLOADS=""
+SLOT="0"
+MYOPTIONS="spork"
+LICENCES="GPL-2"
+PLATFORMS="test"
+
+check() {
+ a=$(ever replace "$1" "$2" "$3" )
+ [[ "${a}" == "${4}" ]] || die "got '$a' wanted '$4'"
+}
+
+pkg_setup() {
+ check "1" - "2.3" "2-3"
+ check "2" - "1.2_beta3_pre1" "1.2-beta3_pre1"
+ check "0" _ "1.2.3" "1.2.3"
+ check "1" _ "1-scm" "1_scm"
+ check "2" _ "1-scm" "1-scm"
+ check "3" _ "1_beta2" "1_beta2"
+ check "99" . "1.2.3-r4" "1.2.3-r4"
+}
+END
+mkdir -p "packages/cat/ever-replace_all"
+cat <<'END' > packages/cat/ever-replace_all/ever-replace_all-1.ebuild || exit 1
+HOMEPAGE="http://example.com/"
+DOWNLOADS=""
+SLOT="0"
+MYOPTIONS="spork"
+LICENCES="GPL-2"
+PLATFORMS="test"
+
+check() {
+ a=$(ever replace_all "$1" "$2" )
+ [[ "${a}" == "${3}" ]] || die "got $a wanted '$3'"
+}
+
+pkg_setup() {
+ check "" "1.2.3" "123"
+ check _ "1.2.3" "1_2_3"
+ check . "1.2.3-scm-r42" "1.2.3.scm.r42"
+ check . "1.2_beta1_p3" "1.2.beta1.p3"
+ check . "1.3b" "1.3b"
+}
+END
+mkdir -p "packages/cat/ever-delete"
+cat <<'END' > packages/cat/ever-delete/ever-delete-1.ebuild || exit 1
+HOMEPAGE="http://example.com/"
+DOWNLOADS=""
+SLOT="0"
+MYOPTIONS="spork"
+LICENCES="GPL-2"
+PLATFORMS="test"
+
+check() {
+ a=$(ever delete "$1" "$2")
+ [[ "${a}" == "${3}" ]] || die "got '$a' wanted '$3'"
+}
+
+pkg_setup() {
+ check 0 "1.2.3" "1.2.3"
+ check 1 "1.2.3" "12.3"
+ check 2 "1.2.3" "1.23"
+ check 3 "1.2.3" "1.2.3"
+ check 1 "1_beta2-try3" "1beta2-try3"
+}
+END
+mkdir -p "packages/cat/ever-delete_all"
+cat <<'END' > packages/cat/ever-delete_all/ever-delete_all-1.ebuild || exit 1
+HOMEPAGE="http://example.com/"
+DOWNLOADS=""
+SLOT="0"
+MYOPTIONS="spork"
+LICENCES="GPL-2"
+PLATFORMS="test"
+
+check() {
+ a=$(ever delete_all "$1" )
+ [[ "${a}" == "${2}" ]] || die "got '$a' wanted '$2'"
+}
+
+pkg_setup() {
+ check "1" "1"
+ check "1.2.3" "123"
+ check "1.2-r1" "12r1"
+ check "1.2_alpha1" "12alpha1"
+ check "4.5.6_p7" "456p7"
+ check "1.2.3-scm" "123scm"
+}
+END
+
cd ..
cd ..
diff --git a/paludis/repositories/e/ebuild/exheres-0/ever_functions.bash b/paludis/repositories/e/ebuild/exheres-0/ever_functions.bash
index 376042a..d59717f 100644
--- a/paludis/repositories/e/ebuild/exheres-0/ever_functions.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/ever_functions.bash
@@ -45,18 +45,30 @@ ever()
;;
remainder)
+ [[ "${#@}" != 1 ]] && [[ "${#@}" != 2 ]] && die "$0 $1 takes at most one extra argument"
+ r=$(paludis_pipe_command EVER "$EAPI" RANGE 2- "${2:-${PV}}" )
;;
- replace_separator)
+ replace)
+ [[ "${#@}" != 3 ]] && [[ "${#@}" != 4 ]] && die "$0 $1 takes two or three extra arguments"
+ [[ -z "${2}" ]] && die "$0 $1 takes a non-empty position as first argument"
+ r=$(paludis_pipe_command EVER "$EAPI" REPLACE "${2}" "${3}" "${4:-${PV}}" )
;;
- replace_all_separators)
+ replace_all)
+ [[ "${#@}" != 2 ]] && [[ "${#@}" != 3 ]] && die "$0 $1 takes one or two extra arguments"
+ r=$(paludis_pipe_command EVER "$EAPI" REPLACE_ALL "${2}" "${3:-${PV}}" )
;;
- delete_separator)
+ delete)
+ [[ "${#@}" != 2 ]] && [[ "${#@}" != 3 ]] && die "$0 $1 takes one or two extra arguments"
+ [[ -z "${2}" ]] && die "$0 $1 takes a non-empty position as first argument"
+ r=$(paludis_pipe_command EVER "$EAPI" REPLACE "${2}" "" "${3:-${PV}}" )
;;
- delete_all_separators)
+ delete_all)
+ [[ "${#@}" != 1 ]] && [[ "${#@}" != 2 ]] && die "$0 $1 takes at most one extra argument"
+ r=$(paludis_pipe_command EVER "$EAPI" REPLACE_ALL "" "${2:-${PV}}" )
;;
at_least)
@@ -65,7 +77,7 @@ ever()
;;
*)
- die "ever subcommand ${1} unrecognised"
+ die "ever subcommand ${1} unrecognised"
;;
esac
diff --git a/paludis/repositories/e/pipe_command_handler.cc b/paludis/repositories/e/pipe_command_handler.cc
index d7356fc..5053ec0 100644
--- a/paludis/repositories/e/pipe_command_handler.cc
+++ b/paludis/repositories/e/pipe_command_handler.cc
@@ -2,6 +2,7 @@
/*
* Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2009 Ingmar Vanhassel
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -469,6 +470,86 @@ paludis::erepository::pipe_command_handler(const Environment * const environment
return "O0;" + result;
}
+ else if (tokens[2] == "REPLACE")
+ {
+ if (tokens.size() != 6)
+ {
+ Log::get_instance()->message("e.pipe_commands.ever.replace.bad", ll_warning, lc_context) << "Got bad EVER " + tokens[2] + " pipe command";
+ return "Ebad EVER " + tokens[2] + " command {'" + join(tokens.begin(), tokens.end(), "', '") + "'}";
+ }
+
+ VersionSpec v(tokens[5]);
+ int current_pos(0);
+ int replace_pos(destringify<int>(tokens[3]));
+ std::string replacement(tokens[4]);
+ std::string result;
+
+ for (VersionSpec::ConstIterator c(v.begin()), c_end(v.end()) ;
+ c != c_end ; ++c)
+ {
+ if (c->text().empty())
+ continue;
+
+ switch (c->text().at(0))
+ {
+ case '.':
+ case '-':
+ case '_':
+ {
+ if (current_pos == replace_pos)
+ result.append(replacement + c->text().substr(1));
+ else
+ result.append(c->text());
+ }
+ break;
+
+ default:
+ result.append(c->text());
+ break;
+ }
+
+ ++current_pos;
+ }
+
+ return "O0;" + result;
+ }
+ else if (tokens[2] == "REPLACE_ALL")
+ {
+ if (tokens.size() != 5)
+ {
+ Log::get_instance()->message("e.pipe_commands.ever.replace_all.bad", ll_warning, lc_context) << "Got bad EVER " + tokens[2] + " pipe command";
+ return "Ebad EVER " + tokens[2] + " command {'" + join(tokens.begin(), tokens.end(), "', '") + "'}";
+ }
+
+ VersionSpec v(tokens[4]);
+ std::string replacement(tokens[3]);
+ std::string result;
+ for (VersionSpec::ConstIterator c(v.begin()), c_end(v.end()) ;
+ c != c_end ; ++c)
+ {
+ if (c->text().empty())
+ continue;
+
+ switch (c->text().at(0))
+ {
+ case '.':
+ case '-':
+ case '_':
+ {
+ result.append(replacement);
+ if (c->text().length() > 1)
+ result.append(c->text().substr(1));
+ }
+ break;
+
+ default:
+ result.append(c->text());
+ break;
+ }
+ }
+
+ return "O0;" + result;
+ }
else
{
Log::get_instance()->message("e.pipe_commands.ever.unknown", ll_warning, lc_context) << "Got unknown EVER pipe subcommand";