Pass destination directory to download_file()
This commit is contained in:
parent
693d01dc1b
commit
38e5dfe35b
|
@ -3,7 +3,7 @@
|
||||||
This file contains a few functions to be shared by all Sys* classes
|
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-22 fosslinux <fosslinux@aussies.space>
|
||||||
# SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
|
# SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# 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 \
|
When in doubt, try deleting the file in question -- it will be downloaded again when running \
|
||||||
this script the next time")
|
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.
|
Download a single source archive.
|
||||||
"""
|
"""
|
||||||
# Automatically determine file name based on URL.
|
# Automatically determine file name based on URL.
|
||||||
if file_name is None:
|
if file_name is None:
|
||||||
file_name = os.path.basename(url)
|
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
|
# Create a directory for downloaded file
|
||||||
if not os.path.isdir(self.cache_dir):
|
if not os.path.isdir(directory):
|
||||||
os.mkdir(self.cache_dir)
|
os.mkdir(directory)
|
||||||
|
|
||||||
# Actually download the file
|
# Actually download the file
|
||||||
headers = {
|
headers = {
|
||||||
|
@ -111,9 +111,9 @@ this script the next time")
|
||||||
for line in sources.readlines():
|
for line in sources.readlines():
|
||||||
line = line.strip().split(" ")
|
line = line.strip().split(" ")
|
||||||
if len(line) > 2:
|
if len(line) > 2:
|
||||||
path = self.download_file(line[0], line[2])
|
path = self.download_file(line[0], self.cache_dir, line[2])
|
||||||
else:
|
else:
|
||||||
path = self.download_file(line[0])
|
path = self.download_file(line[0], self.cache_dir)
|
||||||
self.check_file(path, line[1])
|
self.check_file(path, line[1])
|
||||||
|
|
||||||
def make_initramfs(self):
|
def make_initramfs(self):
|
||||||
|
|
Loading…
Reference in New Issue