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

feat: Seperate functions for fetching and downloading images #1

Draft
wants to merge 3 commits into
base: fix/channels
Choose a base branch
from

Conversation

muhammad23012009
Copy link
Owner

Signed-off-by: Muhammad [email protected]

@muhammad23012009 muhammad23012009 marked this pull request as draft September 30, 2022 09:30
Copy link
Collaborator

@maciek134 maciek134 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All in all this is still a lot of hardcoded stuff that won't play nice with the installer configs

@@ -17,7 +17,7 @@ data_dir="${data_home}/ubports-installer-cli"

fetch() {
url=${1}
cached="${cache_dir}/${url}"
cached="${cache_dir}/$(basename "${url}")"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break horribly, there is no guarantee the filenames that will be fetched are unique. The cache directory is not supposed to be pretty, having full URLs there doesn't hurt anything.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break horribly, there is no guarantee the filenames that will be fetched are unique. The cache directory is not supposed to be pretty, having full URLs there doesn't hurt anything.

The old one actually breaks worse, for example when it downloads the channels.json from https://system-image.ubports.com, the command manages to separate the link, 'https:' becomes a directory in which '/system-image.ubports.com' exists and then finally comes the channels.json.
And it won't refetch the file anyway, so I don't see how it breaks...?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not breaking, that's the way it's supposed to work and there is nothing wrong with that - like I said, the directory structure is not supposed to be pretty. And what I mean is that you can for example download the channels list for one device, but since you used basename if you try to do it for another it will use the cached one and you will download files for a wrong device.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I see, yeah I see how it breaks now

ubcli.sh Outdated
if [ -z "${latest_images}" ]; then
printf "$(ct 'red' true)ERROR:$(ct 'red') images for device"
printf "$(ct 'orange') ${device}$(ct 'red') on channel"
printf "$(ct 'orange') ${channel}$(ct 'red') not found!"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clear colors after printing (just $(ct))

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clear colors after printing (just $(ct))

Resolved.

file=$(basename "${files}")
fetch_persistent_files "${URL}${files}" "${install_dir}/${file}"
echo "update $file $file.asc" >> "${install_dir}/ubuntu_command"
wget "${URL}${files}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could have used the same logic that's in fetch to choose between wget and curl

echo "format system
$( [ -z ${wipe:+true} ] || echo "format data")
load_keyring image-master.tar.xz image-master.tar.xz.asc
load_keyring image-signing.tar.xz image-signing.tar.xz.asc
mount system" > "${install_dir}/ubuntu_command"
}

fill_ubuntu_command() {
index_url=${1}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

="${1}"

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

="${1}"

Also resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants