update
authorthierry <thierry@41d37cc5-eb28-0410-a9bf-d37491348ade>
Thu, 19 Mar 2009 11:13:26 +0000 (11:13 +0000)
committerthierry <thierry@41d37cc5-eb28-0410-a9bf-d37491348ade>
Thu, 19 Mar 2009 11:13:26 +0000 (11:13 +0000)
scripts/alpha-repo.py

index c4fef59..fc3900e 100755 (executable)
@@ -68,13 +68,21 @@ def extract_contents (standard):
     contents = [ rpm_name(rpm_file) for rpm_file in rpm_files]
     return contents
 
-def install_xfer (repo,rpm_name,options):
+def install_standard_rpm_name (repo,rpm_name,options):
+    former_alpha_rpms = set(glob.glob ('%s/%s*rpm'%(repo,rpm_name)))
     xfer_patt= '%s/xfer/RPMS/*/%s*.rpm' % (repo, rpm_name);
     xfer_rpm_names=glob.glob(xfer_patt)
     for xfer_rpm_name in xfer_rpm_names:
         command = 'mv %s %s' % ( xfer_rpm_name, repo)
         if prompt('Adopt %s'%os.path.basename(xfer_rpm_name)):
             run(command,options)
+            try:
+                former_alpha_rpms.remove('%s/%s'%(repo,rpm_name))
+            except:
+                pass
+    for former in former_alpha_rpms:
+        if prompt ('Remove old %s'%os.path.basename(former)):
+            command.run("rm %s"%former,options)
 
 def remaining_rpms (root):
     command="find %s -name '*.rpm'"%root
@@ -106,27 +114,34 @@ def main ():
     repo=options.repo
     standard=options.standard
 
+    ### in case we have leftovers from a previous run days ago, better clean it up
     xfer='%s/xfer'%repo
     if os.path.isdir(xfer):
         if prompt('Want to clean up %s'%xfer,False):
             run('rm -rf %s'%xfer,options)
 
+    # go get the stuff
     if prompt ('Need to fetch rpms from %s ' % http):
         rsync_xfer(http,repo,options)
     
+    # install yumgroups
     if prompt ('Install yumgroups'):
         command="mv %s/xfer/RPMS/yumgroups.xml %s/"%(repo,repo)
         run(command,options)
 
+    # compute the set of rpms currently in the standard repo
+    # i.e. the ones that come with noderepo
     if prompt ('Get list of standard rpms from %s ' % standard):
         rpm_names=extract_contents(standard)
 
+    # interactively propose to move them in the right place
     if prompt ('Moving standard rpms to %s' % repo):
         for rpm_name in rpm_names:
-            install_xfer(repo,rpm_name,options)
+            install_standard_rpm_name(repo,rpm_name,options)
 
     # once here, we have moved all the rpms that belonged to the standard noderepo
-    # let's manually scan the other ones as there might be new rpms needed
+    # let's manually scan the ones that remain in xfer/
+    # as there might be new rpms in this new build
     # the list proposed here contains mostly server-side rpms, 
     # so the prompt default is False
     if prompt ('Scan remaining rpms for double-check'):
@@ -141,6 +156,3 @@ def main ():
 
 if __name__ == '__main__':
     main()
-
-    
-