-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Implementation of working alternatives on pacman #26482
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
base: master
Are you sure you want to change the base?
Conversation
|
Please note that this is a temporary implementation for testing a beta version of Also, here is a PR where pacman packages are collected for all testing - termux-pacman/termux-packages#211 |
b86b6d3 to
ee8b24f
Compare
| TERMUX_PKG_SHA256=61cbd445d1381b4b184bc7c4e2791f07a79f0f2807b7c600399d0d08e8cd28cf | ||
| TERMUX_PKG_REVISION=5 | ||
| TERMUX_PKG_SRCURL=(https://gitlab.archlinux.org/pacman/pacman/-/releases/v${TERMUX_PKG_VERSION}/downloads/pacman-${TERMUX_PKG_VERSION}.tar.xz | ||
| https://github.com/termux-pacman/pacman-switch/archive/refs/heads/main.zip) |
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.
I'm guessing you made this refs/heads/main for testing.
In a final version of this that should be pinned to a specific commit or release tag.
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.
Yes, you got it right. When pacman-switch is fully ready, I'll make a pinned release.
| echo " points=(${LINK[$name]}:${ALTERNATIVE[$name]}${DEPENDENTS[$name]})" | ||
| echo "}" | ||
| done | ||
| } > "${TERMUX_PREFIX_CLASSICAL}/share/pacman-switch/$(basename "${i//.alternatives/.sw}")" |
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.
What's wrong with the .alternatives file extension?
You're parsing those anyway.
Why invent your own ad-hoc plaintext format?
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.
Why invent your own ad-hoc plaintext format?
I did this to make it easier for pacman-switch to retrieve/parse data. Switcher files (.sw) are essentially shell scripts with functions that can be run to retrieve variables with data and then manipulate them immediately.
| ## | ||
| # Parse datas from the alternatives file and put the datas into the variables. | ||
| # . | ||
| # . | ||
| # **Parameters:** | ||
| # `path_to_alternatives_file` - The path to the package's `.alternatives` file. | ||
| # . | ||
| # **Returns:** | ||
| # returns their contents in the associative arrays: | ||
| # ${LINK[@]} ${[ALTERNATIVE[@]} ${DEPENDENTS[@]} ${PRIORITY[@]} | ||
| # . | ||
| # . | ||
| # termux_alternatives__parse_alternatives_file <path_to_alternatives_file> | ||
| ## |
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.
I think the rewritten function comment is overly verbose and loses some of the original information.
I'm also not sure why this got moved to a new function (pseudo-)namespace.
termux_parse_alternatives or termux_parse_alternatives_file should be plenty descriptive.
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.
I needed to move the function to utils so that it could be used not only in termux_step_update_alternatives but also in termux_step_install_switcher_files.
Regarding the function naming and its comments/description, this is a standard for scripts in utils (at least in scripts/utils/termux/). You can ask @agnostic-apollo for more details. Also, take a look at another script with the same standard - https://github.com/termux/termux-packages/blob/master/scripts/utils/termux/package/termux_package.sh
| for name in "${NAME[@]}"; do | ||
| # Not every entry will have dependents in its group | ||
| # but we need to initialize the keys regardless | ||
| : "${DEPENDENTS[$name]:=}" | ||
| done |
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.
Moving this into the function is a good call since it's a concern of the function and shouldn't need to be handled at the callsite.
ee8b24f to
45d8e20
Compare
45d8e20 to
994c3bf
Compare
994c3bf to
caf1ad8
Compare
caf1ad8 to
7493c3a
Compare
For testing