Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
mithatOffline
Post subject: apter: easier aptosid package management  PostPosted: 15.12.2011, 19:32



Joined: 2011-12-15
Posts: 23

Status: Offline
I've been very tempted to adopt aptosid (replacing my Debian testing installs), but I've remained reluctant mostly because of the somewhat cumbersome way that package management needs to be handled in aptosid. To that end, tonight I wrote a script to streamline the process for "recognize rather than memorize" idiots like me. I am currently testing it on a sample aptosid install, and I'm thinking that other users (and users yet to come?) may have use for it. I call it 'apter'.

I have posted the code to http://paste.kde.org/159602/. It requires gxmessage -- I hope that doesn't offend KDE purists too deeply.

The script behaves differently depending on whether it's called by a user or by root. This reduces the number of commands that the user needs to memorize to one. I'm assuming that it's installed in /usr/local/bin. It's used as follows:

  • As a regular user logged into an X session, start 'apter'.
  • In the window that appears, enter the names of the packages you want to add to your system separated with spaces. (Note: You can copy&&paste package names from synaptic, a Web browser, etc.)
  • Click OK. (Note: When you click OK, the names you entered will be written to a temp file.)
  • A window appears that tells you what you need to do next to complete the process; namely it instructs you to:
    1. Type 'Ctl-Alt-F1'.
    2. Login as root.
    3. Enter the 'apter' command and follow the prompts.

When you run the 'apter' command as root, it:

  • Goes into textmode ('init 3')
  • Asks you if you want to update.
  • Asks you if you want to upgrade.
  • Asks you if you want to install the packages whose names you wrote to the temp file above.
  • Tells you what you need to do to restart X (i.e., 'init 5 && exit').

Since I'm not an apt or aptosid genius -- or any kind of genius for that matter -- I would really appreciate it if someone with more expertise had a look at the do_root function in the script to verify that there isn't anything really evil in there.

Ideally, the script in root mode should prevent execution unless the user 'Ctl-Alt-F1'ed first -- but I've yet to figure out if there's a way to figure that out.

Cheers,
-Mithat
 
 View user's profile Send private message  
Reply with quote Back to top
DonKultOffline
Post subject: RE: apter: easier aptosid package management  PostPosted: 15.12.2011, 20:09
Team Member


Joined: 2010-09-02
Posts: 481

Status: Offline
There is really no need to leave X just to install a package or two. All the manual says is that you should do a dist-upgrade only out-of-X (aka 'init 3').

Further more your script doesn't do a 'apt-get update' - so you do it manual or what? - and instead a 'apt-get upgrade' which the manual discourages…

In the end, i would not automate such a simple task given that automation usually leads to a more sloppy user-behavior and that is exactly what you don't want as we require users to think about and after that confirm the 'apt-get dist-upgrade' question. Not just confirm it because it's the fourth question in a series of questions you usually press confirm anyway…

_________________
MfG. DonKult
"I never make stupid mistakes. Only very, very clever ones." ~ The Doctor
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
mithatOffline
Post subject: Re: RE: apter: easier aptosid package management  PostPosted: 15.12.2011, 20:49



Joined: 2011-12-15
Posts: 23

Status: Offline
      DonKult wrote:
There is really no need to leave X just to install a package or two.


Under the heading "Installing a new package", the manual states, "Upgrading packages and installing new packages without stopping X can cause problems. Any method of installing packages under X has this problem. ... If you are in any doubt ensure you leave X as per the dist-upgrade instructions before installing any packages."

      DonKult wrote:
Further more your script doesn't do a 'apt-get update'


Thanks for catching that! Line 102 should be 'apt-get update'. (Note the question asked on line 100.)

      DonKult wrote:
we require users to think about and after that confirm the 'apt-get dist-upgrade' question. Not just confirm it because it's the fourth question in a series of questions you usually press confirm anyway…


Isn't doing regular and frequent dist-upgrades a part of standard hygiene? I'm in the process of adding a "Show upgrade warnings" button to the user ui to (1) remind users to check and (2) make it easy to check for those problems.

