aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Piotr Jaroszyński <peper@gentoo.org> 2007-04-30 13:36:03 +0000
committerAvatar Piotr Jaroszyński <peper@gentoo.org> 2007-04-30 13:36:03 +0000
commitc6eba9b5c810263fb683348bd622433082233b88 (patch)
tree9a025bba59b756d6ddb91a0bfeeeb075cec28e70
parent6b4260d8e76b93572523ac707e2ed9b0d842c0ef (diff)
downloadpaludis-c6eba9b5c810263fb683348bd622433082233b88.tar.gz
paludis-c6eba9b5c810263fb683348bd622433082233b88.tar.xz
Improve ebuild name checking.
-rw-r--r--paludis/qa/ebuild_name_check.cc17
-rw-r--r--paludis/qa/ebuild_name_check_TEST.cc14
-rwxr-xr-xpaludis/qa/ebuild_name_check_TEST_setup.sh4
-rw-r--r--src/clients/qualudis/qualudis.cc8
4 files changed, 30 insertions, 13 deletions
diff --git a/paludis/qa/ebuild_name_check.cc b/paludis/qa/ebuild_name_check.cc
index e67d926..eca9832 100644
--- a/paludis/qa/ebuild_name_check.cc
+++ b/paludis/qa/ebuild_name_check.cc
@@ -17,8 +17,9 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/name.hh>
+#include <paludis/dep_spec.hh>
#include <paludis/util/is_file_with_extension.hh>
+#include <paludis/util/strip.hh>
#include <paludis/qa/ebuild_name_check.hh>
using namespace paludis;
@@ -35,9 +36,17 @@ EbuildNameCheck::operator() (const FSEntry & f) const
if (is_file_with_extension(f, ".ebuild", IsFileWithOptions()))
{
- if (stringify(f.dirname().basename()) != stringify(f.basename()).substr(
- 0, stringify(f.dirname().basename()).length()))
- result << Message(qal_fatal, "Ebuild name does not match directory name");
+ try
+ {
+ if (stringify(f.dirname().basename()) != stringify(
+ PackageDepSpec("=cat/" + strip_trailing_string(stringify(f.basename()), ".ebuild"),
+ pds_pm_permissive).package_ptr()->package))
+ result << Message(qal_fatal, "Ebuild name does not match directory name");
+ }
+ catch (const PackageDepSpecError)
+ {
+ result << Message(qal_fatal, "Ebuild version is invalid");
+ }
}
return result;
diff --git a/paludis/qa/ebuild_name_check_TEST.cc b/paludis/qa/ebuild_name_check_TEST.cc
index 689fe45..b121b68 100644
--- a/paludis/qa/ebuild_name_check_TEST.cc
+++ b/paludis/qa/ebuild_name_check_TEST.cc
@@ -74,9 +74,23 @@ namespace test_cases
FSEntry f2(e / "valid-cat" / "valid-pkg" / "invalid-pkg-0.ebuild");
TEST_CHECK(f2.exists());
+ FSEntry f3(e / "valid-cat" / "valid-pkg" / "valid-pkg-not-0.ebuild");
+ TEST_CHECK(f3.exists());
+
+ FSEntry f4(e / "valid-cat" / "valid-pkg" / "valid-pkg.ebuild");
+ TEST_CHECK(f4.exists());
+
CheckResult r1((*(*FileCheckMaker::get_instance()->find_maker(
EbuildNameCheck::identifier()))())(f2));
TEST_CHECK(! r1.empty());
+
+ CheckResult r2((*(*FileCheckMaker::get_instance()->find_maker(
+ EbuildNameCheck::identifier()))())(f3));
+ TEST_CHECK(! r2.empty());
+
+ CheckResult r3((*(*FileCheckMaker::get_instance()->find_maker(
+ EbuildNameCheck::identifier()))())(f4));
+ TEST_CHECK(! r3.empty());
}
} test_ebuild_name_check_invalid;
diff --git a/paludis/qa/ebuild_name_check_TEST_setup.sh b/paludis/qa/ebuild_name_check_TEST_setup.sh
index 259b2f3..a5db67d 100755
--- a/paludis/qa/ebuild_name_check_TEST_setup.sh
+++ b/paludis/qa/ebuild_name_check_TEST_setup.sh
@@ -8,5 +8,7 @@ mkdir "valid-cat" || exit 4
mkdir "valid-cat/valid-pkg" || exit 5
touch "valid-cat/valid-pkg/valid-pkg-0.ebuild" || exit 6
touch "valid-cat/valid-pkg/invalid-pkg-0.ebuild" || exit 7
-touch "valid-cat/valid-pkg/ChangeLog" || exit 8
+touch "valid-cat/valid-pkg/valid-pkg-not-0.ebuild" || exit 8
+touch "valid-cat/valid-pkg/valid-pkg.ebuild" || exit 9
+touch "valid-cat/valid-pkg/ChangeLog" || exit 10
diff --git a/src/clients/qualudis/qualudis.cc b/src/clients/qualudis/qualudis.cc
index 5774952..b280e8e 100644
--- a/src/clients/qualudis/qualudis.cc
+++ b/src/clients/qualudis/qualudis.cc
@@ -307,10 +307,6 @@ namespace
if (! is_file_with_extension(*f, ".ebuild", IsFileWithOptions()))
continue;
- // Don't check ebuilds with the wrong name.
- if (stringify(dir.basename()) != stringify(f->basename()).substr(0,stringify(dir.basename()).length()))
- continue;
-
qa::EbuildCheckData d(
QualifiedPackageName(CategoryNamePart(stringify(dir.dirname().basename())),
PackageNamePart(stringify(dir.basename()))),
@@ -332,10 +328,6 @@ namespace
if (! is_file_with_extension(*f, ".ebuild", IsFileWithOptions()))
continue;
- // Don't check ebuilds with the wrong name.
- if (stringify(dir.basename()) != stringify(f->basename()).substr(0,stringify(dir.basename()).length()))
- continue;
-
for (RepositoryPortageInterface::ProfilesIterator
i(env.main_repository()->portage_interface->begin_profiles()),
i_end(env.main_repository()->portage_interface->end_profiles()) ; i != i_end ; ++i)