Skip to content

Conversation

@Maxython
Copy link
Member

For testing

@robertkirkman robertkirkman self-requested a review September 15, 2025 16:06
@Maxython
Copy link
Member Author

Please note that this is a temporary implementation for testing a beta version of pacman-switch.

Also, here is a PR where pacman packages are collected for all testing - termux-pacman/termux-packages#211

@Maxython Maxython force-pushed the alternatives-for-pacman branch 7 times, most recently from b86b6d3 to ee8b24f Compare September 19, 2025 22:51
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)
Copy link
Member

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.

Copy link
Member Author

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}")"
Copy link
Member

@TomJo2000 TomJo2000 Sep 19, 2025

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?

Copy link
Member Author

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.

Comment on lines +8 to +21
##
# 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>
##
Copy link
Member

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.

Copy link
Member Author

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

Comment on lines -43 to -47
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
Copy link
Member

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.

@Maxython Maxython force-pushed the alternatives-for-pacman branch from ee8b24f to 45d8e20 Compare September 25, 2025 12:15
@Maxython Maxython force-pushed the alternatives-for-pacman branch from 45d8e20 to 994c3bf Compare September 26, 2025 07:26
@Maxython Maxython force-pushed the alternatives-for-pacman branch from 994c3bf to caf1ad8 Compare October 2, 2025 11:18
@Maxython Maxython force-pushed the alternatives-for-pacman branch from caf1ad8 to 7493c3a Compare October 2, 2025 16:41
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.

4 participants