OpenCSW Bug Tracker


Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0004559 [alternatives] regular use major always 2010-09-30 15:47 2013-08-25 13:58
Reporter jh View Status public  
Assigned To phil
Priority normal Resolution fixed  
Status closed  
Summary 0004559: --set does not work
Description during testing the new apache2 package I wanted to change the alternative:

/opt/csw/sbin/alternatives --display httpd
Installed alternatives for httpd are:
/opt/csw/apache2/sbin/httpd httpd /opt/csw/apache2/sbin/httpd.prefork 100
/opt/csw/apache2/sbin/httpd httpd /opt/csw/apache2/sbin/httpd.worker 50


/opt/csw/sbin/alternatives --set httpd /opt/csw/apache2/sbin/httpd.worker

ln: cannot create /etc/opt/etc/alternatives/httpd: No such file or directory
Additional Information
Tags No tags attached.
Attached Files

- Relationships

-  Notes
(0008319)
phil (reporter)
2010-10-02 18:22

Ah.. presuming you are reporting on an issue with TEST packages of apache2
(since the officially released versions of them do not use 'alternatives'), and since you had other issues with the 'alternatives' package due to your zone usage, I am going to close this bug, as probably invalid.
(it is entirely possible it is an issue with the test apache packages rather than 'alternatives')

If you discover a problem with officially released packages, please open a new bug, with details.

Thanks,
Philip
(0008321)
bwalton (administrator)
2010-10-02 18:25

This bug is _most definitely NOT_ invalid. Notice that the path where alternatives looks for info is /etc/opt/etc/alternatives instead of /etc/opt/csw/altenatives.

When that path correction is made, the alternatives command _still_ fails because nothing has created that directory.

Then, when the directory is created, the alternatives command fails because something calls an internal function with the wrong number of arguments.

This will be a showstopper for the pending apache2 refresh...

Thanks
-Ben
(0008324)
phil (reporter)
2010-10-02 20:00

woopsie.. yes I closed this prematurely.
The good news is, I was coming back to mention that I noticed the error of my ways while coding other stuff, and this is also fixed in the release I'm making this weekend :)

Please poke at the version in my "experimental" area.
(0008328)
bwalton (administrator)
2010-10-03 03:36

Poked and failed.

--snip--

[ verifying class <none> ]
Registering 'httpd' alternative /opt/csw/apache2/sbin/httpd.prefork ...
ERROR: set_link needs 3 arguments
/opt/csw/sbin/alternatives[54]: shift: bad number
Registering 'httpd' alternative /opt/csw/apache2/sbin/httpd.worker ...
ERROR: set_link needs 3 arguments
/opt/csw/sbin/alternatives[54]: shift: bad number

--snip--

