CVS: src/si/extras entitycheck.py,1.23,1.24
Mats Wichmann <[email protected]>
| Newsgroups | gmane.linux.lsb.implementation |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/lsb/src/si/extras
In directory sc8-pr-cvs1:/tmp/cvs-serv12926
Modified Files:
entitycheck.py
Log Message:
A little more polish
Index: entitycheck.py
===================================================================
RCS file: /cvsroot/lsb/src/si/extras/entitycheck.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -r1.23 -r1.24
*** entitycheck.py 10 Jan 2003 18:45:36 -0000 1.23
--- entitycheck.py 10 Jan 2003 19:19:16 -0000 1.24
***************
*** 19,23 ****
--dryrun -- test what pkgs would be retrieved
-u FILE, --updatefile=FILE -- use FILE for pkg locations [%s]
! -z URL, --fallback=URL -- use URL for fallback for pkgs [%s]
-h, --help -- print this text and exit
"""
--- 19,23 ----
--dryrun -- test what pkgs would be retrieved
-u FILE, --updatefile=FILE -- use FILE for pkg locations [%s]
! -z URL, --fallback=URL -- use URL as fallback for pkg retrieval [%s]
-h, --help -- print this text and exit
"""
***************
*** 25,30 ****
import sys, re, os, getopt, string, md5, urllib
! # DEFAULTS: the only stuff that should need tuning
! # Path defaults
entity_file = 'entities/package'
package_path = '/usr/src/si/packages'
--- 25,30 ----
import sys, re, os, getopt, string, md5, urllib
! # PATH DEFAULTS the only stuff that should need tuning
! # These are used as globals throughout
entity_file = 'entities/package'
package_path = '/usr/src/si/packages'
***************
*** 33,37 ****
update_file = 'extras/package_locations'
fallback_url = 'ftp://freestandards.org/pub/lsb/impl/beta/source/packages'
! # Behavior defaults
generate_sums = None
check_sums = None
--- 33,40 ----
update_file = 'extras/package_locations'
fallback_url = 'ftp://freestandards.org/pub/lsb/impl/beta/source/packages'
!
! # Behavior defaults: generally should not change, since
! # the command-line options are not set up to be inverses
! # (i.e. if default is changed to true, no way to set back to false)
generate_sums = None
check_sums = None
***************
*** 112,116 ****
try:
! filename, mime = urllib.urlretrieve(to_get, pkgpath, self.feedback)
if mime and mime.gettype() == 'text/html':
raise IOError
--- 115,120 ----
try:
! filename, mime = urllib.urlretrieve(to_get, pkgpath,
! self.feedback)
if mime and mime.gettype() == 'text/html':
raise IOError
***************
*** 118,122 ****
break
except IOError:
! # if it dies, remove the partial file
if os.path.exists(pkgpath): os.remove(pkgpath)
--- 122,126 ----
break
except IOError:
! # if it died, remove the partial file
if os.path.exists(pkgpath): os.remove(pkgpath)
***************
*** 167,178 ****
def parse_locations():
! """Parse the locations file. Returns a list of package
! location instances.
! """
#
# The locations file contains lines of the form:
! # pkgname url alternate_url
#
! # Alternate_url is used in cases where the package may not stay
# in one place over time (e.g., if it moves to an "old" directory
# when a new version is released)
--- 171,180 ----
def parse_locations():
! """Parse the locations file. Returns a list of location instances."""
#
# The locations file contains lines of the form:
! # pkgname url alternate_url // comment
#
! # alternate_url is used in cases where the package may not stay
# in one place over time (e.g., if it moves to an "old" directory
# when a new version is released)
***************
*** 185,189 ****
locations = []
for line in package_file.readlines():
! if line[0] == '#': continue # skip comments
bits = string.split(line)
if len(bits) < 3 or bits[1] == "none" or bits[1] == "None":
--- 187,191 ----
locations = []
for line in package_file.readlines():
! if line[0] == '#': continue # '#' is used for an initial comment
bits = string.split(line)
if len(bits) < 3 or bits[1] == "none" or bits[1] == "None":
***************
*** 209,214 ****
else:
found.append(item)
! if check_sums or generate_sums:
! item.domd5()
return (found, missing)
--- 211,215 ----
else:
found.append(item)
! if check_sums or generate_sums: item.domd5()
return (found, missing)
***************
*** 249,254 ****
for item in collection:
print "\t", item.file
- # For debugging: print both name and file
- #print "\t", item.name, "->", item.file
def report(fnd_pkg, fnd_pat, miss_pkg, miss_pat, extras, *sums):
--- 250,253 ----
***************
*** 288,295 ****
dump_coll(failed, "Packages which failed to retrieve:")
dump_coll(missing, "Entities missing:")
! if failed or missing:
! return 1
! else:
! return 0
def readmd5():
--- 287,293 ----
dump_coll(failed, "Packages which failed to retrieve:")
dump_coll(missing, "Entities missing:")
!
! if failed or missing: return 1
! return 0
def readmd5():
***************
*** 330,334 ****
fails.append(pkg)
if pkg.message == 'not found':
! # should not happen, but we track so we can catch where
# an entity is defined but not listed in package_locations
missing.append(pkg)
--- 328,332 ----
fails.append(pkg)
if pkg.message == 'not found':
! # should not happen, but we track 'em so we can catch where
# an entity is defined but not listed in package_locations
missing.append(pkg)
***************
*** 352,357 ****
if opt in ('--packagepath', '-p'): package_path = arg
if opt in ('--patchpath', '-d'): patch_path = arg
! if opt in ('--gensum', '-g'): generate_sums = 'yes'
! if opt in ('--checksum', '-c'): check_sums = 'yes'
if opt in ('--sumfile', '-s'): md5sum_file = arg
if opt in ('--fetch', '-f'): fetch_files = 'yes'
--- 350,361 ----
if opt in ('--packagepath', '-p'): package_path = arg
if opt in ('--patchpath', '-d'): patch_path = arg
! if opt in ('--gensum', '-g'):
! if check_sums:
! usage(2, "check-sums and generate-sums are mutually exclusive")
! generate_sums = 'yes'
! if opt in ('--checksum', '-c'):
! if generate_sums:
! usage(2, "check-sums and generate-sums are mutually exclusive")
! check_sums = 'yes'
if opt in ('--sumfile', '-s'): md5sum_file = arg
if opt in ('--fetch', '-f'): fetch_files = 'yes'
***************
*** 364,371 ****
--- 368,378 ----
# 2. Check directories are okay up front
+ # also saves time to make sure the checksum file is there
if not os.path.isdir(package_path):
usage(1, "Path to packages <%s> is invalid" % package_path)
if not os.path.isdir(patch_path):
usage(1, "Path to packages <%s> is invalid" % patch_path)
+ if check_sums and not os.path.isfile(md5sum_file):
+ usage(1, "Checksum file <%s> is invalid" % md5sum_file)
# 3. Parse the entity file and see if those entities exist