- Use filesystem::TmpDir to create unique and unused Source cache
authorMichael Andres <ma@suse.de>
Mon, 24 Apr 2006 13:49:03 +0000 (13:49 +0000)
committerMichael Andres <ma@suse.de>
Mon, 24 Apr 2006 13:49:03 +0000 (13:49 +0000)
  directories. (#168051)

devel/devel.dmacvicar/Makefile
devel/devel.ma/Parse.cc
package/libzypp.changes
zypp/SourceManager.cc

index 46888a6..9dd16c9 100644 (file)
@@ -34,9 +34,9 @@ POST_INSTALL = :
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
-build_triplet = i686-suse-linux
-host_triplet = i686-suse-linux
-target_triplet = i686-suse-linux
+build_triplet = x86_64-suse-linux
+host_triplet = x86_64-suse-linux
+target_triplet = x86_64-suse-linux
 noinst_PROGRAMS = test$(EXEEXT) lock$(EXEEXT) testbed$(EXEEXT)
 subdir = devel/devel.dmacvicar
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
@@ -76,15 +76,15 @@ DIST_SOURCES = $(lock_SOURCES) $(test_SOURCES) $(testbed_SOURCES)
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = ${SHELL} /space/sources/zypp-trunk/trunk/libzypp/missing --run aclocal-1.9
+ACLOCAL = ${SHELL} /Local/ma/zypp/libzypp/missing --run aclocal-1.9
 ALLOCA = 
 AMDEP_FALSE = #
 AMDEP_TRUE = 
-AMTAR = ${SHELL} /space/sources/zypp-trunk/trunk/libzypp/missing --run tar
+AMTAR = ${SHELL} /Local/ma/zypp/libzypp/missing --run tar
 AR = ar
-AUTOCONF = ${SHELL} /space/sources/zypp-trunk/trunk/libzypp/missing --run autoconf
-AUTOHEADER = ${SHELL} /space/sources/zypp-trunk/trunk/libzypp/missing --run autoheader
-AUTOMAKE = ${SHELL} /space/sources/zypp-trunk/trunk/libzypp/missing --run automake-1.9
+AUTOCONF = ${SHELL} /Local/ma/zypp/libzypp/missing --run autoconf
+AUTOHEADER = ${SHELL} /Local/ma/zypp/libzypp/missing --run autoheader
+AUTOMAKE = ${SHELL} /Local/ma/zypp/libzypp/missing --run automake-1.9
 AWK = gawk
 BUILD_INCLUDED_LIBINTL = no
 CATOBJEXT = .gmo
@@ -114,9 +114,9 @@ GENCAT = gencat
 GLIBC2 = yes
 GLIBC21 = yes
 GMSGFMT = /usr/bin/msgfmt
-HAL_CFLAGS = -DDBUS_API_SUBJECT_TO_CHANGE -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/hal -I/opt/gnome/include/glib-2.0 -I/opt/gnome/lib/glib-2.0/include  
+HAL_CFLAGS = -DFAKE_HAL
 HAL_LDADD = 
-HAL_LIBS = -L/opt/gnome/lib -lgobject-2.0 -ldbus-glib-1 -lglib-2.0 -lhal-storage -lhal -ldbus-1  
+HAL_LIBS = 
 HAVE_ASPRINTF = 1
 HAVE_DOT = YES
 HAVE_POSIX_PRINTF = 1
@@ -144,7 +144,7 @@ LN_S = ln -s
 LTLIBICONV = 
 LTLIBINTL = 
 LTLIBOBJS = 
-MAKEINFO = ${SHELL} /space/sources/zypp-trunk/trunk/libzypp/missing --run makeinfo
+MAKEINFO = ${SHELL} /Local/ma/zypp/libzypp/missing --run makeinfo
 MKINSTALLDIRS = $(top_builddir)/./mkinstalldirs
 MSGFMT = /usr/bin/msgfmt
 MSGMERGE = /usr/bin/msgmerge
@@ -157,7 +157,7 @@ PACKAGE_STRING = zypp 0.0.0
 PACKAGE_TARNAME = zypp
 PACKAGE_VERSION = 0.0.0
 PATH_SEPARATOR = :
-PKG_CONFIG = /usr/bin/pkg-config
+PKG_CONFIG = 
 POSUB = po
 RANLIB = ranlib
 SET_MAKE = 
@@ -173,7 +173,7 @@ ac_ct_CXX = g++
 ac_ct_F77 = 
 ac_ct_RANLIB = ranlib
 ac_ct_STRIP = strip
-ac_pt_PKG_CONFIG = /usr/bin/pkg-config
+ac_pt_PKG_CONFIG = 
 am__fastdepCC_FALSE = #
 am__fastdepCC_TRUE = 
 am__fastdepCXX_FALSE = #
@@ -184,23 +184,23 @@ am__quote =
 am__tar = tar --format=ustar -chf - "$$tardir"
 am__untar = tar -xf -
 bindir = ${exec_prefix}/bin
-build = i686-suse-linux
+build = x86_64-suse-linux
 build_alias = 
-build_cpu = i686
+build_cpu = x86_64
 build_os = linux
 build_vendor = suse
 datadir = ${prefix}/share
 docdir = ${datadir}/doc/packages
 exec_prefix = ${prefix}
-host = i686-suse-linux
+host = x86_64-suse-linux
 host_alias = 
-host_cpu = i686
+host_cpu = x86_64
 host_os = linux
 host_vendor = suse
 includedir = ${prefix}/include
 infodir = ${prefix}/info
-install_sh = /space/sources/zypp-trunk/trunk/libzypp/install-sh
-libdir = /usr/lib
+install_sh = /Local/ma/zypp/libzypp/install-sh
+libdir = /usr/lib64
 libexecdir = ${exec_prefix}/libexec
 localedir = /usr/share/locale
 localstatedir = ${prefix}/var
@@ -213,9 +213,9 @@ program_transform_name = s,x,x,
 sbindir = ${exec_prefix}/sbin
 sharedstatedir = ${prefix}/com
 sysconfdir = ${prefix}/etc
-target = i686-suse-linux
+target = x86_64-suse-linux
 target_alias = 
-target_cpu = i686
+target_cpu = x86_64
 target_os = linux
 target_vendor = suse
 xmlstoreschemadir = /usr/share/zypp/schema/xmlstore
index 993d638..91f35d9 100644 (file)
@@ -278,28 +278,6 @@ int main( int argc, char * argv[] )
   //zypp::base::LogControl::instance().logfile( "xxx" );
   INT << "===[START]==========================================" << endl;
 
-  map<NVRA,string> nvrmap;
-
-  NVRA a( "foo", Edition(""), Arch_noarch );
-  NVRA b( "baa", Edition(""), Arch_i386 );
-  NVRA c( "kaa", Edition(""), Arch_i486 );
-  NVRA d( "daa", Edition(""), Arch_ppc );
-
-  nvrmap[a] = "A";
-  nvrmap[b] = "B";
-  nvrmap[c] = "C";
-  nvrmap[d] = "D";
-
-  INT << nvrmap.size() << endl;
-  std::for_each( make_map_key_begin( nvrmap ),   make_map_key_end( nvrmap ),
-                 PrintOn<NVRA>(INT) );
-  std::for_each( make_map_key_begin( nvrmap ),   make_map_key_end( nvrmap ),
-                 PrintX(nvrmap) );
-
-  INT << nvrmap[NVRA( "kaa", Edition(""), Arch_i386 )]  << endl;
-
-  return 0;
-
   ResPool pool( getZYpp()->pool() );
 
   if ( 0 )
@@ -309,18 +287,37 @@ int main( int argc, char * argv[] )
       INT << "Added target: " << pool << endl;
     }
 
