aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Richard Brown <rbrown@exherbo.org> 2007-03-07 22:44:15 +0000
committerAvatar Richard Brown <rbrown@exherbo.org> 2007-03-07 22:44:15 +0000
commit18f8ce9abc51d4d1b4be0240b81a5d840709c1e3 (patch)
tree2e028d88db290dd0ce7141ee5b70861cb3c34690
parent78211c1ec110e4ab049865091dfa1300abd173d5 (diff)
downloadpaludis-18f8ce9abc51d4d1b4be0240b81a5d840709c1e3.tar.gz
paludis-18f8ce9abc51d4d1b4be0240b81a5d840709c1e3.tar.xz
Add FindUnusedPackageTask to ruby.
-rw-r--r--paludis/tasks/Makefile.am6
-rw-r--r--ruby/Makefile.am11
-rw-r--r--ruby/find_unused_packages_task.cc101
-rw-r--r--ruby/find_unused_packages_task_TEST.rb52
-rwxr-xr-xruby/find_unused_packages_task_TEST_cleanup.sh12
-rwxr-xr-xruby/find_unused_packages_task_TEST_setup.sh63
-rw-r--r--src/clients/adjutrix/Makefile.am2
-rw-r--r--src/clients/contrarius/Makefile.am2
-rw-r--r--src/clients/paludis/Makefile.am4
9 files changed, 243 insertions, 10 deletions
diff --git a/paludis/tasks/Makefile.am b/paludis/tasks/Makefile.am
index 48c7723..37562c7 100644
--- a/paludis/tasks/Makefile.am
+++ b/paludis/tasks/Makefile.am
@@ -19,7 +19,7 @@ TESTS_ENVIRONMENT = env \
check_PROGRAMS = $(TESTS)
check_SCRIPTS =
-noinst_LIBRARIES = libpaludistasks.a
+lib_LTLIBRARIES = libpaludistasks.la
paludis_tasks_includedir = $(includedir)/paludis/tasks
paludis_tasks_include_HEADERS = \
find_unused_packages_task.hh \
@@ -31,7 +31,7 @@ paludis_tasks_include_HEADERS = \
report_task.hh \
exceptions.hh
-libpaludistasks_a_SOURCES = $(paludis_tasks_include_HEADERS) \
+libpaludistasks_la_SOURCES = $(paludis_tasks_include_HEADERS) \
find_unused_packages_task.cc \
install_task.cc \
uninstall_task.cc \
@@ -42,7 +42,7 @@ libpaludistasks_a_SOURCES = $(paludis_tasks_include_HEADERS) \
if ! MONOLITHIC
-libpaludistasks_a_LIBADD = \
+libpaludistasks_la_LIBADD = \
$(top_builddir)/paludis/dep_list/libpaludisdeplist.la \
$(top_builddir)/paludis/libpaludis.la \
$(top_builddir)/paludis/util/libpaludisutil.la
diff --git a/ruby/Makefile.am b/ruby/Makefile.am
index 4302f5e..eb4442d 100644
--- a/ruby/Makefile.am
+++ b/ruby/Makefile.am
@@ -31,7 +31,8 @@ IF_RUBY_TESTS = \
dep_list_TEST.rb \
dep_tag_TEST.rb \
query_TEST.rb \
- package_database_TEST.rb
+ package_database_TEST.rb \
+ find_unused_packages_task_TEST.rb
IF_RUBY_QA_TESTS = \
message_TEST.rb \
@@ -56,7 +57,8 @@ IF_RUBY_SOURCES = \
contents.cc \
dep_list.cc \
dep_tag.cc \
- query.cc
+ query.cc \
+ find_unused_packages_task.cc
IF_RUBY_QA_SOURCES = \
message.cc \
@@ -75,7 +77,8 @@ EXTRA_DIST = $(IF_RUBY_TESTS) $(IF_RUBY_SOURCES) \
paludis_ruby_TEST_setup.sh paludis_ruby_TEST_cleanup.sh \
qa_environment_TEST_setup.sh qa_environment_TEST_cleanup.sh \
check_TEST_setup.sh check_TEST_cleanup.sh \
- dep_list_TEST_setup.sh dep_list_TEST_cleanup.sh
+ dep_list_TEST_setup.sh dep_list_TEST_cleanup.sh \
+ find_unused_packages_task_TEST_setup.sh find_unused_packages_task_TEST_cleanup.sh
TESTS_ENVIRONMENT = env \
PALUDIS_NO_GLOBAL_HOOKS="yes" \
@@ -116,6 +119,7 @@ libpaludisruby_la_LIBADD = \
$(top_builddir)/paludis/libpaludis.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
$(top_builddir)/paludis/dep_list/libpaludisdeplist.la \
+ $(top_builddir)/paludis/tasks/libpaludistasks.la \
$(top_builddir)/paludis/repositories/libpaludisrepositories.la \
$(top_builddir)/paludis/repositories/gentoo/libpaludisgentoorepository.la \
$(top_builddir)/paludis/environments/paludis/libpaludispaludisenvironment.la \
@@ -132,6 +136,7 @@ libpaludisruby_la_LIBADD = \
$(top_builddir)/paludis/libpaludis.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
$(top_builddir)/paludis/dep_list/libpaludisdeplist.la \
+ $(top_builddir)/paludis/tasks/libpaludistasks.la \
$(top_builddir)/paludis/repositories/libpaludisrepositories.la \
$(top_builddir)/paludis/repositories/gentoo/libpaludisgentoorepository.la \
$(top_builddir)/paludis/environments/paludis/libpaludispaludisenvironment.la \
diff --git a/ruby/find_unused_packages_task.cc b/ruby/find_unused_packages_task.cc
new file mode 100644
index 0000000..e55dae6
--- /dev/null
+++ b/ruby/find_unused_packages_task.cc
@@ -0,0 +1,101 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Richard Brown <rbrown@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 <paludis_ruby.hh>
+#include <paludis/tasks/find_unused_packages_task.hh>
+#include <ruby.h>
+
+using namespace paludis;
+using namespace paludis::ruby;
+
+#define RUBY_FUNC_CAST(x) reinterpret_cast<VALUE (*)(...)>(x)
+
+namespace
+{
+ static VALUE c_find_unused_packages_task;
+
+ VALUE
+ find_unused_packages_task_init(int, VALUE *, VALUE self)
+ {
+ return self;
+ }
+
+ VALUE
+ find_unused_packages_task_new(int argc, VALUE *argv, VALUE self)
+ {
+ FindUnusedPackagesTask * ptr(0);
+ try
+ {
+ if (2 == argc)
+ {
+ ptr = new FindUnusedPackagesTask(value_to_environment_data(argv[0])->env_ptr,
+ value_to_repository(argv[1]).get());
+ }
+ else
+ {
+ rb_raise(rb_eArgError, "FindUnusedPackagesTask expects two arguments, but got %d",argc);
+ }
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<FindUnusedPackagesTask>::free, ptr));
+ rb_obj_call_init(tdata, argc, argv);
+ return tdata;
+ }
+ catch (const std::exception & e)
+ {
+ delete ptr;
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ VALUE find_unused_packages_task_execute(VALUE self, VALUE qpn)
+ {
+ try
+ {
+ FindUnusedPackagesTask * ptr;
+ Data_Get_Struct(self, FindUnusedPackagesTask, ptr);
+ std::tr1::shared_ptr<const PackageDatabaseEntryCollection> c(ptr->execute(value_to_qualified_package_name(qpn)));
+ VALUE result(rb_ary_new());
+ for (PackageDatabaseEntryCollection::Iterator i(c->begin()), i_end(c->end()) ; i != i_end ; ++i)
+ rb_ary_push(result, package_database_entry_to_value(*i));
+ return result;
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ void do_register_find_unused_packages_task()
+ {
+ /* Document-class: Paludis::QA::Message
+ *
+ * A QA message
+ */
+ c_find_unused_packages_task = rb_define_class_under(paludis_module(),
+ "FindUnusedPackagesTask", rb_cObject);
+ rb_define_singleton_method(c_find_unused_packages_task,
+ "new", RUBY_FUNC_CAST(&find_unused_packages_task_new),-1);
+ rb_define_method(c_find_unused_packages_task,
+ "initialize", RUBY_FUNC_CAST(&find_unused_packages_task_init),-1);
+ rb_define_method(c_find_unused_packages_task,
+ "execute", RUBY_FUNC_CAST(&find_unused_packages_task_execute),1);
+ }
+}
+
+RegisterRubyClass::Register paludis_ruby_register_find_unused_packages_task PALUDIS_ATTRIBUTE((used))
+ (&do_register_find_unused_packages_task);
diff --git a/ruby/find_unused_packages_task_TEST.rb b/ruby/find_unused_packages_task_TEST.rb
new file mode 100644
index 0000000..648150f
--- /dev/null
+++ b/ruby/find_unused_packages_task_TEST.rb
@@ -0,0 +1,52 @@
+#!/usr/bin/env ruby
+# vim: set sw=4 sts=4 et tw=80 :
+
+#
+# Copyright (c) 2007 Richard Brown <rbrown@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
+#
+
+require 'test/unit'
+require 'Paludis'
+
+module Paludis
+ Log.instance.log_level = LogLevel::Warning
+
+ class TestCase_FindUnusedPackagesTask < Test::Unit::TestCase
+ def env
+ NoConfigEnvironment.new(Dir.getwd().to_s + "/find_unused_packages_task_TEST_dir/testrepo")
+ end
+
+ def task
+ FindUnusedPackagesTask.new(env,env.portage_repository)
+ end
+
+ def test_create
+ assert_nothing_raised do
+ task
+ end
+ end
+
+ def test_execute
+ t = task
+ bar = t.execute(QualifiedPackageName.new('foo/bar'))
+ assert bar.empty?
+ baz = t.execute(QualifiedPackageName.new('foo/baz'))
+ assert_equal 1, baz.length
+ assert_kind_of PackageDatabaseEntry, baz.first
+ end
+ end
+end
+
diff --git a/ruby/find_unused_packages_task_TEST_cleanup.sh b/ruby/find_unused_packages_task_TEST_cleanup.sh
new file mode 100755
index 0000000..64e75c8
--- /dev/null
+++ b/ruby/find_unused_packages_task_TEST_cleanup.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+if [ -d find_unused_packages_task_TEST_dir ] ; then
+ rm -fr find_unused_packages_task_TEST_dir
+else
+ true
+fi
+
+
+
+
diff --git a/ruby/find_unused_packages_task_TEST_setup.sh b/ruby/find_unused_packages_task_TEST_setup.sh
new file mode 100755
index 0000000..0aa5c1d
--- /dev/null
+++ b/ruby/find_unused_packages_task_TEST_setup.sh
@@ -0,0 +1,63 @@
+#!/bin/bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+mkdir find_unused_packages_task_TEST_dir || exit 1
+cd find_unused_packages_task_TEST_dir || exit 1
+
+mkdir -p testrepo/{eclass,distfiles,profiles/testprofile,foo/bar/files,foo/baz/files} || exit 1
+
+cd testrepo || exit 1
+echo "testrepo" > profiles/repo_name || exit 1
+cat <<END > profiles/categories || exit 1
+foo
+END
+cat <<END > profiles/testprofile/make.defaults
+ARCH=test
+USERLAND=test
+KERNEL=test
+END
+cat <<END > profiles/profiles.desc
+test testprofile stable
+END
+
+cat <<"END" > foo/bar/bar-1.0.ebuild || exit 1
+DESCRIPTION="Test package"
+HOMEPAGE="http://paludis.pioto.org/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+END
+
+cat <<"END" > foo/bar/bar-2.0.ebuild || exit 1
+DESCRIPTION="Test package"
+HOMEPAGE="http://paludis.pioto.org/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="~test"
+END
+
+cat <<"END" > foo/baz/baz-1.0.ebuild || exit 1
+DESCRIPTION="Test package"
+HOMEPAGE="http://paludis.pioto.org/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+END
+
+cat <<"END" > foo/baz/baz-2.0.ebuild || exit 1
+DESCRIPTION="Test package"
+HOMEPAGE="http://paludis.pioto.org/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+END
+
+cd ..
diff --git a/src/clients/adjutrix/Makefile.am b/src/clients/adjutrix/Makefile.am
index 389721b..3c49ebf 100644
--- a/src/clients/adjutrix/Makefile.am
+++ b/src/clients/adjutrix/Makefile.am
@@ -50,7 +50,7 @@ adjutrix_LDADD = \
$(top_builddir)/paludis/environments/no_config/libpaludisnoconfigenvironment.la \
$(top_builddir)/paludis/repositories/gentoo/libpaludisgentoorepository.la \
$(top_builddir)/paludis/repositories/fake/libpaludisfakerepository.la \
- $(top_builddir)/paludis/tasks/libpaludistasks.a \
+ $(top_builddir)/paludis/tasks/libpaludistasks.la \
$(top_builddir)/paludis/libpaludis.la \
$(top_builddir)/paludis/args/libpaludisargs.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
diff --git a/src/clients/contrarius/Makefile.am b/src/clients/contrarius/Makefile.am
index a8c9dbd..09817a4 100644
--- a/src/clients/contrarius/Makefile.am
+++ b/src/clients/contrarius/Makefile.am
@@ -27,7 +27,7 @@ contrarius_SOURCES = \
contrarius_LDADD = \
$(top_builddir)/paludis/libpaludis.la \
$(top_builddir)/paludis/environments/libpaludisenvironments.la \
- $(top_builddir)/paludis/tasks/libpaludistasks.a \
+ $(top_builddir)/paludis/tasks/libpaludistasks.la \
$(top_builddir)/paludis/args/libpaludisargs.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
$(top_builddir)/paludis/dep_list/libpaludisdeplist.la \
diff --git a/src/clients/paludis/Makefile.am b/src/clients/paludis/Makefile.am
index 9d88478..57c2c98 100644
--- a/src/clients/paludis/Makefile.am
+++ b/src/clients/paludis/Makefile.am
@@ -49,7 +49,7 @@ paludis_SOURCES = \
if MONOLITHIC
paludis_LDADD = \
- $(top_builddir)/paludis/tasks/libpaludistasks.a \
+ $(top_builddir)/paludis/tasks/libpaludistasks.la \
$(top_builddir)/paludis/libpaludis.la \
$(top_builddir)/paludis/args/libpaludisargs.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
@@ -63,7 +63,7 @@ paludis_LDADD = \
else
paludis_LDADD = \
- $(top_builddir)/paludis/tasks/libpaludistasks.a \
+ $(top_builddir)/paludis/tasks/libpaludistasks.la \
$(top_builddir)/paludis/libpaludis.la \
$(top_builddir)/paludis/args/libpaludisargs.la \
$(top_builddir)/paludis/util/libpaludisutil.la \