It's actually worse now, as before the registration worked, you just couldn't manually set the preferred link. :(
(0008329)
bwalton (administrator)
2010-10-03 04:06

A further update: When the original bungled --set data was removed (by using --auto), a subsequent installation proceeded normally. So, the changes made earlier are likely good, but further error checks may be required in there somewhere?
(0008330)
bwalton (administrator)
2010-10-03 04:14

Another update. It's still broken:


# alternatives --display httpd
Installed alternatives for httpd are:
/opt/csw/apache2/sbin/httpd httpd /opt/csw/apache2/sbin/httpd.prefork 100
/opt/csw/apache2/sbin/httpd httpd /opt/csw/apache2/sbin/httpd.worker 50

# alternatives --set httpd /opt/csw/apache2/sbin/httpd.worker
ERROR: set_link needs 3 arguments
/opt/csw/sbin/alternatives[54]: shift: bad number

This is the same error I noted earlier (found after fixing path and forcing directory creation).
(0008332)
phil (reporter)
2010-10-03 08:16

"works for me"(with mutt).

$ pfexec ./alternatives --set mutt /opt/csw/bin/mutt-ncurses
phil@opensolaris:~$ echo $?
0



Given that apache2 is a NEW package, that was not using alternatives before, dont you think its possible the bug is in your implementation of the interface to the alternatives program, rather than in the alternatives program itself?
(0008333)
phil (reporter)
2010-10-03 08:22

btw: you might try setting "DEBUG=echo" in your environment, and running it again, to see what set_link is getting called with.
(0008334)
bwalton (administrator)
2010-10-03 14:26

I added an extra debugging line too to print the content of $line just before the set_link call.

The altneratives stuff is pretty stock. I used the built in GAR support for this and have a file /opt/csw/share/altneratives/apache2 containing:

# cat /opt/csw/share/alternatives/apache2
/opt/csw/apache2/sbin/httpd httpd /opt/csw/apache2/sbin/httpd.prefork 100
/opt/csw/apache2/sbin/httpd httpd /opt/csw/apache2/sbin/httpd.worker 50


This is, afaik, a valid file. Both altnernatives are being shipped in the same package, so the altnatives file has 2 lines. Anyway, I still think alternatives is doing something wrong here...debug output:

# DEBUG=echo alternatives --set httpd /opt/csw/apache2/sbin/httpd.worker
found match for httpd: /opt/csw/share/alternatives/apache2
set_alternative called with httpd
line is: /opt/csw/apache2/sbin/httpd httpd /opt/csw/apache2/sbin/httpd.prefork 100 /opt/csw/apache2/sbin/httpd httpd /opt/csw/apache2/sbin/httpd.worker 50
set_link called with: /opt/csw/apache2/sbin/httpd httpd /opt/csw/apache2/sbin/httpd.prefork
removing symlink /opt/csw/apache2/sbin/httpd
linking /opt/csw/apache2/sbin/httpd to /opt/csw/apache2/sbin/httpd.prefork
set_link called with: /opt/csw/apache2/sbin/httpd httpd /opt/csw/apache2/sbin/httpd.worker
removing symlink /opt/csw/apache2/sbin/httpd
linking /opt/csw/apache2/sbin/httpd to /opt/csw/apache2/sbin/httpd.worker
set_link called with: 50
ERROR: set_link needs 3 arguments
/opt/csw/sbin/alternatives[55]: shift: bad number
(0008335)
phil (reporter)
2010-10-03 17:07

This is looking like a bug in your package.
From the output, I'm guessing you have the same line, in multiple "alternatives" files. This is incorrect configuration.
Each file in /opt/csw/share/alternatives, must have unique content
(0008336)
phil (reporter)
2010-10-03 17:36

Hmm.. on second thought, the joined output is not duplicate, so it cant be a "same line multiple times" problem. But I'm not seeing how the script itself could be joining lines otherwise.
(0008337)
phil (reporter)
2010-10-03 17:48

awwright, I finally went and took your apache2 package, and grabbed the one alternatives config file. I see the same problem output you do.
so I'm poking at it.
(0008338)
phil (reporter)
2010-10-03 18:04

Okay, I've realized the issue now.
my implementation presumes that, since the "alternatives" file format allows for "slave" addons to the end of the line, that each alternatives definition file, has exactly one line.
That may or may not be a reasonable presumption to make. I havent decided.
But you'll note that other stuff that we have, acts in that manner.
there is

/opt/csw/share/alternatives/mutt_ncurses
/opt/csw/share/alternatives/mutt_slang

It's unfortunate that we have lots of old legacy GAR support and documentation, that was left around from OTHER implementations of "alternatives", so that may have lead you astray here.

A quick fix for you, Ben, would be for you to split up your two lines, into two files.
I'm not sure how long it will take me to figure out multi-line-per-file support cleanly.
(0008339)
phil (reporter)
2010-10-03 18:45

Yah, I've now spent some "quality time" with the code.
It CAN handle multiple lines in the configs.. but only for DIFFERENT programs.
If you put multiple entries for the same program, in the same file, it will be unhappy.
(0008340)
dam (administrator)
2010-10-03 23:02

GAR currently writes at most one file per package to the location
  /opt/csw/share/alternatives/<catalogname>
I see no reason why there should be more than one file per package. Nonetheless multiple options per package is a valid usecase.
(0008341)
phil (reporter)
2010-10-04 00:37

It is just a curent implementation detail of GAR, that it only writes one "alternatives" file per package. It could be modified to do otherwise.
Similarly, the current alternatives implementation "could be modified" to do otherwise, but that would take a whole lot of thinking about design, and then quite a bit of coding, to make it happen.
I'm guessing the GAR modification would be fairly easy.

I will not have time to do further modification to the 'alternatives' program, for at least another two weeks.

I find this whole thing rather odd to start with, having the two apache binaries merged into the top package.
If you split off the different apache implementations into separate packages, (or at least the uncommon one) like we previously had, then this whole "problem" becomes moot. And it would add functionality to the user. there's no reason for them to download a binary (the lower-priority "alternative") and have it laying around, if they are never going to use it.
(0008343)
bwalton (administrator)
2010-10-04 02:17

--snip--
It's unfortunate that we have lots of old legacy GAR support and documentation, that was left around from OTHER implementations of "alternatives", so that may have lead you astray here.
--snip--

I'd actually say it's more unfortunate that the rewrite of alternatives doesn't handle what the original version did. :)

I also agree with Dago here. Splitting the httpd.* files made sense previously as we had postinstall scripts that handled swapping things around. Given that this is the perfect use case for alternatives, there is no real need for a secondary package (aside from the issue James noted) at this point.

I _can_ deliver httpd.worker in ap2_worker for now, but I'm still going to expect that you fix alternatives properly in the long run.
(0010542)
pfelecan (manager)
2013-08-25 13:58

So old that I think this can be closed. If I'm wrong, please re-open it.


Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker