Lines 7-12
Link Here
|
7 |
from stat import * |
7 |
from stat import * |
8 |
from commands import * |
8 |
from commands import * |
9 |
from select import * |
9 |
from select import * |
|
|
10 |
from output import * |
10 |
import string,os,types,sys,shlex,shutil,xpak,fcntl,signal,time,missingos,cPickle,atexit,grp |
11 |
import string,os,types,sys,shlex,shutil,xpak,fcntl,signal,time,missingos,cPickle,atexit,grp |
11 |
|
12 |
|
12 |
#Secpass will be set to 1 if the user is root or in the wheel group. |
13 |
#Secpass will be set to 1 if the user is root or in the wheel group. |
Lines 810-815
Link Here
|
810 |
#interrupted by signal |
811 |
#interrupted by signal |
811 |
return 16 |
812 |
return 16 |
812 |
|
813 |
|
|
|
814 |
def fetchsize(myuris,humanread): |
815 |
"get the amount remaing to fetch files. Will not work in digest file doesn't exist." |
816 |
digestfn=settings["FILESDIR"]+"/digest-"+settings["PF"] |
817 |
if not os.path.exists(digestfn): |
818 |
print "Digest file", digestfn, " doesn't exist. Aborting" |
819 |
return -1; |
820 |
myfile=open(digestfn,"r") |
821 |
mylines=myfile.readlines() |
822 |
mydigests={} |
823 |
# Parse digest file |
824 |
for x in mylines: |
825 |
myline=string.split(x) |
826 |
if len(myline)<4: |
827 |
#invalid line |
828 |
print "!!! The digest",digestfn,"appears to be corrupt. Aborting." |
829 |
return -1 |
830 |
try: |
831 |
mydigests[myline[2]]={"md5":myline[1],"size":string.atol(myline[3])} |
832 |
except ValueError: |
833 |
print "!!! The digest",digestfn,"appears to be corrupt. Aborting." |
834 |
return -1 |
835 |
|
836 |
totalsize=0 |
837 |
for myuri in myuris: |
838 |
myfile=os.path.basename(myuri) |
839 |
# Check how much we need to download of myfile |
840 |
if not mydigests.has_key(myfile): |
841 |
print "Digest file missing entry for ", myfile, "Try updating it." |
842 |
return -1 |
843 |
filesize=mydigests[myfile]["size"]; |
844 |
try: |
845 |
mystat=os.stat(settings["DISTDIR"]+"/"+myfile) |
846 |
size=filesize - mystat[ST_SIZE]-filesize |
847 |
if(size > 0): |
848 |
totalsize+=size |
849 |
except (OSError,IOError),e: |
850 |
totalsize += filesize |
851 |
if(humanread): |
852 |
print "Requires "+humansize(totalsize)+" fetching." |
853 |
else: |
854 |
return totalsize |
855 |
|
856 |
|
813 |
def fetch(myuris): |
857 |
def fetch(myuris): |
814 |
"fetch files. Will use digest file if available." |
858 |
"fetch files. Will use digest file if available." |
815 |
if ("mirror" in features) and ("nomirror" in settings["RESTRICT"].split()): |
859 |
if ("mirror" in features) and ("nomirror" in settings["RESTRICT"].split()): |
Lines 1058-1064
Link Here
|
1058 |
return unmerge(settings["CATEGORY"],settings["PF"],myroot) |
1102 |
return unmerge(settings["CATEGORY"],settings["PF"],myroot) |
1059 |
|
1103 |
|
1060 |
if mydo not in ["help","clean","prerm","postrm","preinst","postinst","config","touch","setup", |
1104 |
if mydo not in ["help","clean","prerm","postrm","preinst","postinst","config","touch","setup", |
1061 |
"depend","fetch","digest","unpack","compile","install","rpm","qmerge","merge","package"]: |
1105 |
"depend","fetch","fetchsize","pfetchsize","digest","unpack","compile","install","rpm","qmerge","merge","package"]: |
1062 |
print "!!! Please specify a valid command." |
1106 |
print "!!! Please specify a valid command." |
1063 |
return 1 |
1107 |
return 1 |
1064 |
|
1108 |
|
Lines 1102-1107
Link Here
|
1102 |
fetchme=newuris |
1146 |
fetchme=newuris |
1103 |
checkme=alist |
1147 |
checkme=alist |
1104 |
|
1148 |
|
|
|
1149 |
if mydo == "fetchsize": |
1150 |
return fetchsize(fetchme, 1) |
1151 |
if mydo == "pfetchsize": |
1152 |
return fetchsize(fetchme, 0) |
1153 |
|
1105 |
if not fetch(fetchme): |
1154 |
if not fetch(fetchme): |
1106 |
return 1 |
1155 |
return 1 |
1107 |
|
1156 |
|