-  Url myUrl( "dir:/mounts/machcd2/CDs/SLES-10-CD-i386-Beta10/CD1" );
-  Source_Ref src1;
-  USR << src1 << endl;
-  try
-    {
-      src1 = SourceFactory().createFrom( myUrl, "/", Date::now().asSeconds() );
-    }
-  catch ( const Exception & )
-    {
-      ;
-    }
-  USR << src1 << endl;
+  if ( 1 ) {
+    SourceManager::sourceManager()->restore( sysRoot );
+    if ( SourceManager::sourceManager()->allSources().empty() )
+      {
+        Source_Ref src1;
+        if ( 1 )
+          {
+            Url myUrl( "dir:/mounts/machcd2/CDs/SLES-10-CD-i386-Beta10/CD1" );
+            USR << src1 << endl;
+            try
+              {
+                src1 = SourceFactory().createFrom( myUrl, "/", Date::now().asSeconds() );
+              }
+            catch ( const Exception & )
+              {
+                ;
+              }
+            USR << src1 << endl;
+          }
+        SourceManager::sourceManager()->addSource( src1 );
+        SourceManager::sourceManager()->store( sysRoot, true );
+      }
+
+    Source_Ref src( *SourceManager::sourceManager()->Source_begin() );
+  }
+
+  USR << "=======================" << endl;
+
+  SourceManager::sourceManager()->removeSource( SourceManager::sourceManager()->Source_begin()->numericId() );
+  SourceManager::sourceManager()->store( sysRoot, true );
+
 
 #if 0
   Source_Ref src1( createSource( "dir:/mounts/machcd2/CDs/SLES-10-CD-i386-Beta10/CD1" ) );
