Skip to content
New issue

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

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

Already on GitHub? # to your account

implement apt-transport-mirror handling #168

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Artoria2e5
Copy link

close #88

@Artoria2e5 Artoria2e5 force-pushed the mirror-uri branch 2 times, most recently from 6350f41 to feeadc3 Compare September 19, 2019 18:16
Copy link
Collaborator

@Lasall Lasall left a comment

Choose a reason for hiding this comment

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

This looks really good, thank you! I haven't applied and tried the patch, I think it doesn't work with a more complex mirror list (apt >= 1.6, see the apt-transport-mirror manpage) but imho a basic support is better than none.

The new mirrorlist variable is $MIRRORLIST.

The cleanup_dllist function is now refactored to accept some arguments.
The refactoring was intended for MIRRORLIST, but it then occurred to me
that it was not meant for persistence anyway. So now it gets
insta-deleted without need for a cleanup function.

TMP_ variables previously used a pretty maintaience-heavy way to be
assigned. I changed it to use the "nameref" magic in bash. Basically
these variables are read/write proxies to some other variables.
@Artoria2e5
Copy link
Author

Alright. It does work on my end now. The grep regex is quite complicated now, but well that's what it takes...

@Artoria2e5
Copy link
Author

Got a seven-year-old bug fixed too.

@Artoria2e5 Artoria2e5 force-pushed the mirror-uri branch 2 times, most recently from 43233be to 8fe8ffc Compare November 25, 2019 08:44
The value was not updating because it was already evaluated at assign-
time. To make it always update we need to make it a function call.
@Artoria2e5 Artoria2e5 requested a review from Lasall February 18, 2020 04:35
@Lasall Lasall self-assigned this Apr 6, 2020
Copy link
Collaborator

@Lasall Lasall left a comment

Choose a reason for hiding this comment

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

I've looked over everything, one challenge I see is that this solution requires the MIRRORS variable to be set alongside the apt-transport-mirror setup. Otherwise only the first mirror from that list is picked.

I would suggest to split the shadowing thing up from the rest so we can merge the other chunk where only minimal changes are needed. I also really love the fixes and improvements you did along the way. Thank you!

# I heard that people call this "variable shadowing."
declare -n this="$1" tmpthis="TMP_$1"
tmpthis="${this-${TMP_RANDOM}}"
sudo_exports+=("TMP_$1=$tmpthis")
Copy link
Collaborator

Choose a reason for hiding this comment

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

needs to be without TMP_: sudo_exports+=("$1=$tmpthis")

Copy link
Author

Choose a reason for hiding this comment

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

I don't think so. There is a for i in "${shadowvars[@]}" part explicitly designed to unpack the TMP_ prefixed variables.

Copy link
Collaborator

@Lasall Lasall Aug 25, 2021

Choose a reason for hiding this comment

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

Just test to overwrite any of the variables via command line (e.g. _APTMGR). (Remove TMP_ to support cmd var precedence)


local mirrors
mapfile -t mirrors < "$mirrorfile"
[ -f "MIRRORLIST" ] && rm -f "$MIRRORLIST"
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing $MIRRORLIST

Copy link
Author

Choose a reason for hiding this comment

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

What...?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The dollar sign was missing.

Copy link
Author

Choose a reason for hiding this comment

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

!!!

Suggested change
[ -f "MIRRORLIST" ] && rm -f "$MIRRORLIST"
[ -f "$MIRRORLIST" ] && rm -f "$MIRRORLIST"

@Lasall
Copy link
Collaborator

Lasall commented Apr 7, 2020

I tested the apt-transport-mirror with following configuration:

Sources list:

deb mirror+file:/etc/apt/mirrorlist unstable main non-free contrib
deb-src mirror+file:/etc/apt/mirrorlist unstable main non-free contrib
deb mirror+http://127.0.0.1/mirrorlist experimental main non-free contrib
deb-src mirror+http://localhost/mirrorlist experimental main non-free contrib

The local(host) mirrorlist(s):

http://deb.debian.org/debian/
http://ftp.de.debian.org/debian/

@Lasall
Copy link
Collaborator

Lasall commented Apr 7, 2020

I tested the shadowing with following test cases:

./apt-fast install "firefo*"  # should expand
_APTMGR="foo bar" ./apt-fast install firefox

@Lasall Lasall removed their assignment Mar 19, 2021
@haidarns
Copy link

Hi, any update for this PR? or issue #88 ?

Copy link
Collaborator

@Lasall Lasall left a comment

Choose a reason for hiding this comment

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

README requires new entry to MIRRORLIST in config file.

Copy link
Collaborator

@Lasall Lasall left a comment

Choose a reason for hiding this comment

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

A few minor changes required. Mainly to fix the automatic sudo and cmd vars.

@@ -101,6 +104,14 @@
#DLLIST=/tmp/apt-fast.list


# Mirror listfile
# This determines where temporary resolutions for the mirror:// url is stored.
Copy link
Collaborator

Choose a reason for hiding this comment

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

url are stored

ftp_proxy="$TMP_ftp_proxy" \
http_proxy="$TMP_http_proxy" \
https_proxy="$TMP_https_proxy" \
exec sudo "${sudo_exports[@]}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing '\' at end of line

# I heard that people call this "variable shadowing."
declare -n this="$1" tmpthis="TMP_$1"
tmpthis="${this-${TMP_RANDOM}}"
sudo_exports+=("TMP_$1=$tmpthis")
Copy link
Collaborator

@Lasall Lasall Aug 25, 2021

Choose a reason for hiding this comment

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

Just test to overwrite any of the variables via command line (e.g. _APTMGR). (Remove TMP_ to support cmd var precedence)

Repository owner deleted a comment Nov 17, 2022
Repository owner deleted a comment Dec 8, 2022
Repository owner locked as spam and limited conversation to collaborators Dec 8, 2022
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants