Code Monkey home page Code Monkey logo

Comments (4)

abysas avatar abysas commented on May 31, 2024 1

@TekWizely, it worked! Was a bit confused how to set and with "add" command, but finally solved that by looking at examples in "help add". Thanks a lot!

from my-alternatives.

TekWizely avatar TekWizely commented on May 31, 2024

Hi @abysas and thanks for taking the time to file an issue.

Q: Are you seeing any specific error(s) on these platforms?

from my-alternatives.

TekWizely avatar TekWizely commented on May 31, 2024

OK so checked out the latest centos via docker and it looks like centos uses an older version of update-alternatives

$ docker run --rm -it centos

# update-alternatives --version
alternatives version 1.13

This version does not suppor the --query command, which my-alternatives relies on for dumping a configuration.

We might be able to modify my-alternatives to support the --display command, which is very similar to the --query command, but it probably won't happen real soon.

In the meantime, I was able to hack-in support via the following technique:

  1. Start with the updated version of the my-alternative script found here:
  2. initialize your shell
$ eval "$(my-alternatives init)"
  1. Confirm your alternatives configuration directory
$ echo $MY_ALTS_HOME

/home/user/.config/my-alternatives
  1. Manually copy over any alternatives you're interested in customizing.
    In my docker image, the system db is stored in : /var/lib/alternatives
$ cp /var/lib/alternatives/<name> $MY_ALTS_HOME/admin/
...
  1. Manually edit the newly-copied config to make the links relative to your configuration. The links are the generic names that the alternative group provides (i.e /usr/bin/pager) and NOT the actual binary that the specific alternatives provide (i.e /usr/bin/more, /usr/bin/less, etc). For binaries, make them relative to $MY_ALTS_HOME/bin. for man pages, make them relative to $MY_ALTS_HOME/man.
    For this example, I'll be using ld which is the only alternative that had multiple options in my centos docker image.
$ diff /var/lib/alternatives/ld $MY_ALTS_HOME/admin/ld

2c2
< /usr/bin/ld
---
> /home/user/.config/my-alternatives/bin/ld
  1. Create the base symlink within the configuration
$ ln -s $MY_ALTS_HOME/bin/<name> $MY_ALTS_HOME/alts/<name>

From here, you can configure your alternative. Again I'll use ld for this example

$ my-alternatives select ld

There are 2 programs which provide 'ld'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/bin/ld.bfd
   2           /usr/bin/ld.gold

Enter to keep the current selection[+], or type selection number: 

I hope that helps - give it a try and let me know.

-TW

from my-alternatives.

TekWizely avatar TekWizely commented on May 31, 2024

UPDATE: After further research I realized I was wrong about the RedHat version being "older".
It's actually a completely separate implementation with slightly different features.

I was also wrong about being able to use --display as a substitute for --query - Turns out the display output doesn't contain enough information to fully build an --install command.

So I decided to take a try at reading the admin file directly, which is definitely a hack since its not part of the public API.

I got it working though!

If you would be so kind as to download the my-alternatives-redhat script in #3 and give it a try !

good luck and please lemme know how it gos,

-TW

from my-alternatives.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.