-
Notifications
You must be signed in to change notification settings - Fork 126
Getting termux-tools
ready for apt
3.0.0
#165
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
Conversation
I tested this, and I think it is working for me. There is something strange-looking about the indentation in some places, but I think you might already have noticed, and will be able to resolve that. |
Haven't noticed anything of the sort. |
Oh ok, sure, here is one of them |
That part was already lined up with the line above, it just used spaces instead of tabs for indentation, which doesn't match the rest of the script. |
924edb6
to
8caa682
Compare
There's snapped it back to 3 tabs. |
The problem is also visible in your screenshot, but then you fixed it in a force push so I guess you are now able to see the problem with how it was before |
Then I'm not seeing what you meant. |
I screenshotted your screenshot and drew a line on it, in my opinion the line should be straight BUT it is ok and does not matter very much because:
|
It was aligned with |
Just finished testing the |
|
For some reason that I have not figured out termux-change-repo/pkg empties my .sources files:
|
scripts/pkg.in
Outdated
source "$selected_mirror" | ||
|
||
case "$(has_repo main)" in | ||
'deb822') sed -ni -e "s|URIs:.*|URIs: $MAIN|" "@TERMUX_PREFIX@/etc/apt/sources.list.d/main.sources";; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be better to keep original *.sources in $PREFIX/etc/termux/ (or another suitable place), and then sed -n -e "s|URIs:.*|URIs: $MAIN|" "$some_path" > "@TERMUX_PREFIX@/etc/apt/sources.list.d/main.sources"
. That would make it possible to recover even if *.sources are emptied as in my issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like it is the -n
option that empties the .sources files:
$ cat main.sources
# The main termux repository, with cloudflare cache
Types: deb
URIs: https://mirror.accum.se/mirror/termux.dev/termux-main
Suites: stable
Components: main
Signed-By: /data/data/com.termux/files/usr/etc/apt/trusted.gpg.d/grimler.gpg, /data/data/com.termux/files/usr/etc/apt/trusted.gpg.d/termux-autobuilds.gpg
# The main termux repository, without cloudflare cache
#Types: deb
#URIs: https://mirror.accum.se/mirror/termux.dev/termux-main
#Suites: stable
#Components: main
#Signed-By: /data/data/com.termux/files/usr/etc/apt/trusted.gpg.d/grimler.gpg, /data/data/com.termux/files/usr/etc/apt/trusted.gpg.d/termux-autobuilds.gpg
$ sed -ni -e "s|URIs:.*|URIs: https://mirror.accum.se/mirror/termux.dev/termux-main|" main.sources
$ cat main.sources
[ empty ]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep sorry that was leftover from testing, thought I had already removed those.
-n
disables the implied p
command causing the pattern space to be printed automatically.
I was using it during testing because I using --debug
to step through the sed command.
# ~$ sed --debug -n -e "s/URIs:.*/URIs: testing/" $TERMUX__PREFIX/etc/apt/sources.list.d/main.sources
SED PROGRAM:
s/URIs:.*/URIs: testing/
INPUT: '/data/data/com.termux/files/usr/etc/apt/sources.list.d/main.sources' line 1
PATTERN: # The main termux repository, with cloudflare cache
COMMAND: s/URIs:.*/URIs: testing/
PATTERN: # The main termux repository, with cloudflare cache
END-OF-CYCLE:
INPUT: '/data/data/com.termux/files/usr/etc/apt/sources.list.d/main.sources' line 2
PATTERN: Types: deb
COMMAND: s/URIs:.*/URIs: testing/
PATTERN: Types: deb
END-OF-CYCLE:
INPUT: '/data/data/com.termux/files/usr/etc/apt/sources.list.d/main.sources' line 3
PATTERN: URIs: https://packages-cf.termux.dev/apt/termux-main/
COMMAND: s/URIs:.*/URIs: testing/
MATCHED REGEX REGISTERS
regex[0] = 0-53 'URIs: https://packages-cf.termux.dev/apt/termux-main/'
PATTERN: URIs: testing
END-OF-CYCLE:
INPUT: '/data/data/com.termux/files/usr/etc/apt/sources.list.d/main.sources' line 4
PATTERN: Suites: stable
COMMAND: s/URIs:.*/URIs: testing/
PATTERN: Suites: stable
END-OF-CYCLE:
INPUT: '/data/data/com.termux/files/usr/etc/apt/sources.list.d/main.sources' line 5
PATTERN: Components: main
COMMAND: s/URIs:.*/URIs: testing/
PATTERN: Components: main
END-OF-CYCLE:
INPUT: '/data/data/com.termux/files/usr/etc/apt/sources.list.d/main.sources' line 6
PATTERN: Signed-By: /data/data/com.termux/files/usr/etc/apt/trusted.gpg.d/grimler.gpg, /data/data/com.termux/files/usr/etc/apt/trusted.gpg.d/termux-autobuilds.gpg
COMMAND: s/URIs:.*/URIs: testing/
PATTERN: Signed-By: /data/data/com.termux/files/usr/etc/apt/trusted.gpg.d/grimler.gpg, /data/data/com.termux/files/usr/etc/apt/trusted.gpg.d/termux-autobuilds.gpg
END-OF-CYCLE:
INPUT: '/data/data/com.termux/files/usr/etc/apt/sources.list.d/main.sources' line 7 PATTERN:
COMMAND: s/URIs:.*/URIs: testing/
PATTERN:
END-OF-CYCLE:
INPUT: '/data/data/com.termux/files/usr/etc/apt/sources.list.d/main.sources' line 8
PATTERN: # The main termux repository, without cloudflare cache
COMMAND: s/URIs:.*/URIs: testing/
PATTERN: # The main termux repository, without cloudflare cache
END-OF-CYCLE:
INPUT: '/data/data/com.termux/files/usr/etc/apt/sources.list.d/main.sources' line 9
PATTERN: #Types: deb
COMMAND: s/URIs:.*/URIs: testing/
PATTERN: #Types: deb
END-OF-CYCLE:
INPUT: '/data/data/com.termux/files/usr/etc/apt/sources.list.d/main.sources' line 10
PATTERN: #URIs: https://packages-cf.termux.dev/apt/termux-main/
COMMAND: s/URIs:.*/URIs: testing/
MATCHED REGEX REGISTERS
regex[0] = 1-54 'URIs: https://packages-cf.termux.dev/apt/termux-main/'
PATTERN: #URIs: testing
END-OF-CYCLE:
INPUT: '/data/data/com.termux/files/usr/etc/apt/sources.list.d/main.sources' line 11
PATTERN: #Suites: stable
COMMAND: s/URIs:.*/URIs: testing/
PATTERN: #Suites: stable
END-OF-CYCLE:
INPUT: '/data/data/com.termux/files/usr/etc/apt/sources.list.d/main.sources' line 12
PATTERN: #Components: main
COMMAND: s/URIs:.*/URIs: testing/
PATTERN: #Components: main
END-OF-CYCLE:
INPUT: '/data/data/com.termux/files/usr/etc/apt/sources.list.d/main.sources' line 13
PATTERN: #Signed-By: /data/data/com.termux/files/usr/etc/apt/trusted.gpg.d/grimler.gpg, /data/data/com.termux/files/usr/etc/apt/trusted.gpg.d/termux-autobuilds.gpg
COMMAND: s/URIs:.*/URIs: testing/
PATTERN: #Signed-By: /data/data/com.termux/files/usr/etc/apt/trusted.gpg.d/grimler.gpg, /data/data/com.termux/files/usr/etc/apt/trusted.gpg.d/termux-autobuilds.gpg
END-OF-CYCLE:
scripts/pkg.in
Outdated
source "$selected_mirror" | ||
|
||
case "$(has_repo main)" in | ||
'deb822') sed -ni -e "s|URIs:.*|URIs: $MAIN|" "@TERMUX_PREFIX@/etc/apt/sources.list.d/main.sources";; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like it is the -n
option that empties the .sources files:
$ cat main.sources
# The main termux repository, with cloudflare cache
Types: deb
URIs: https://mirror.accum.se/mirror/termux.dev/termux-main
Suites: stable
Components: main
Signed-By: /data/data/com.termux/files/usr/etc/apt/trusted.gpg.d/grimler.gpg, /data/data/com.termux/files/usr/etc/apt/trusted.gpg.d/termux-autobuilds.gpg
# The main termux repository, without cloudflare cache
#Types: deb
#URIs: https://mirror.accum.se/mirror/termux.dev/termux-main
#Suites: stable
#Components: main
#Signed-By: /data/data/com.termux/files/usr/etc/apt/trusted.gpg.d/grimler.gpg, /data/data/com.termux/files/usr/etc/apt/trusted.gpg.d/termux-autobuilds.gpg
$ sed -ni -e "s|URIs:.*|URIs: https://mirror.accum.se/mirror/termux.dev/termux-main|" main.sources
$ cat main.sources
[ empty ]
I opened a PR: github.com/TomJo2000/pull/2 with fixes for my comments above, and also fixed so it can find current_mirror in deb822 format as well |
b26d819
to
8246af6
Compare
Those changes have been manually merged into |
Thanks! Here's another PR which checks if both main.sources and sources.list exists, and deletes sources.list if main.sources seems to be a valid mirror: TomJo2000#3 |
The way I was gonna handle that is for each |
@TomJo2000 right, that does sound better! |
[ -f "$TERMUX_PREFIX/etc/apt/sources.list.d/{{repo}}.list" ] && {
echo "Legacy repo file found for '{{repo}}' repository."
echo "Migrating sources.list.d/{{repo}}.list to sources.list.d/{{repo}}.sources"
mv -v "$TERMUX_PREFIX"/etc/apt/sources.list.d/{{repo}}.list{,.dpkg-old}
echo "A backup copy of the old {{repo}}.list repo file"
echo "has been saved to $TERMUX_PREFIX/etc/apt/sources.list.d/{{repo}}.list.dpkg-old"
}
( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR looks good to me, I will aim at merging and releasing it tomorrow evening unless there are more questions/comments by then!
We can merge this PR ahead of merging Apt 3.0.1, |
Looks good otherwise. |
8246af6
to
3b2d731
Compare
3b2d731
to
9c60582
Compare
b63cc37
to
7db0105
Compare
scripts/pkg.in
Outdated
sed -i -e "s|URIs:.*|$(sed_escape_replacement "URIs: $ROOT")|" \ | ||
"@TERMUX_PREFIX@/etc/apt/sources.list.d/root.sources" | ||
;; | ||
'legacy') echo "deb $ROOT root stable" > @TERMUX_PREFIX@/etc/apt/sources.list.d/root.list;; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quote.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Derp, yeah missed that one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked and quoted all remaining instances.
https://github.com/termux/termux-tools/compare/7db010555f20e228d8e3d3301c2f93f3070d4e77..aa8327da102febe132be2378a1797e7bb723d21a
7db0105
to
aa8327d
Compare
Needs one more update in update_apt_cache, where we run: |
Co-authored-by: Henrik Grimler <grimler@termux.dev> Co-authored-by: agnostic-apollo <agnosticapollo@gmail.com>
aa8327d
to
eba064d
Compare
Thanks! |
Apt 3.0.0 makes the "multiline"
deb822
format the standard for package sources.This PR aims to introduce support for this repo source format in
termux-tools
.This initial commit only adds support in
pkg
.I plan to add support in
termux-info
tomorrow, however that turned into half a refactor and I'm tired.The changes to
pkg
introduce two possible return values fromhas_repo
.deb822
, the new standard format (determined by the.sources
file extension)legacy
, the old oneline format (determined by the.list
file extension)Support for the legacy oneline
.list
format isn't slated to be removed until 20291,so it is kept for backwards compatibility in the meantime.
""
) indicates that the repo is not present in either format.I also fixed a couple shellcheck warnings and some indentation.
I may do a more extensive refactor of
pkg
as part of this PR later.Footnotes
https://man.archlinux.org/man/sources.list.5#ONE-LINE-STYLE_FORMAT ↩