aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-27 03:08:07 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-27 03:08:07 +0000
commita51731476ff340e08c7ee38f0749ae6f0fcc215f (patch)
tree222c6e2974160b27f91a7bb813bff5dd84ed9071
parent17b2f8db16626eb819e13663dd36c8278ddff068 (diff)
downloadpaludis-a51731476ff340e08c7ee38f0749ae6f0fcc215f.tar.gz
paludis-a51731476ff340e08c7ee38f0749ae6f0fcc215f.tar.xz
Be able to unmerge Portage-generated fif and dev vdb entries. Be less strict about vdb entries containing whitespace. Fixes: ticket:31
-rw-r--r--ebuild/unmerge.cc80
-rw-r--r--ebuild/unmerge_TEST.bash30
-rwxr-xr-xebuild/unmerge_TEST_setup.sh7
-rw-r--r--paludis/util/fs_entry.cc24
-rw-r--r--paludis/util/fs_entry.hh12
5 files changed, 149 insertions, 4 deletions
diff --git a/ebuild/unmerge.cc b/ebuild/unmerge.cc
index 0760440..367b42c 100644
--- a/ebuild/unmerge.cc
+++ b/ebuild/unmerge.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.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
@@ -72,6 +72,17 @@ namespace
if ("obj" == tokens.at(0))
{
+ while (tokens.size() > 4)
+ {
+ if (std::string::npos != tokens.at(4).find('='))
+ break;
+
+ tokens.at(1).append(" " + tokens.at(2));
+ for (unsigned i = 2 ; i < tokens.size() - 1 ; ++i)
+ tokens.at(i) = tokens.at(i + 1);
+ tokens.pop_back();
+ }
+
if (tokens.size() != 4)
{
Log::get_instance()->message(ll_warning, lc_no_context,
@@ -111,6 +122,34 @@ namespace
}
else if ("sym" == tokens.at(0))
{
+ while (tokens.size() > 5)
+ {
+ if (std::string::npos != tokens.at(2).find('='))
+ break;
+
+ if (tokens.at(2) == "->")
+ break;
+
+ tokens.at(1).append(" " + tokens.at(2));
+ for (unsigned i = 2 ; i < tokens.size() - 1; ++i)
+ tokens.at(i) = tokens.at(i + 1);
+ tokens.pop_back();
+ }
+
+ while (tokens.size() > 5)
+ {
+ if (std::string::npos != tokens.at(2).find('='))
+ break;
+
+ if (tokens.at(4) == "->")
+ break;
+
+ tokens.at(3).append(" " + tokens.at(4));
+ for (unsigned i = 4 ; i < tokens.size() - 1; ++i)
+ tokens.at(i) = tokens.at(i + 1);
+ tokens.pop_back();
+ }
+
if (tokens.size() != 5)
{
Log::get_instance()->message(ll_warning, lc_no_context,
@@ -131,7 +170,35 @@ namespace
}
else if ("misc" == tokens.at(0))
{
+ }
+ else if ("fif" == tokens.at(0) || "dev" == tokens.at(0))
+ {
+ while (tokens.size() > 2)
+ {
+ if (std::string::npos != tokens.at(2).find('='))
+ break;
+
+ tokens.at(1).append(" " + tokens.at(2));
+ for (unsigned i = 2 ; i < tokens.size() - 1; ++i)
+ tokens.at(i) = tokens.at(i + 1);
+ tokens.pop_back();
+ }
+ if (tokens.size() != 2)
+ {
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "Malformed VDB entry '" + *cur + "'");
+ exit_status |= 8;
+ }
+ else if ("fif" == tokens.at(0) && ! (root / tokens.at(1)).is_fifo())
+ cout << "--- [!type] " << tokens.at(1) << endl;
+ else if ("dev" == tokens.at(0) && ! (root / tokens.at(1)).is_device())
+ cout << "--- [!type] " << tokens.at(1) << endl;
+ else
+ {
+ cout << "<<< " << tokens.at(1) << endl;
+ (root / tokens.at(1)).unlink();
+ }
}
else if ("dir" == tokens.at(0))
/* nothing */ ;
@@ -158,6 +225,17 @@ namespace
if ("dir" == tokens.at(0))
{
+ while (tokens.size() > 2)
+ {
+ if (std::string::npos != tokens.at(2).find('='))
+ break;
+
+ tokens.at(1).append(" " + tokens.at(2));
+ for (unsigned i = 2 ; i < tokens.size() - 1; ++i)
+ tokens.at(i) = tokens.at(i + 1);
+ tokens.pop_back();
+ }
+
if (tokens.size() != 2)
{
Log::get_instance()->message(ll_warning, lc_no_context,
diff --git a/ebuild/unmerge_TEST.bash b/ebuild/unmerge_TEST.bash
index f3076b8..ace2de5 100644
--- a/ebuild/unmerge_TEST.bash
+++ b/ebuild/unmerge_TEST.bash
@@ -1,7 +1,7 @@
#!/bin/bash
# vim: set sw=4 sts=4 et :
-# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+# Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.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
@@ -64,3 +64,31 @@ unmerge_files_TEST()
test_equality "$ok" ""
}
+unmerge_spaces_TEST()
+{
+ ${TOP_BUILD_DIR}/ebuild/merge "unmerge_TEST_dir/spaces_src" \
+ "unmerge_TEST_dir/spaces_dst" \
+ "unmerge_TEST_dir/spaces_contents"
+ test_return_code
+
+ ok=
+ for a in unmerge_TEST_dir/spaces_dst/* ; do
+ [[ -e "$a" ]] || continue
+ ok=yes
+ break
+ done
+ test_equality "$ok" "yes"
+
+ ${TOP_BUILD_DIR}/ebuild/unmerge "unmerge_TEST_dir/spaces_dst" \
+ "unmerge_TEST_dir/spaces_contents"
+ test_return_code
+
+ ok=
+ for a in unmerge_TEST_dir/spaces_dst/* ; do
+ [[ -e "$a" ]] || continue
+ test_equality "$a" ""
+ ok=no
+ done
+ test_equality "$ok" ""
+}
+
diff --git a/ebuild/unmerge_TEST_setup.sh b/ebuild/unmerge_TEST_setup.sh
index 158e2ae..33643aa 100755
--- a/ebuild/unmerge_TEST_setup.sh
+++ b/ebuild/unmerge_TEST_setup.sh
@@ -6,3 +6,10 @@ mkdir -p unmerge_TEST_dir/{empty_src,empty_dst} || exit 2
mkdir -p unmerge_TEST_dir/{files_src,files_dst} || exit 3
echo "file one" > unmerge_TEST_dir/files_src/one
echo "file two" > unmerge_TEST_dir/files_src/two
+
+mkdir -p unmerge_TEST_dir/{spaces_src,spaces_dst} || exit 4
+echo "file one" > unmerge_TEST_dir/spaces_src/"file one"
+mkdir -p unmerge_TEST_dir/spaces_src/"dir two"
+echo "file two" > unmerge_TEST_dir/spaces_src/"dir two"/"file two"
+ln -s "link three" unmerge_TEST_dir/spaces_src/"link three"
+
diff --git a/paludis/util/fs_entry.cc b/paludis/util/fs_entry.cc
index d174279..bdd28a8 100644
--- a/paludis/util/fs_entry.cc
+++ b/paludis/util/fs_entry.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
* Copyright (c) 2006 Mark Loeser <halcy0n@gentoo.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -131,6 +131,28 @@ FSEntry::is_directory() const
}
bool
+FSEntry::is_fifo() const
+{
+ _stat();
+
+ if (_exists)
+ return S_ISFIFO((*_stat_info).st_mode);
+
+ return false;
+}
+
+bool
+FSEntry::is_device() const
+{
+ _stat();
+
+ if (_exists)
+ return S_ISBLK((*_stat_info).st_mode) || S_ISCHR((*_stat_info).st_mode);
+
+ return false;
+}
+
+bool
FSEntry::is_regular_file() const
{
_stat();
diff --git a/paludis/util/fs_entry.hh b/paludis/util/fs_entry.hh
index 5837507..0b67941 100644
--- a/paludis/util/fs_entry.hh
+++ b/paludis/util/fs_entry.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
* Copyright (c) 2006 Mark Loeser <halcy0n@gentoo.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -194,6 +194,16 @@ namespace paludis
bool is_symbolic_link() const;
/**
+ * Whether we exist and are a device file.
+ */
+ bool is_device() const;
+
+ /**
+ * Whether we exist and are a fifo.
+ */
+ bool is_fifo() const;
+
+ /**
* Check if filesystem entry has `perm` for `user_group`.
*
* \exception FSError if there was a problem accessing the filesystem entry