aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2015-11-05 17:35:15 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2015-11-05 17:37:29 +0000
commit53f810cb0be8b63a682770a96ada8695f1beef69 (patch)
treeb3fa81c7fdaf27359c3bdddf4419341f38561f05
parente7180b72c432d32b4c7324dea4ae859084ac08ea (diff)
downloadpaludis-53f810cb0be8b63a682770a96ada8695f1beef69.tar.gz
paludis-53f810cb0be8b63a682770a96ada8695f1beef69.tar.xz
EAPI 6 has eapply
-rw-r--r--paludis/repositories/e/e_repository_TEST_5.cc9
-rwxr-xr-xpaludis/repositories/e/e_repository_TEST_5_setup.sh18
-rw-r--r--paludis/repositories/e/e_repository_TEST_6.cc99
-rwxr-xr-xpaludis/repositories/e/e_repository_TEST_6_setup.sh424
-rw-r--r--paludis/repositories/e/ebuild/6/build_functions.bash54
5 files changed, 604 insertions, 0 deletions
diff --git a/paludis/repositories/e/e_repository_TEST_5.cc b/paludis/repositories/e/e_repository_TEST_5.cc
index 238bab2..b7d3d36 100644
--- a/paludis/repositories/e/e_repository_TEST_5.cc
+++ b/paludis/repositories/e/e_repository_TEST_5.cc
@@ -339,6 +339,15 @@ 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/no-eapply-5",
+ &env, { })), nullptr, { }))]->last());
+ ASSERT_TRUE(bool(id));
+ EXPECT_EQ("5", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->parse_value());
+ id->perform_action(action);
+ }
}
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 aa68a27..0f20ed2 100755
--- a/paludis/repositories/e/e_repository_TEST_5_setup.sh
+++ b/paludis/repositories/e/e_repository_TEST_5_setup.sh
@@ -668,6 +668,24 @@ pkg_preinst() {
}
END
+mkdir -p "cat/no-eapply" || exit 1
+cat << 'END' > cat/no-eapply/no-eapply-5.ebuild || exit 1
+EAPI="5"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+S=${WORKDIR}
+
+src_prepare() {
+ [[ -z $(declare -F eapply) ]] || die
+}
+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 23f23a0..15a9008 100644
--- a/paludis/repositories/e/e_repository_TEST_6.cc
+++ b/paludis/repositories/e/e_repository_TEST_6.cc
@@ -544,5 +544,104 @@ 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/eapply-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/eapply-options-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/eapply-dashdash-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/eapply-missing-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/eapply-failure-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/eapply-nonfatal-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/eapply-dir-failure-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/eapply-dir-nonfatal-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/eapply-badmix-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/eapply-nopatches-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/eapply-dir-nopatches-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);
+ }
}
diff --git a/paludis/repositories/e/e_repository_TEST_6_setup.sh b/paludis/repositories/e/e_repository_TEST_6_setup.sh
index 99ee7e0..52ae5f1 100755
--- a/paludis/repositories/e/e_repository_TEST_6_setup.sh
+++ b/paludis/repositories/e/e_repository_TEST_6_setup.sh
@@ -1319,5 +1319,429 @@ pkg_preinst() {
}
END
+mkdir -p "cat/eapply/files/subdir" || exit 1
+cat << 'END' > cat/eapply/eapply-6.ebuild || exit 1
+EAPI="6"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+S=${WORKDIR}
+
+src_unpack() {
+ echo first >file || die
+ echo donkey >file2 || die
+}
+
+src_prepare() {
+ [[ -n $(declare -F eapply) ]] || die not defined
+
+ eapply "${FILESDIR}"/first "${FILESDIR}"/subdir "${FILESDIR}"/"last with spaces" || die eapply
+ [[ $(< file) == seventh ]] || die file
+ [[ $(< file2) == donkey ]] || die file2
+}
+END
+cat << 'END' > cat/eapply/files/first || exit 1
+--- directory/file
++++ directory/file
+@@ -1 +1 @@
+-first
++second
+END
+cat << 'END' > cat/eapply/files/subdir/A.patch || exit 1
+--- directory/file
++++ directory/file
+@@ -1 +1 @@
+-second
++third
+END
+cat << 'END' > cat/eapply/files/subdir/B.diff || exit 1
+--- directory/file
++++ directory/file
+@@ -1 +1 @@
+-third
++fourth
+END
+cat << 'END' > cat/eapply/files/subdir/"C with spaces".patch || exit 1
+--- directory/file
++++ directory/file
+@@ -1 +1 @@
+-fourth
++fifth
+END
+cat << 'END' > cat/eapply/files/subdir/D.patch~ || exit 1
+--- directory/file2
++++ directory/file2
+@@ -1 +1 @@
+-donkey
++monkey
+END
+cat << 'END' > cat/eapply/files/subdir/E.txt || exit 1
+--- directory/file2
++++ directory/file2
+@@ -1 +1 @@
+-donkey
++turkey
+END
+cat << 'END' > cat/eapply/files/subdir/a.patch || exit 1
+--- directory/file
++++ directory/file
+@@ -1 +1 @@
+-fifth
++sixth
+END
+cat << 'END' > cat/eapply/files/"last with spaces" || exit 1
+--- directory/file
++++ directory/file
+@@ -1 +1 @@
+-sixth
++seventh
+END
+
+mkdir -p "cat/eapply-options/files/subdir" || exit 1
+cat << 'END' > cat/eapply-options/eapply-options-6.ebuild || exit 1
+EAPI="6"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+S=${WORKDIR}
+
+src_unpack() {
+ echo first >file || die
+}
+
+src_prepare() {
+ eapply -p0 "${FILESDIR}"/first.patch "${FILESDIR}"/second.patch "${FILESDIR}"/subdir/third.patch || die eapply
+ [[ $(< file) == fourth ]] || die file
+}
+END
+cat << 'END' > cat/eapply-options/files/first.patch || exit 1
+--- file
++++ file
+@@ -1 +1 @@
+-first
++second
+END
+cat << 'END' > cat/eapply-options/files/second.patch || exit 1
+--- file
++++ file
+@@ -1 +1 @@
+-second
++third
+END
+cat << 'END' > cat/eapply-options/files/subdir/third.patch || exit 1
+--- file
++++ file
+@@ -1 +1 @@
+-third
++fourth
+END
+
+mkdir -p "cat/eapply-dashdash/files" || exit 1
+cat << 'END' > cat/eapply-dashdash/eapply-dashdash-6.ebuild || exit 1
+EAPI="6"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+S=${WORKDIR}
+
+src_unpack() {
+ echo first >file || die
+ cp "${FILESDIR}"/-p2 . || die
+}
+
+src_prepare() {
+ eapply -p0 -- -p2 || die eapply
+ [[ $(< file) == second ]] || die file
+}
+END
+cat << 'END' > cat/eapply-dashdash/files/-p2 || exit 1
+--- file
++++ file
+@@ -1 +1 @@
+-first
++second
+END
+
+mkdir -p "cat/eapply-missing/files" || exit 1
+cat << 'END' > cat/eapply-missing/eapply-missing-6.ebuild || exit 1
+EAPI="6"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+S=${WORKDIR}
+
+src_unpack() {
+ echo first >file || die
+}
+
+src_prepare() {
+ eapply "${FILESDIR}"/first.patch
+}
+END
+cat << 'END' > cat/eapply-missing/files/second.patch || exit 1
+--- directory/file
++++ directory/file
+@@ -1 +1 @@
+-second
++third
+END
+
+mkdir -p "cat/eapply-failure/files" || exit 1
+cat << 'END' > cat/eapply-failure/eapply-failure-6.ebuild || exit 1
+EAPI="6"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+S=${WORKDIR}
+
+src_unpack() {
+ echo first >file || die
+}
+
+src_prepare() {
+ eapply "${FILESDIR}"/fail.patch
+}
+END
+cat << 'END' > cat/eapply-failure/files/fail.patch || exit 1
+--- directory/file
++++ directory/file
+@@ -1 +1 @@
+-fourth
++fifth
+END
+
+mkdir -p "cat/eapply-nonfatal/files" || exit 1
+cat << 'END' > cat/eapply-nonfatal/eapply-nonfatal-6.ebuild || exit 1
+EAPI="6"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+S=${WORKDIR}
+
+src_unpack() {
+ echo first >file || die
+ echo donkey >file2 || die
+}
+
+src_prepare() {
+ nonfatal eapply "${FILESDIR}"/first.patch "${FILESDIR}"/fail.patch "${FILESDIR}"/last.patch && die eapply
+ [[ $(< file) == second ]] || die file
+ [[ $(< file2) == donkey ]] || die file2
+}
+END
+cat << 'END' > cat/eapply-nonfatal/files/first.patch || exit 1
+--- directory/file
++++ directory/file
+@@ -1 +1 @@
+-first
++second
+END
+cat << 'END' > cat/eapply-nonfatal/files/fail.patch || exit 1
+--- directory/file
++++ directory/file
+@@ -1 +1 @@
+-fourth
++fifth
+END
+cat << 'END' > cat/eapply-nonfatal/files/last.patch || exit 1
+--- directory/file2
++++ directory/file2
+@@ -1 +1 @@
+-donkey
++monkey
+END
+
+mkdir -p "cat/eapply-dir-failure/files/subdir" || exit 1
+cat << 'END' > cat/eapply-dir-failure/eapply-dir-failure-6.ebuild || exit 1
+EAPI="6"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+S=${WORKDIR}
+
+src_unpack() {
+ echo first >file || die
+}
+
+src_prepare() {
+ eapply "${FILESDIR}"/subdir
+}
+END
+cat << 'END' > cat/eapply-dir-failure/files/subdir/fail.patch || exit 1
+--- file
++++ file
+@@ -1 +1 @@
+-first
++second
+END
+
+mkdir -p "cat/eapply-dir-nonfatal/files/subdir" || exit 1
+cat << 'END' > cat/eapply-dir-nonfatal/eapply-dir-nonfatal-6.ebuild || exit 1
+EAPI="6"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+S=${WORKDIR}
+
+src_unpack() {
+ echo first >file || die
+ echo donkey >file2 || die
+}
+
+src_prepare() {
+ nonfatal eapply "${FILESDIR}"/subdir && die eapply
+ [[ $(< file) == second ]] || die file
+ [[ $(< file2) == donkey ]] || die file2
+}
+END
+cat << 'END' > cat/eapply-dir-nonfatal/files/subdir/A.patch || exit 1
+--- directory/file
++++ directory/file
+@@ -1 +1 @@
+-first
++second
+END
+cat << 'END' > cat/eapply-dir-nonfatal/files/subdir/B.patch || exit 1
+--- file
++++ file
+@@ -1 +1 @@
+-second
++third
+END
+cat << 'END' > cat/eapply-dir-nonfatal/files/subdir/C.patch || exit 1
+--- directory/file2
++++ directory/file2
+@@ -1 +1 @@
+-donkey
++monkey
+END
+
+mkdir -p "cat/eapply-badmix/files/subdir" || exit 1
+cat << 'END' > cat/eapply-badmix/eapply-badmix-6.ebuild || exit 1
+EAPI="6"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+S=${WORKDIR}
+
+src_unpack() {
+ echo first >file || die
+}
+
+src_prepare() {
+ nonfatal eapply "${FILESDIR}"/first.patch -p0 "${FILESDIR}"/second.patch
+}
+END
+cat << 'END' > cat/eapply-badmix/files/first.patch || exit 1
+--- directory/file
++++ directory/file
+@@ -1 +1 @@
+-first
++second
+END
+cat << 'END' > cat/eapply-badmix/files/second.patch || exit 1
+--- file
++++ file
+@@ -1 +1 @@
+-second
++third
+END
+
+mkdir -p "cat/eapply-nopatches" || exit 1
+cat << 'END' > cat/eapply-nopatches/eapply-nopatches-6.ebuild || exit 1
+EAPI="6"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+S=${WORKDIR}
+
+src_unpack() {
+ echo first >file || die
+}
+
+src_prepare() {
+ nonfatal eapply -p0
+}
+END
+
+mkdir -p "cat/eapply-dir-nopatches/files/subdir" || exit 1
+cat << 'END' > cat/eapply-dir-nopatches/eapply-dir-nopatches-6.ebuild || exit 1
+EAPI="6"
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+S=${WORKDIR}
+
+src_unpack() {
+ echo first >file || die
+}
+
+src_prepare() {
+ nonfatal eapply "${FILESDIR}"/subdir
+}
+END
+cat << 'END' > cat/eapply-dir-nopatches/files/subdir/first.patch~ || exit 1
+--- directory/file
++++ directory/file
+@@ -1 +1 @@
+-first
++second
+END
+
cd ..
cd ..
diff --git a/paludis/repositories/e/ebuild/6/build_functions.bash b/paludis/repositories/e/ebuild/6/build_functions.bash
index ede8189..8420a36 100644
--- a/paludis/repositories/e/ebuild/6/build_functions.bash
+++ b/paludis/repositories/e/ebuild/6/build_functions.bash
@@ -19,6 +19,60 @@
ebuild_load_module --older build_functions
+eapply()
+{
+ local -a options files
+ local p dashdash= badmix=
+ for p in "${@}" ; do
+ if [[ -n ${dashdash} ]] ; then
+ files+=( "${p}" )
+ elif [[ ${p} == -- ]] ; then
+ options+=( "${files[@]}" )
+ files=( )
+ dashdash=yes
+ elif [[ ${p} == -* && ${#files[@]} -eq 0 ]] ; then
+ options+=( "${p}" )
+ else
+ [[ ${p} == -* ]] && badmix=yes
+ files+=( "${p}" )
+ fi
+ done
+
+ [[ -z ${dashdash} && -n ${badmix} ]] && die "options must be specified before patches"
+ [[ ${#files[@]} -eq 0 ]] && die "no patches specified"
+
+ local x st
+ for x in "${files[@]}" ; do
+ if [[ -d ${x} ]] ; then
+ local f any=
+
+ for f in "${x}"/*.@(diff|patch) ; do
+ [[ -e ${f} ]] || continue
+ any=yes
+ patch -p1 -f -g0 --no-backup-if-mismatch "${options[@]}" < "${f}"
+ st=${?}
+ if [[ ${st} -ne 0 ]] ; then
+ paludis_die_unless_nonfatal "applying patch ${f} failed"
+ return ${st}
+ fi
+ done
+
+ [[ -z ${any} ]] && die "no patches found in directory ${x}"
+
+ else
+ patch -p1 -f -g0 --no-backup-if-mismatch "${options[@]}" < "${x}"
+ st=${?}
+ if [[ ${st} -ne 0 ]] ; then
+ paludis_die_unless_nonfatal "applying patch ${x} failed"
+ return ${st}
+ fi
+ fi
+ done
+
+ return 0
+}
+ebuild_need_extglob eapply
+
einstall()
{
die "einstall is banned in EAPI 6"