Mailinglist Archive: zypp-commit (223 mails)

< Previous Next >
[zypp-commit] r10712 - in /trunk/libzypp: ./ package/ tests/zypp/ zypp/ zypp/media/ zypp/target/
  • From: dmacvicar@xxxxxxxxxxxxxxxx
  • Date: Thu, 31 Jul 2008 17:08:20 -0000
  • Message-id: <20080731170820.4436C2F11F@xxxxxxxxxxxxxxxx>
Author: dmacvicar
Date: Thu Jul 31 19:08:19 2008
New Revision: 10712

URL: http://svn.opensuse.org/viewcvs/zypp?rev=10712&view=rev
Log:
generate a unique anonymous unique string per target
and add it to the agent string for better statistics

Added:
trunk/libzypp/tests/zypp/Target_test.cc
Modified:
trunk/libzypp/libzypp.spec.cmake
trunk/libzypp/package/libzypp.changes
trunk/libzypp/tests/zypp/CMakeLists.txt
trunk/libzypp/zypp/Target.cc
trunk/libzypp/zypp/Target.h
trunk/libzypp/zypp/media/MediaCurl.cc
trunk/libzypp/zypp/target/TargetImpl.cc
trunk/libzypp/zypp/target/TargetImpl.h

Modified: trunk/libzypp/libzypp.spec.cmake
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/libzypp.spec.cmake?rev=10712&r1=10711&r2=10712&view=diff
==============================================================================
--- trunk/libzypp/libzypp.spec.cmake (original)
+++ trunk/libzypp/libzypp.spec.cmake Thu Jul 31 19:08:19 2008
@@ -29,6 +29,7 @@

%if 0%{?suse_version}
BuildRequires: hicolor-icon-theme update-desktop-files rpm-devel
+Requires: uuid-runtime
%endif

%if 0%{?fedora_version}
@@ -38,6 +39,8 @@
%if 0%{?mandriva_version}
BuildRequires: glib2-devel
BuildRequires: librpm-devel
+# uuidgen
+Requires: e2fsprogs
%endif



Modified: trunk/libzypp/package/libzypp.changes
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/package/libzypp.changes?rev=10712&r1=10711&r2=10712&view=diff
==============================================================================
--- trunk/libzypp/package/libzypp.changes (original)
+++ trunk/libzypp/package/libzypp.changes Thu Jul 31 19:08:19 2008
@@ -6,6 +6,12 @@
- revision 10710

-------------------------------------------------------------------
+Thu Jul 31 19:01:54 CEST 2008 - dmacvicar@xxxxxxx
+
+- generate a unique anonymous unique string per target
+ and add it to the agent string for better statistics
+
+-------------------------------------------------------------------
Wed Jul 30 19:12:00 CEST 2008 ma@xxxxxxx

- /var/lib/zypp and /var/cache/zypp should be owned by libzypp

Modified: trunk/libzypp/tests/zypp/CMakeLists.txt
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/CMakeLists.txt?rev=10712&r1=10711&r2=10712&view=diff
==============================================================================
--- trunk/libzypp/tests/zypp/CMakeLists.txt (original)
+++ trunk/libzypp/tests/zypp/CMakeLists.txt Thu Jul 31 19:08:19 2008
@@ -28,6 +28,7 @@
RepoManager
RepoStatus
ResKind
+ Target
TranslatedText
Url
Vendor

Added: trunk/libzypp/tests/zypp/Target_test.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/Target_test.cc?rev=10712&view=auto
==============================================================================
--- trunk/libzypp/tests/zypp/Target_test.cc (added)
+++ trunk/libzypp/tests/zypp/Target_test.cc Thu Jul 31 19:08:19 2008
@@ -0,0 +1,32 @@
+
+#include <iostream>
+#include <list>
+#include <string>
+
+// Boost.Test
+#include <boost/test/auto_unit_test.hpp>
+
+#include "zypp/base/Logger.h"
+#include "zypp/base/Exception.h"
+#include "zypp/ZYppFactory.h"
+#include "zypp/ZYpp.h"
+#include "zypp/ZYppFactory.h"
+#include "zypp/TmpPath.h"
+
+using boost::unit_test::test_case;
+using namespace std;
+using namespace zypp;
+
+
+BOOST_AUTO_TEST_CASE(target_test)
+{
+
+ filesystem::TmpDir tmp;
+
+ ZYpp::Ptr z = getZYpp();
+ z->initializeTarget( tmp.path() );
+
+ BOOST_CHECK( ! z->target()->anonymousUniqueId().empty() );
+ BOOST_CHECK( PathInfo( tmp.path() /
"/var/lib/zypp/AnonymousUniqueId").isExist() );
+ BOOST_CHECK( PathInfo( tmp.path() /
"/var/lib/zypp/AnonymousUniqueId").size() > 0 );
+}

Modified: trunk/libzypp/zypp/Target.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Target.cc?rev=10712&r1=10711&r2=10712&view=diff
==============================================================================
--- trunk/libzypp/zypp/Target.cc (original)
+++ trunk/libzypp/zypp/Target.cc Thu Jul 31 19:08:19 2008
@@ -100,6 +100,9 @@
std::string Target::release() const
{ return _pimpl->release(); }

+ std::string Target::anonymousUniqueId() const
+ { return _pimpl->anonymousUniqueId(); }
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////