If doing frequent and non-deeply-introspective dist-upgrades is really an issue, it's easy enough to make it default to 'no'.
 
 View user's profile Send private message  
Reply with quote Back to top
DonKultOffline
Post subject: Re: RE: apter: easier aptosid package management  PostPosted: 15.12.2011, 21:40
Team Member


Joined: 2010-09-02
Posts: 481

Status: Offline
      mithat wrote:
      DonKult wrote:
There is really no need to leave X just to install a package or two.


Under the heading "Installing a new package", the manual states, "Upgrading packages and installing new packages without stopping X can cause problems. Any method of installing packages under X has this problem. ... If you are in any doubt ensure you leave X as per the dist-upgrade instructions before installing any packages."


The keyword here is 'can' and what you generously hide in '...'. Specifically the "As long as any package you want to install will not upgrade additional packages then it is safe to install it without stopping X." If you dist-upgrade only once in a blue moon, a new KDE version is incoming, you want to upgrade kmail alone, yeap, that can cause trouble, but installing a leaf package like a game or some productive application is fair game…

Oh and for the record: You should have done all that already in testing and/or stable. See the official releasenotes for debian squeeze for an example:
http://www.debian.org/releases/squeeze/ ... eparations

_________________
MfG. DonKult
"I never make stupid mistakes. Only very, very clever ones." ~ The Doctor
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
mithatOffline
Post subject: Re: RE: apter: easier aptosid package management  PostPosted: 15.12.2011, 22:47



Joined: 2011-12-15
Posts: 23

Status: Offline
      DonKult wrote:
You should have done all that already in testing and/or stable.


Thanks for the heads up.
 
 View user's profile Send private message  
Reply with quote Back to top
detaosOffline
Post subject: RE: Re: RE: apter: easier aptosid package management  PostPosted: 16.12.2011, 00:23
Team Member


Joined: 2010-08-26
Posts: 166
Location: floating in the ether
Status: Offline
As a KDE user and a Qt developer, I felt it was important for you to know that I am deeply offended by your use of gxmessage Wink

_________________
#aptosid-art ftw!
(what would cleary do?)
 
 View user's profile Send private message Send e-mail Visit poster's website  
Reply with quote Back to top
mithatOffline
Post subject: Re: RE: Re: RE: apter: easier aptosid package management  PostPosted: 16.12.2011, 00:41



Joined: 2011-12-15
Posts: 23

Status: Offline
      detaos wrote:
As a KDE user and a Qt developer, I felt it was important for you to know that I am deeply offended by your use of gxmessage Wink


Smile If there turns out to be a safe and useful way to do something along these lines, I was thinking of splitting the "user" side off as a Qt app. That should make almost everyone happy.
 
 View user's profile Send private message  
Reply with quote Back to top
ghstryderOffline
Post subject: RE: Re: RE: Re: RE: apter: easier aptosid package management  PostPosted: 17.12.2011, 02:36



Joined: 2010-09-12
Posts: 93
Location: Detroit
Status: Offline
I've often wished that we had someone around here that understands that whole apt thing. Very Happy
 
 View user's profile Send private message  
Reply with quote Back to top
DeepDayzeOffline
Post subject: RE: Re: RE: Re: RE: apter: easier aptosid package management  PostPosted: 17.12.2011, 03:30



Joined: 2010-09-11
Posts: 616
Location: USA
Status: Offline
Nice script and quite promising...I'll see if I can spend some time with it and let you know of any other bugs that might pop up.
 
 View user's profile Send private message  
Reply with quote Back to top
DonKultOffline
Post subject: Re: RE: Re: RE: Re: RE: apter: easier aptosid package manage  PostPosted: 17.12.2011, 09:41
Team Member


Joined: 2010-09-02
Posts: 481

Status: Offline
      ghstryder wrote:
I've often wished that we had someone around here that understands that whole apt thing. Very Happy

Be careful what you wish for, you just might get it. Wink