index e323f21..6276915 100644 (file)
@@ -1,4 +1,10 @@
 -------------------------------------------------------------------
+Mon Apr 24 15:44:18 CEST 2006 - ma@suse.de
+
+- Use filesystem::TmpDir to create unique and unused Source cache
+  directories. (#168051)
+
+-------------------------------------------------------------------
 Mon Apr 24 14:30:41 CEST 2006 - ma@suse.de
 
 - Enable signature checks per default. (#168525)
index 2fef26c..1847def 100644 (file)
@@ -23,6 +23,7 @@
 #include "zypp/Source.h"
 #include "zypp/source/SourceImpl.h"
 #include "zypp/target/store/PersistentStorage.h"
+#include "zypp/TmpPath.h"
 #include "zypp/Pathname.h"
 #include "zypp/PathInfo.h"
 
@@ -90,7 +91,7 @@ namespace zypp
       MIL << "SourceManager remove " << it->second << endl;
       _deleted_sources[it->second.numericId()] = it->second;
       _sources.erase(it);
-      
+
       // release all media of this source, not needed anymore (#159754)
       it->second.release();
 
@@ -266,8 +267,6 @@ namespace zypp
        MIL << "Created..." << topdir << std::endl;
     }
 
-    unsigned id = 0;
-
     // first, gather all known cache dirs
     std::set<std::string> known_caches;
     for( SourceMap::iterator it = _sources.begin(); it != _sources.end(); it++)
@@ -293,27 +292,9 @@ namespace zypp
        {
            if( descr.cache_dir.empty() )
            {
-               // generate the new cache name
-
-               std::string cache = ZYPP_METADATA_PREFIX + str::numstring(id); // we should strip root here
-
-               // generate a new cache dir
-               while( id < 1000 && known_caches.find( cache ) != known_caches.end() )
-               {
-                   ++id;
-                   cache = ZYPP_METADATA_PREFIX + str::numstring(id); // we should strip root here
-               }
-
-               if ( id == 1000 )
-               {
-                   ERR << "Unable to generate a new cache directory name" << endl;
-                   metadata_cache = false;
-                   continue;
-               }
-
-               descr.cache_dir = cache;
-
-               known_caches.insert( cache );
+              filesystem::TmpDir newCache( root_r /  ZYPP_METADATA_PREFIX, "Source." );
+              descr.cache_dir = ZYPP_METADATA_PREFIX + newCache.path().basename();
+              known_caches.insert( descr.cache_dir.asString() );
            }
 
            filesystem::assert_dir ( root_r.asString() + descr.cache_dir );