Modified: trunk/libzypp/zypp/Target.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Target.h?rev=10712&r1=10711&r2=10712&view=diff
==============================================================================
--- trunk/libzypp/zypp/Target.h (original)
+++ trunk/libzypp/zypp/Target.h Thu Jul 31 19:08:19 2008
@@ -110,6 +110,16 @@
*/
std::string release() const;

+ /**
+ * anonymous unique id
+ *
+ * This id is generated once and stays in the
+ * saved in the target.
+ * It is unique and is used only for statistics.
+ *
+ */
+ std::string anonymousUniqueId() const;
+
public:
/** Ctor. If \c doRebuild_r is \c true, an already existing
* database is rebuilt (rpm --rebuilddb ).

Modified: trunk/libzypp/zypp/media/MediaCurl.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaCurl.cc?rev=10712&r1=10711&r2=10712&view=diff
==============================================================================
--- trunk/libzypp/zypp/media/MediaCurl.cc (original)
+++ trunk/libzypp/zypp/media/MediaCurl.cc Thu Jul 31 19:08:19 2008
@@ -26,6 +26,9 @@
#include "zypp/media/MediaUserAuth.h"
#include "zypp/media/CurlConfig.h"
#include "zypp/thread/Once.h"
+#include "zypp/Target.h"
+#include "zypp/ZYppFactory.h"
+
#include <cstdlib>
#include <sys/types.h>
#include <sys/stat.h>
@@ -183,9 +186,29 @@

const char *const MediaCurl::agentString()
{
- static const std::string _value( str::form( "ZYpp %s (curl %s)",
+ // we need to add the release and identifier to the
+ // agent string.
+ // The target could be not initialized, and then this information
+ // is not available.
+ Target_Ptr target;
+ // FIXME this has to go away as soon as the target
+ // does not throw when not initialized.
+ try {
+ target = zypp::getZYpp()->target();
+ }
+ catch ( const Exception &e )
+ {
+ // nothing to do
+ }
+
+ static const std::string _value( str::form( "ZYpp %s (curl %s) %s",
VERSION,
-
curl_version_info(CURLVERSION_NOW)->version ) );
+
curl_version_info(CURLVERSION_NOW)->version,
+ target ? str::form( " - %s on
'%s'",
+
target->anonymousUniqueId().c_str(),
+
target->release().c_str() ).c_str()
+ : "" )
+ );
return _value.c_str();
}


Modified: trunk/libzypp/zypp/target/TargetImpl.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/TargetImpl.cc?rev=10712&r1=10711&r2=10712&view=diff
==============================================================================
--- trunk/libzypp/zypp/target/TargetImpl.cc (original)
+++ trunk/libzypp/zypp/target/TargetImpl.cc Thu Jul 31 19:08:19 2008
@@ -287,6 +287,52 @@
, _hardLocksFile( Pathname::assertprefix( _root,
ZConfig::instance().locksFile() ) )
{
_rpm.initDatabase( root_r, Pathname(), doRebuild_r );
+
+ // create the anonymous unique id
+ // this value is used for statistics
+ Pathname idpath( home() / "AnonymousUniqueId");
+
+ if ( ! PathInfo( idpath ).isExist() )
+ {
+ MIL << "creating anonymous unique id" << endl;
+
+ // if the file does not exist we need to generate the uuid file
+ const char* argv[] =
+ {
+ "/usr/bin/uuidgen",
+ "-r",
+ "-t",
+ NULL
+ };
+
+ ExternalProgram prog( argv,
+ ExternalProgram::Normal_Stderr,
+ false, -1, true);
+ std::string line;
+ std::ofstream idfile;
+ // make sure the path exists
+ filesystem::assert_dir( home() );
+ idfile.open( idpath.c_str() );
+
+ if ( idfile.good() )
+ {
+ for(line = prog.receiveLine();
+ ! line.empty();
+ line = prog.receiveLine() )
+ {
+ MIL << line << endl;
+
+ idfile << line;
+ }
+ prog.close();
+ }
+ else
+ {
+ // FIXME, should we ignore the error?
+ ZYPP_THROW(Exception("Can't open anonymous id file '" +
idpath.asString() + "' for writing"));
+ }
+ }
+
MIL << "Initialized target on " << _root << endl;
}

@@ -822,6 +868,18 @@
return _("Unknown Distribution");
}

+ std::string TargetImpl::anonymousUniqueId() const
+ {
+ std::ifstream idfile( ( home() / "AnonymousUniqueId" ).c_str() );
+ for( iostr::EachLine in( idfile ); in; in.next() )
+ {
+ std::string line( str::trim( *in ) );
+ if ( ! line.empty() )
+ return line;
+ }
+ return std::string();
+ }
+
void TargetImpl::installSrcPackage( const SrcPackage_constPtr &
srcPackage_r )
{
// provide on local disk

Modified: trunk/libzypp/zypp/target/TargetImpl.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/TargetImpl.h?rev=10712&r1=10711&r2=10712&view=diff
==============================================================================
--- trunk/libzypp/zypp/target/TargetImpl.h (original)
+++ trunk/libzypp/zypp/target/TargetImpl.h Thu Jul 31 19:08:19 2008
@@ -78,6 +78,8 @@

void buildCache();

+ std::string anonymousUniqueId() const;
+
public:

/** The root set for this target */

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages