Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raspbmirror: add --nosources option #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion raspbmirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@

parser.add_argument("--nolock", help="don't try to lock the target directory", action="store_true")

parser.add_argument("--nosources", help="don't try to mirror source packages", action="store_true")

args = parser.parse_args()

if not args.nolock:
Expand Down Expand Up @@ -389,6 +391,11 @@ def testandreporthash(sha256hash, sha256, errorprefix, path, errorsuffix):
return True


def issourcespath(path):
pathsplit = path.split(b'/')
return (b'dists' in pathsplit) and (pathsplit[-1] in (b'extrasources', b'Sources', b'Sources.gz', b'Sources.xz'))


if (args.mdurl is None) or (args.mdurl.upper() == 'NONE'):
mdurl = None
else:
Expand Down Expand Up @@ -468,7 +475,7 @@ def opengu(filepath):
(filedata,ts) = geturl(fileurl)

f = open(makenewpath(b'snapshotindex.txt'),'wb')
if (args.tlwhitelist is None) and (args.distswhitelist is None):
if (args.tlwhitelist is None) and (args.distswhitelist is None) and (not args.nosources):
f.write(filedata)
else:
lines = filedata.split(b'\n')
Expand Down Expand Up @@ -516,6 +523,20 @@ def opengu(filepath):
for toplevel,distribution in missingesdists:
print((b'missing extra sources file for '+toplevel+b'/dists/'+distribution).decode('ascii'))
sys.exit(1)
if args.nosources:
linesnew = []
for line in lines:
path, sizeandsha = line.split(b' ')
pathsplit = path.split(b'/')
if issourcespath(path):
pass
elif (len(pathsplit) > 1) and pathsplit[1] == b'pool':
pass
else:
linesnew.append(line)

lines = linesnew

for line in lines:
f.write(line+b'\n')
f.close()
Expand Down Expand Up @@ -590,6 +611,8 @@ def opengu(filepath):
#if filename in knownfiles:
# if files
#print(filename)
if args.nosources and issourcespath(filename):
continue
addfilefromdebarchive(knownfiles,filequeue,filename,linesplit[0],linesplit[1]);
else:
insha256 = False
Expand Down