mirror of
https://github.com/tuna/tunasync-scripts.git
synced 2025-04-19 11:42:43 +00:00
Merge fb4e67d502482b2d89bef00424640d9484d56b15 into 45385e1bf522101cddcc8a9be0ba436a717d8265
This commit is contained in:
commit
46a0334542
11
apt-sync.py
11
apt-sync.py
@ -143,6 +143,7 @@ def apt_mirror(
|
||||
arch: str,
|
||||
dest_base_dir: Path,
|
||||
deb_set: Dict[str, int],
|
||||
skip_checksum: bool
|
||||
) -> int:
|
||||
if not dest_base_dir.is_dir():
|
||||
print("Destination directory is empty, cannot continue")
|
||||
@ -229,7 +230,7 @@ def apt_mirror(
|
||||
)
|
||||
pkgidx_file.unlink()
|
||||
continue
|
||||
if hashlib.sha256(content).hexdigest() != checksum:
|
||||
if not skip_checksum and hashlib.sha256(content).hexdigest() != checksum:
|
||||
print(
|
||||
f"Invalid checksum of {pkgidx_file}, expected {checksum}, skipped"
|
||||
)
|
||||
@ -331,7 +332,7 @@ def apt_mirror(
|
||||
with dest_tmp_filename.open("rb") as f:
|
||||
for block in iter(lambda: f.read(1024**2), b""):
|
||||
sha.update(block)
|
||||
if sha.hexdigest() != pkg_checksum:
|
||||
if not skip_checksum and sha.hexdigest() != pkg_checksum:
|
||||
print(f"Invalid checksum of {dest_filename}, expected {pkg_checksum}")
|
||||
dest_tmp_filename.unlink()
|
||||
continue
|
||||
@ -383,6 +384,8 @@ def main():
|
||||
action="store_true",
|
||||
help="print package files to be deleted only",
|
||||
)
|
||||
parser.add_argument("--skip-checksum", action='store_true',
|
||||
help='skip checksum validation')
|
||||
args = parser.parse_args()
|
||||
|
||||
# generate lists of os codenames
|
||||
@ -420,7 +423,7 @@ def main():
|
||||
for arch in arch_list:
|
||||
if (
|
||||
apt_mirror(
|
||||
args.base_url, os, comp, arch, args.working_dir, deb_set=deb_set
|
||||
args.base_url, os, comp, arch, args.working_dir, deb_set=deb_set, skip_checksum=args.skip_checksum
|
||||
)
|
||||
!= 0
|
||||
):
|
||||
@ -438,4 +441,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
Loading…
x
Reference in New Issue
Block a user