aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-06-29 19:14:56 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-06-29 19:14:56 +0000
commit0abcc993e5af9125f6d1b999d5ef0eb7fc91034e (patch)
tree6b3258f0f59613b392d0b093880dd0719787d8fd
parent6b37827c18302c498d0c4d32c85e5b745b565a7a (diff)
downloadpaludis-0abcc993e5af9125f6d1b999d5ef0eb7fc91034e.tar.gz
paludis-0abcc993e5af9125f6d1b999d5ef0eb7fc91034e.tar.xz
Use internal md5 routines rather than calling md5sum when merging and unmerging
-rw-r--r--ebuild/utils/Makefile.am10
-rw-r--r--ebuild/utils/merge.cc36
-rw-r--r--ebuild/utils/unmerge.cc10
3 files changed, 26 insertions, 30 deletions
diff --git a/ebuild/utils/Makefile.am b/ebuild/utils/Makefile.am
index 81b7095..5c88641 100644
--- a/ebuild/utils/Makefile.am
+++ b/ebuild/utils/Makefile.am
@@ -51,15 +51,13 @@ AM_CXXFLAGS = -I$(top_srcdir)
merge_SOURCES = merge.cc merge_common.cc merge_common.hh
merge_LDADD = \
- $(top_builddir)/paludis/libpaludis.a \
- $(top_builddir)/paludis/args/libpaludisargs.a \
- $(top_builddir)/paludis/util/libpaludisutil.a
+ $(top_builddir)/paludis/util/libpaludisutil.a \
+ $(top_builddir)/paludis/digests/libpaludisdigests.a
unmerge_SOURCES = unmerge.cc merge_common.cc merge_common.hh
unmerge_LDADD = \
- $(top_builddir)/paludis/libpaludis.a \
- $(top_builddir)/paludis/args/libpaludisargs.a \
- $(top_builddir)/paludis/util/libpaludisutil.a
+ $(top_builddir)/paludis/util/libpaludisutil.a \
+ $(top_builddir)/paludis/digests/libpaludisdigests.a
TESTS_ENVIRONMENT = env \
PALUDIS_EBUILD_DIR="`$(top_srcdir)/ebuild/utils/canonicalise $(top_srcdir)/ebuild/`" \
diff --git a/ebuild/utils/merge.cc b/ebuild/utils/merge.cc
index fa6be69..7345555 100644
--- a/ebuild/utils/merge.cc
+++ b/ebuild/utils/merge.cc
@@ -19,6 +19,7 @@
#include "merge_common.hh"
+#include <paludis/digests/md5.hh>
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/log.hh>
@@ -63,12 +64,10 @@ namespace
{
int n(0);
- PStream our_md5command(getenv_or_error("PALUDIS_EBUILD_DIR") +
- "/digests/domd5 '" + stringify(file_to_install) + "'");
- std::string our_md5((istreambuf_iterator<char>(our_md5command)),
- istreambuf_iterator<char>());
- if (0 != our_md5command.exit_status())
- throw Failure("Could not md5sum '" + stringify(name) + "'");
+ ifstream our_md5_file(stringify(file_to_install).c_str());
+ if (! our_md5_file)
+ throw Failure("Could not get md5 for '" + stringify(file_to_install) + "'");
+ MD5 our_md5(our_md5_file);
FSEntry result(name);
while (true)
@@ -77,13 +76,12 @@ namespace
return result;
else if (result.is_regular_file())
{
- PStream other_md5command(getenv_or_error("PALUDIS_EBUILD_DIR") +
- "/digests/domd5 '" + stringify(result) + "'");
- std::string other_md5((istreambuf_iterator<char>(other_md5command)),
- istreambuf_iterator<char>());
- if (0 != other_md5command.exit_status())
- throw Failure("Could not md5sum '" + stringify(result) + "'");
- if (other_md5 == our_md5)
+ ifstream other_md5_file(stringify(result).c_str());
+ if (! other_md5_file)
+ throw Failure("Could not get md5 for '" + stringify(result) + "'");
+ MD5 other_md5(other_md5_file);
+
+ if (our_md5.hexsum() == other_md5.hexsum())
return result;
}
@@ -300,13 +298,13 @@ namespace
ostreambuf_iterator<char>(output_file));
}
- PStream md5command(getenv_or_error("PALUDIS_EBUILD_DIR") +
- "/digests/domd5 '" + stringify(dst) + "'");
- std::string md5((istreambuf_iterator<char>(md5command)), istreambuf_iterator<char>());
- if (0 != md5command.exit_status())
- throw Failure("Could not md5sum '" + stringify(dst) + "'");
+ ifstream dst_file(stringify(dst).c_str());
+ if (! dst_file)
+ throw Failure("Could not get md5 for '" + stringify(dst_file) + "'");
+ MD5 md5(dst_file);
+
*contents << "obj " << dst_dir_str.substr(root_str.length()) << "/" <<
- dst.basename() << " " << strip_trailing(md5, "\n") << " " <<
+ dst.basename() << " " << md5.hexsum() << " " <<
FSEntry(stringify(dst)).mtime() << endl;
}
}
diff --git a/ebuild/utils/unmerge.cc b/ebuild/utils/unmerge.cc
index f17c3c5..4f217d5 100644
--- a/ebuild/utils/unmerge.cc
+++ b/ebuild/utils/unmerge.cc
@@ -19,6 +19,8 @@
#include "merge_common.hh"
+#include <paludis/digests/md5.hh>
+
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/log.hh>
@@ -81,16 +83,14 @@ namespace
cout << "--- [!time] " << tokens.at(1) << endl;
else
{
- PStream md5command(getenv_or_error("PALUDIS_EBUILD_DIR") +
- "/digests/domd5 '" + stringify(root / tokens.at(1)) + "'");
- std::string md5((istreambuf_iterator<char>(md5command)), istreambuf_iterator<char>());
- if (0 != md5command.exit_status())
+ ifstream md5_file(stringify(root / tokens.at(1)).c_str());
+ if (! md5_file)
{
Log::get_instance()->message(ll_warning, "Couldn't get md5 for '" +
stringify(root / tokens.at(1)) + "'");
cout << "--- [!md5?] " << tokens.at(1) << endl;
}
- else if (strip_trailing(md5, "\n") != tokens.at(2))
+ else if (MD5(md5_file).hexsum() != tokens.at(2))
cout << "--- [!md5 ] " << tokens.at(1) << endl;
else if (is_config_protected(root, root / tokens.at(1)))
cout << "--- [cfgpr] " << tokens.at(1) << endl;