Pass destination directory to download_file()

This commit is contained in:
Dor Askayo 2023-01-13 15:47:06 +02:00
parent 693d01dc1b
commit 38e5dfe35b
1 changed files with 8 additions and 8 deletions

View File

@ -3,7 +3,7 @@
This file contains a few functions to be shared by all Sys* classes
"""
# SPDX-FileCopyrightText: 2022 Dor Askayo <dor.askayo@gmail.com>
# SPDX-FileCopyrightText: 2022-2023 Dor Askayo <dor.askayo@gmail.com>
# SPDX-FileCopyrightText: 2021-22 fosslinux <fosslinux@aussies.space>
# SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
# SPDX-License-Identifier: GPL-3.0-or-later
@ -71,18 +71,18 @@ actual: {readable_hash}\n\
When in doubt, try deleting the file in question -- it will be downloaded again when running \
this script the next time")
def download_file(self, url, file_name=None):
def download_file(self, url, directory, file_name=None):
"""
Download a single source archive.
"""
# Automatically determine file name based on URL.
if file_name is None:
file_name = os.path.basename(url)
abs_file_name = os.path.join(self.cache_dir, file_name)
abs_file_name = os.path.join(directory, file_name)
# Create a cache directory for downloaded sources
if not os.path.isdir(self.cache_dir):
os.mkdir(self.cache_dir)
# Create a directory for downloaded file
if not os.path.isdir(directory):
os.mkdir(directory)
# Actually download the file
headers = {
@ -111,9 +111,9 @@ this script the next time")
for line in sources.readlines():
line = line.strip().split(" ")
if len(line) > 2:
path = self.download_file(line[0], line[2])
path = self.download_file(line[0], self.cache_dir, line[2])
else:
path = self.download_file(line[0])
path = self.download_file(line[0], self.cache_dir)
self.check_file(path, line[1])
def make_initramfs(self):