aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-01-11 18:53:19 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-01-11 18:53:19 +0000
commit5e6f6e90079ab26d811d81e507f9211fb875a500 (patch)
tree3f51a04cd484116c2d3662db0e93185e7e9c3411
parent3b611ef07501abcff3ee2d8948dfe737cdfa5fd4 (diff)
downloadpaludis-5e6f6e90079ab26d811d81e507f9211fb875a500.tar.gz
paludis-5e6f6e90079ab26d811d81e507f9211fb875a500.tar.xz
Resurrect files_dir_size check.
-rw-r--r--paludis/repositories/e/qa/Makefile.am2
-rw-r--r--paludis/repositories/e/qa/files_dir_size.cc81
-rw-r--r--paludis/repositories/e/qa/files_dir_size.hh37
-rw-r--r--paludis/repositories/e/qa/qa_checks.cc4
4 files changed, 124 insertions, 0 deletions
diff --git a/paludis/repositories/e/qa/Makefile.am b/paludis/repositories/e/qa/Makefile.am
index d5e250a..52c993e 100644
--- a/paludis/repositories/e/qa/Makefile.am
+++ b/paludis/repositories/e/qa/Makefile.am
@@ -42,6 +42,7 @@ paludis_repositories_e_include_HEADERS = \
visibility.hh \
whitespace.hh \
header.hh \
+ files_dir_size.hh \
repo_name.hh
lib_LTLIBRARIES = libpaludiserepositoryqa.la
@@ -63,6 +64,7 @@ libpaludiserepositoryqa_la_SOURCES = \
visibility.cc \
whitespace.cc \
header.cc \
+ files_dir_size.cc \
repo_name.cc \
$(paludis_repositories_e_include_HEADERS)
diff --git a/paludis/repositories/e/qa/files_dir_size.cc b/paludis/repositories/e/qa/files_dir_size.cc
new file mode 100644
index 0000000..d5b44ff
--- /dev/null
+++ b/paludis/repositories/e/qa/files_dir_size.cc
@@ -0,0 +1,81 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/repositories/e/qa/files_dir_size.hh>
+#include <paludis/qa.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/dir_iterator.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/is_file_with_extension.hh>
+#include <paludis/util/log.hh>
+
+using namespace paludis;
+using namespace paludis::erepository;
+
+bool
+paludis::erepository::files_dir_size_check(
+ QAReporter & reporter,
+ const FSEntry & dir,
+ const std::string & name
+ )
+{
+ Context context("When performing check '" + name + "' using files_dir_size_check on directory '" + stringify(dir) + "':");
+ Log::get_instance()->message(ll_debug, lc_context) << "files_dir_size_check '"
+ << dir << "', " << name << "'";
+
+ struct SizeFinder
+ {
+ off_t total_size;
+
+ SizeFinder() :
+ total_size(0)
+ {
+ }
+
+ void operator() (const FSEntry & f)
+ {
+ if (f.basename() == "CVS" || '.' == f.basename().at(0))
+ return;
+
+ if (f.is_directory())
+ {
+ for (DirIterator ff(f), ff_end ; ff != ff_end ; ++ff)
+ operator() (*ff);
+ }
+ else if (f.is_regular_file())
+ {
+ if (0 != f.basename().compare(0, 7, "digest-"))
+ total_size += f.file_size();
+ }
+ }
+ };
+
+ SizeFinder f;
+ f(dir / "files");
+
+ if (f.total_size > (100 * 1024))
+ reporter.message(QAMessage(dir / "files", qaml_minor, name, "files/ is way too bloated (" +
+ stringify(f.total_size / 1024) + "KBytes, excluding digests and CVS)"));
+ else if (f.total_size > (20 * 1024))
+ reporter.message(QAMessage(dir / "files", qaml_minor, name, "files/ is oversized (" +
+ stringify(f.total_size / 1024) + "KBytes, excluding digests and CVS)"));
+
+ return true;
+}
+
diff --git a/paludis/repositories/e/qa/files_dir_size.hh b/paludis/repositories/e/qa/files_dir_size.hh
new file mode 100644
index 0000000..eff40b5
--- /dev/null
+++ b/paludis/repositories/e/qa/files_dir_size.hh
@@ -0,0 +1,37 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_QA_FILES_DIR_SIZE_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_QA_FILES_DIR_SIZE_HH 1
+
+#include <paludis/repositories/e/qa/qa_controller.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ bool files_dir_size_check(
+ QAReporter &,
+ const FSEntry & dir,
+ const std::string & s
+ );
+ }
+}
+
+#endif
diff --git a/paludis/repositories/e/qa/qa_checks.cc b/paludis/repositories/e/qa/qa_checks.cc
index 0457dba..fc24793 100644
--- a/paludis/repositories/e/qa/qa_checks.cc
+++ b/paludis/repositories/e/qa/qa_checks.cc
@@ -22,6 +22,7 @@
#include <paludis/util/instantiation_policy-impl.hh>
#include <paludis/repositories/e/qa/stray_files.hh>
+#include <paludis/repositories/e/qa/files_dir_size.hh>
#include <paludis/repositories/e/qa/eapi_supported.hh>
#include <paludis/repositories/e/qa/metadata_keys.hh>
#include <paludis/repositories/e/qa/short_description_key.hh>
@@ -76,6 +77,9 @@ QAChecks::QAChecks() :
_imp->category_dir_checks_group->add_check("stray_category_dir_files",
tr1::bind(stray_files_check, _2, _4, _1, is_stray_at_category_dir, "stray_category_dir_files"));
+ _imp->package_dir_checks_group->add_check("files_dir_size",
+ tr1::bind(files_dir_size_check, _2, _1, "files_dir_size"));
+
_imp->package_id_checks_group->add_check("eapi_supported",
tr1::bind(eapi_supported_check, _1, _2, _5, "eapi_supported"));