aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-16 13:23:11 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-16 13:23:11 +0000
commitbd7d77e58c333cca237693041824f301c9128700 (patch)
tree3162d45b501ebbde1ac060ab2fa0c8ae21f4a468
parent80111275ca47dd8153705764416954e1f9dfd829 (diff)
downloadpaludis-bd7d77e58c333cca237693041824f301c9128700.tar.gz
paludis-bd7d77e58c333cca237693041824f301c9128700.tar.xz
files/ size QA checks
-rw-r--r--paludis/qa/files.m41
-rw-r--r--paludis/qa/files_dir_size_check.cc83
-rw-r--r--paludis/qa/files_dir_size_check.hh51
3 files changed, 135 insertions, 0 deletions
diff --git a/paludis/qa/files.m4 b/paludis/qa/files.m4
index 16ea902..12d509c 100644
--- a/paludis/qa/files.m4
+++ b/paludis/qa/files.m4
@@ -22,6 +22,7 @@ add(`environment', `hh', `cc')
add(`file_check', `hh', `cc')
add(`file_name_check', `hh', `cc')
add(`file_permissions_check', `hh', `cc', `test', `testscript')
+add(`files_dir_size_check', `hh', `cc')
add(`glep_31_check', `hh', `cc', `test')
add(`has_ebuilds_check', `hh', `cc', `test', `testscript')
add(`has_misc_files_check', `hh', `cc', `test', `testscript')
diff --git a/paludis/qa/files_dir_size_check.cc b/paludis/qa/files_dir_size_check.cc
new file mode 100644
index 0000000..5948b24
--- /dev/null
+++ b/paludis/qa/files_dir_size_check.cc
@@ -0,0 +1,83 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * 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 "files_dir_size_check.hh"
+
+#include <paludis/is_file_with_extension.hh>
+#include <paludis/dir_iterator.hh>
+
+using namespace paludis;
+using namespace paludis::qa;
+
+FilesDirSizeCheck::FilesDirSizeCheck()
+{
+}
+
+CheckResult
+FilesDirSizeCheck::operator() (const FSEntry & d) const
+{
+ CheckResult result(d, identifier());
+
+ if (! (d / "files").exists())
+ result << Message(qal_skip, "No files/ found");
+
+ 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(d / "files");
+
+ if (f.total_size > (20 * 1024))
+ result << Message(qal_minor, "files/ too bloated (" +
+ stringify(f.total_size / 1024) + "KBytes)");
+
+ return result;
+}
+
+const std::string &
+FilesDirSizeCheck::identifier()
+{
+ static const std::string id("files dir size");
+ return id;
+}
+
diff --git a/paludis/qa/files_dir_size_check.hh b/paludis/qa/files_dir_size_check.hh
new file mode 100644
index 0000000..c342a4e
--- /dev/null
+++ b/paludis/qa/files_dir_size_check.hh
@@ -0,0 +1,51 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * 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_QA_FILES_DIR_SIZE_CHECK_HH
+#define PALUDIS_GUARD_PALUDIS_QA_FILES_DIR_SIZE_CHECK_HH 1
+
+#include <paludis/qa/package_dir_check.hh>
+#include <string>
+
+namespace paludis
+{
+ namespace qa
+ {
+ class FilesDirSizeCheck :
+ public PackageDirCheck
+ {
+ public:
+ FilesDirSizeCheck();
+
+ CheckResult operator() (const FSEntry &) const;
+
+ static const std::string & identifier();
+
+ virtual std::string describe() const
+ {
+ return "Checks that files/ (excluding digests) is below 20k";
+ }
+ };
+
+ static const PackageDirCheckMaker::RegisterMaker register_files_dir_size_check(
+ FilesDirSizeCheck::identifier(), &make_package_dir_check<FilesDirSizeCheck>);
+ }
+}
+
+#endif