aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2015-11-01 16:20:36 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2015-11-05 17:37:27 +0000
commit223c7cd2b1c03f5916b00c3ba583b47112a148ff (patch)
tree7c82d74a05726362d09548a060c7fca0c234b3a5
parentd71ab4e7c5a35755fb3ec108a116f89965a5df2c (diff)
downloadpaludis-223c7cd2b1c03f5916b00c3ba583b47112a148ff.tar.gz
paludis-223c7cd2b1c03f5916b00c3ba583b47112a148ff.tar.xz
EAPI 6 supports die/assert -n
-rw-r--r--paludis/repositories/e/e_repository_TEST_5.cc18
-rwxr-xr-xpaludis/repositories/e/e_repository_TEST_5_setup.sh41
-rw-r--r--paludis/repositories/e/e_repository_TEST_6.cc72
-rwxr-xr-xpaludis/repositories/e/e_repository_TEST_6_setup.sh164
-rw-r--r--paludis/repositories/e/eapi.cc1
-rw-r--r--paludis/repositories/e/eapi.hh2
-rw-r--r--paludis/repositories/e/eapis/0.conf1
-rw-r--r--paludis/repositories/e/eapis/6.conf2
-rw-r--r--paludis/repositories/e/eapis/exheres-0.conf1
-rw-r--r--paludis/repositories/e/eapis/paludis-1.conf1
-rw-r--r--paludis/repositories/e/ebuild.cc2
-rw-r--r--paludis/repositories/e/ebuild/die_functions.bash23
12 files changed, 324 insertions, 4 deletions
diff --git a/paludis/repositories/e/e_repository_TEST_5.cc b/paludis/repositories/e/e_repository_TEST_5.cc
index 7f12e39..ebef77a 100644
--- a/paludis/repositories/e/e_repository_TEST_5.cc
+++ b/paludis/repositories/e/e_repository_TEST_5.cc
@@ -276,6 +276,24 @@ TEST(ERepository, InstallEAPI5)
EXPECT_EQ("5", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
id->perform_action(action);
}
+
+ {
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/nonfatal-die-5",
+ &env, { })), nullptr, { }))]->last());
+ ASSERT_TRUE(bool(id));
+ EXPECT_EQ("5", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
+ EXPECT_THROW(id->perform_action(action), ActionFailedError);
+ }
+
+ {
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/nonfatal-assert-5",
+ &env, { })), nullptr, { }))]->last());
+ ASSERT_TRUE(bool(id));
+ EXPECT_EQ("5", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
+ EXPECT_THROW(id->perform_action(action), ActionFailedError);
+ }
}
TEST(ERepository, RequiredUse)
diff --git a/paludis/repositories/e/e_repository_TEST_5_setup.sh b/paludis/repositories/e/e_repository_TEST_5_setup.sh
index c176636..8e7c0b0 100755
--- a/paludis/repositories/e/e_repository_TEST_5_setup.sh
+++ b/paludis/repositories/e/e_repository_TEST_5_setup.sh
@@ -518,6 +518,47 @@ src_unpack() {
}
END
+mkdir -p "cat/nonfatal-die" || exit 1
+cat << 'END' > cat/nonfatal-die/nonfatal-die-5.ebuild || exit 1
+EAPI="5"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+pkg_setup() {
+ nonfatal test
+}
+
+test() {
+ die -n test
+}
+END
+
+mkdir -p "cat/nonfatal-assert" || exit 1
+cat << 'END' > cat/nonfatal-assert/nonfatal-assert-5.ebuild || exit 1
+EAPI="5"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+pkg_setup() {
+ nonfatal test
+}
+
+test() {
+ true | false | true
+ assert -n test
+}
+END
+
mkdir -p "cat/subslots" || exit 1
cat << 'END' > cat/subslots/subslots-5.ebuild || exit 1
EAPI="5"
diff --git a/paludis/repositories/e/e_repository_TEST_6.cc b/paludis/repositories/e/e_repository_TEST_6.cc
index f990d21..79dbde3 100644
--- a/paludis/repositories/e/e_repository_TEST_6.cc
+++ b/paludis/repositories/e/e_repository_TEST_6.cc
@@ -230,5 +230,77 @@ TEST(ERepository, InstallEAPI6)
EXPECT_EQ("6", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
id->perform_action(action);
}
+
+ {
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/plain-die-6",
+ &env, { })), nullptr, { }))]->last());
+ ASSERT_TRUE(bool(id));
+ EXPECT_EQ("6", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
+ EXPECT_THROW(id->perform_action(action), ActionFailedError);
+ }
+
+ {
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/plain-assert-6",
+ &env, { })), nullptr, { }))]->last());
+ ASSERT_TRUE(bool(id));
+ EXPECT_EQ("6", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
+ EXPECT_THROW(id->perform_action(action), ActionFailedError);
+ }
+
+ {
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/nonfatal-die-6",
+ &env, { })), nullptr, { }))]->last());
+ ASSERT_TRUE(bool(id));
+ EXPECT_EQ("6", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
+ EXPECT_THROW(id->perform_action(action), ActionFailedError);
+ }
+
+ {
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/nonfatal-assert-6",
+ &env, { })), nullptr, { }))]->last());
+ ASSERT_TRUE(bool(id));
+ EXPECT_EQ("6", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
+ EXPECT_THROW(id->perform_action(action), ActionFailedError);
+ }
+
+ {
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/die-n-6",
+ &env, { })), nullptr, { }))]->last());
+ ASSERT_TRUE(bool(id));
+ EXPECT_EQ("6", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
+ EXPECT_THROW(id->perform_action(action), ActionFailedError);
+ }
+
+ {
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/assert-n-6",
+ &env, { })), nullptr, { }))]->last());
+ ASSERT_TRUE(bool(id));
+ EXPECT_EQ("6", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
+ EXPECT_THROW(id->perform_action(action), ActionFailedError);
+ }
+
+ {
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/nonfatal-die-n-6",
+ &env, { })), nullptr, { }))]->last());
+ ASSERT_TRUE(bool(id));
+ EXPECT_EQ("6", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
+ id->perform_action(action);
+ }
+
+ {
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/nonfatal-assert-n-6",
+ &env, { })), nullptr, { }))]->last());
+ ASSERT_TRUE(bool(id));
+ EXPECT_EQ("6", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
+ id->perform_action(action);
+ }
}
diff --git a/paludis/repositories/e/e_repository_TEST_6_setup.sh b/paludis/repositories/e/e_repository_TEST_6_setup.sh
index 391a2f3..1976b80 100755
--- a/paludis/repositories/e/e_repository_TEST_6_setup.sh
+++ b/paludis/repositories/e/e_repository_TEST_6_setup.sh
@@ -327,5 +327,169 @@ EOF
}
END
+mkdir -p "cat/plain-die" || exit 1
+cat << 'END' > cat/plain-die/plain-die-6.ebuild || exit 1
+EAPI="6"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+pkg_setup() {
+ test
+}
+
+test() {
+ die test
+}
+END
+
+mkdir -p "cat/plain-assert" || exit 1
+cat << 'END' > cat/plain-assert/plain-assert-6.ebuild || exit 1
+EAPI="6"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+pkg_setup() {
+ test
+}
+
+test() {
+ true | false | true
+ assert test
+}
+END
+
+mkdir -p "cat/nonfatal-die" || exit 1
+cat << 'END' > cat/nonfatal-die/nonfatal-die-6.ebuild || exit 1
+EAPI="6"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+pkg_setup() {
+ nonfatal test
+}
+
+test() {
+ die test
+}
+END
+
+mkdir -p "cat/nonfatal-assert" || exit 1
+cat << 'END' > cat/nonfatal-assert/nonfatal-assert-6.ebuild || exit 1
+EAPI="6"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+pkg_setup() {
+ nonfatal test
+}
+
+test() {
+ true | false | true
+ assert test
+}
+END
+
+mkdir -p "cat/die-n" || exit 1
+cat << 'END' > cat/die-n/die-n-6.ebuild || exit 1
+EAPI="6"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+pkg_setup() {
+ test
+}
+
+test() {
+ die -n test
+}
+END
+
+mkdir -p "cat/assert-n" || exit 1
+cat << 'END' > cat/assert-n/assert-n-6.ebuild || exit 1
+EAPI="6"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+pkg_setup() {
+ test
+}
+
+test() {
+ true | false | true
+ assert -n test
+}
+END
+
+mkdir -p "cat/nonfatal-die-n" || exit 1
+cat << 'END' > cat/nonfatal-die-n/nonfatal-die-n-6.ebuild || exit 1
+EAPI="6"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+pkg_setup() {
+ nonfatal test && die
+}
+
+test() {
+ die -n test
+}
+END
+
+mkdir -p "cat/nonfatal-assert-n" || exit 1
+cat << 'END' > cat/nonfatal-assert-n/nonfatal-assert-n-6.ebuild || exit 1
+EAPI="6"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+pkg_setup() {
+ nonfatal test && die
+}
+
+test() {
+ true | false | true
+ assert -n test
+}
+END
+
cd ..
cd ..
diff --git a/paludis/repositories/e/eapi.cc b/paludis/repositories/e/eapi.cc
index ef14b30..05b2c02 100644
--- a/paludis/repositories/e/eapi.cc
+++ b/paludis/repositories/e/eapi.cc
@@ -245,6 +245,7 @@ namespace
{
return std::make_shared<EAPIToolsOptions>(make_named_values<EAPIToolsOptions>(
n::best_has_version_host_root() = destringify_key<bool>(k, "best_has_version_host_root"),
+ n::die_supports_dash_n() = destringify_key<bool>(k, "die_supports_dash_n"),
n::dodoc_r() = destringify_key<bool>(k, "dodoc_r"),
n::doins_symlink() = destringify_key<bool>(k, "doins_symlink"),
n::doman_lang_filenames() = destringify_key<bool>(k, "doman_lang_filenames"),
diff --git a/paludis/repositories/e/eapi.hh b/paludis/repositories/e/eapi.hh
index 6b06390..c21902f 100644
--- a/paludis/repositories/e/eapi.hh
+++ b/paludis/repositories/e/eapi.hh
@@ -61,6 +61,7 @@ namespace paludis
typedef Name<struct name_description> description;
typedef Name<struct name_description_choices> description_choices;
typedef Name<struct name_description_use> description_use;
+ typedef Name<struct name_die_supports_dash_n> die_supports_dash_n;
typedef Name<struct name_directory_if_exists_variables> directory_if_exists_variables;
typedef Name<struct name_directory_variables> directory_variables;
typedef Name<struct name_dodoc_r> dodoc_r;
@@ -483,6 +484,7 @@ namespace paludis
struct EAPIToolsOptions
{
NamedValue<n::best_has_version_host_root, bool> best_has_version_host_root;
+ NamedValue<n::die_supports_dash_n, bool> die_supports_dash_n;
NamedValue<n::dodoc_r, bool> dodoc_r;
NamedValue<n::doins_symlink, bool> doins_symlink;
NamedValue<n::doman_lang_filenames, bool> doman_lang_filenames;
diff --git a/paludis/repositories/e/eapis/0.conf b/paludis/repositories/e/eapis/0.conf
index c025d4f..60cb8e6 100644
--- a/paludis/repositories/e/eapis/0.conf
+++ b/paludis/repositories/e/eapis/0.conf
@@ -280,6 +280,7 @@ dodoc_r = false
doins_symlink = false
dosym_mkdir = true
failure_is_fatal = false
+die_supports_dash_n = false
no_s_workdir_fallback = false
use_with_enable_empty_third_argument = false
best_has_version_host_root = false
diff --git a/paludis/repositories/e/eapis/6.conf b/paludis/repositories/e/eapis/6.conf
index c8b0bb4..a9b1555 100644
--- a/paludis/repositories/e/eapis/6.conf
+++ b/paludis/repositories/e/eapis/6.conf
@@ -11,6 +11,8 @@ utility_path_suffixes = 6 5 4 3 2 1 0
shell_options_global = failglob
+die_supports_dash_n = true
+
econf_extra_options_help_dependent = ${econf_extra_options_help_dependent} --docdir::--docdir=/usr/share/doc/\${PF} --htmldir::--htmldir=/usr/share/doc/\${PF}/html
unpack_any_path = true
diff --git a/paludis/repositories/e/eapis/exheres-0.conf b/paludis/repositories/e/eapis/exheres-0.conf
index 2aa8c93..5b49ab3 100644
--- a/paludis/repositories/e/eapis/exheres-0.conf
+++ b/paludis/repositories/e/eapis/exheres-0.conf
@@ -357,6 +357,7 @@ dodoc_r = true
dosym_mkdir = false
doins_symlink = true
failure_is_fatal = true
+die_supports_dash_n = false
no_s_workdir_fallback = true
use_with_enable_empty_third_argument = true
fix_mtimes = true
diff --git a/paludis/repositories/e/eapis/paludis-1.conf b/paludis/repositories/e/eapis/paludis-1.conf
index 4ebe6a9..08f88c0 100644
--- a/paludis/repositories/e/eapis/paludis-1.conf
+++ b/paludis/repositories/e/eapis/paludis-1.conf
@@ -280,6 +280,7 @@ dosym_mkdir = false
doins_symlink = false
use_with_enable_empty_third_argument = true
failure_is_fatal = false
+die_supports_dash_n = false
best_has_version_host_root = false
new_stdin = false
diff --git a/paludis/repositories/e/ebuild.cc b/paludis/repositories/e/ebuild.cc
index f732ff9..4d66343 100644
--- a/paludis/repositories/e/ebuild.cc
+++ b/paludis/repositories/e/ebuild.cc
@@ -267,6 +267,8 @@ EbuildCommand::operator() ()
params.package_id()->eapi()->supported()->tools_options()->use_with_enable_empty_third_argument() ? "yes" : "")
.setenv("PALUDIS_FAILURE_IS_FATAL",
params.package_id()->eapi()->supported()->tools_options()->failure_is_fatal() ? "yes" : "")
+ .setenv("PALUDIS_DIE_SUPPORTS_DASH_N",
+ params.package_id()->eapi()->supported()->tools_options()->die_supports_dash_n() ? "yes" : "")
.setenv("PALUDIS_UNPACK_FROM_VAR",
params.package_id()->eapi()->supported()->ebuild_environment_variables()->env_distdir())
.setenv("PALUDIS_IMAGE_DIR_VAR",
diff --git a/paludis/repositories/e/ebuild/die_functions.bash b/paludis/repositories/e/ebuild/die_functions.bash
index e9bbd6d..9d334ed 100644
--- a/paludis/repositories/e/ebuild/die_functions.bash
+++ b/paludis/repositories/e/ebuild/die_functions.bash
@@ -22,24 +22,39 @@
shopt -s expand_aliases
+_paludis_pipestatus=
alias die='diefunc "${FUNCNAME:-$0}" "$LINENO"'
-alias assert='_pipestatus="${PIPESTATUS[*]}"; [[ -z "${_pipestatus//[ 0]/}" ]] || diefunc "${FUNCNAME:-$0}" "$LINENO" "$_pipestatus"'
+alias assert='_paludis_pipestatus="${PIPESTATUS[*]}"; [[ -z "${_paludis_pipestatus//[ 0]/}" ]] || diefunc "${FUNCNAME:-$0}" "$LINENO"'
# paludis_die_or_error is only for use in scripts
alias paludis_die_or_error='paludis_die_or_error_func "$0" "$LINENO"'
# paludis_die_unless_nonfatal and paludis_assert_unless_nonfatal are only for use in shell functions
alias paludis_die_unless_nonfatal='paludis_die_unless_nonfatal_func "$FUNCNAME" "$LINENO"'
-alias paludis_assert_unless_nonfatal='_pipestatus="${PIPESTATUS[*]}"; [[ -z "${_pipestatus//[ 0]/}" ]] || paludis_die_unless_nonfatal_func "$FUNCNAME" "$LINENO" "$_pipestatus"'
+alias paludis_assert_unless_nonfatal='_paludis_pipestatus="${PIPESTATUS[*]}"; [[ -z "${_paludis_pipestatus//[ 0]/}" ]] || paludis_die_unless_nonfatal_func "$FUNCNAME" "$LINENO"'
trap 'echo "die trap: exiting with error." 1>&2 ; exit 250' SIGUSR1
diefunc()
{
- local func="$1" line="$2"
+ local func="$1" line="$2" nonfatal=
shift 2
+
+ if [[ -n ${PALUDIS_DIE_SUPPORTS_DASH_N} && $1 == -n && -n ${PALUDIS_FAILURE_IS_NONFATAL} ]] ; then
+ shift
+ nonfatal=yes
+ fi
+
+ local message="$*"
+ [[ -n ${_paludis_pipestatus//[ 0]/} ]] && message="${_paludis_pipestatus} ${message}"
+
+ if [[ -n ${nonfatal} ]] ; then
+ echo "${func}: ${message}" >&2
+ return 247
+ fi
+
echo 1>&2
echo "!!! ERROR in ${CATEGORY:-?}/${!PALUDIS_NAME_VERSION_REVISION_VAR:-?}::${REPOSITORY:-?}:" 1>&2
echo "!!! In ${func:-?} at line ${line:-?}" 1>&2
- echo "!!! ${*:-(no message provided)}" 1>&2
+ echo "!!! ${message:-(no message provided)}" 1>&2
echo 1>&2
echo "!!! Call stack:" 1>&2