_________________
MfG. DonKult
"I never make stupid mistakes. Only very, very clever ones." ~ The Doctor
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
mithatOffline
Post subject: RE: Re: RE: Re: RE: Re: RE: apter: easier aptosid package ma  PostPosted: 17.12.2011, 10:33



Joined: 2011-12-15
Posts: 23

Status: Offline
Latest version is at http://paste.kde.org/174836/. Changes:

* bugfix: in root mode, update option now actually updates
* change: in root mode, script will continue only iff root is the sole user
* change: in root mode, dist-upgrade option now defaults to 'No'
* change: in root mode: ui strings better match apt-get conventions
* change: added 'logout' step to directions
* change: added convenience buttons in "user" mode for checking warnings and navigating packages.

I'm not convinced that the package navigation buttons are that helpful. They distract too much from the "Check warnings" button.

-Mithat
 
 View user's profile Send private message  
Reply with quote Back to top
x-un-i
Post subject: Re: RE: Re: RE: Re: RE: apter: easier aptosid package manage  PostPosted: 17.12.2011, 12:31
Team Member


Joined: 2010-08-26
Posts: 170

      ghstryder wrote:
I've often wished that we had someone around here that understands that whole apt thing. Very Happy


I'm sure you did not put till now the right questions about it. otherwise would get ( more or less quickly) the good answers from that "someone"

_________________
Why do strong arms fatigue themselves with frivolous dumbbells?
To dig a vineyard is worthier exercise for men.
Marcus Valerius Martialis, römischer Satiriker und Epigrammdichter

Será que o diabo perdeu a virgindade?
 
 View user's profile Send private message  
Reply with quote Back to top
DonKultOffline
Post subject: RE: Re: RE: Re: RE: Re: RE: apter: easier aptosid package ma  PostPosted: 17.12.2011, 13:16
Team Member


Joined: 2010-09-02
Posts: 481

Status: Offline
Still not convinced that such a tool is such a good idea, but still a few comments:
* you can detect if you are on a tty - just check that the /proc/self/fd/0 is a link to /dev/tty? rather than a /dev/pts/? -- this would rule out ssh logins through, so it should only be a strong warning. Another option is to have a closer look at the who output, it tells you from there a user is logged in.
* The check for logged_in fails if the username sorts behind root. 'wc' for counting lines is a better idea.
* Running apt-get clean unconditional is a bad idea as it removes the chance to find an (old) working version of a package locally in case of problems with the new version.
* also, you handle multiuser systems (login status) but assume that only one person (marks for) installing stuff. As the file isn't protected link-attacks are properly possible and on a multiuser system it should be easy for a user who isn't root to become it just by pasting whatever he needs into this file before it is created by the user who will later install stuff. I could imagine creating the file with the content '-y --force-yes libc6-' and set it to world-writable. Okay, the user adding new packages to it will see that, but if i am good at timing (or use a script) i can create the file first empty, wait for the user adding some packages and then change it to my content (inotify to the 'rescue'). And thats only a very simple create maximum damage idea. With more thinking, we can do more subtil attacks…

apt-get has a dselect-upgrade command, i have never used it (which is an answer for itself), but marking packages with dpkg feels alot cleaner than reading it from a not-so-special file. I don't know about dependency resolution of this command through, so this remark is maybe completely pointless. I am too lazy now to check the code.

_________________
MfG. DonKult
"I never make stupid mistakes. Only very, very clever ones." ~ The Doctor
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
mithatOffline
Post subject: RE: Re: RE: Re: RE: Re: RE: apter: easier aptosid package ma  PostPosted: 17.12.2011, 17:41



Joined: 2011-12-15
Posts: 23

Status: Offline
@DonKuit: Thanks for all your comments. I'll work on making changes for your first three points -- those are fairly straight forward.

For the fourth, it looks like the "user" version should be run as root as well, and the file it creates be in a dir w/ root-only write access. Running both faces (X and textmode) as root might open up other possibilities as well, like doing --download-only while still in X to minimize time spent out of your X session.
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 12 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by Zafenio