Live data from Hacker News

The apt command: Combining apt-get and apt-cache and adds a progress bar (2014)

mvogt.wordpress.com

61–70 of 77 posts

Re: The apt command: Combining apt-get and apt-cache and adds a progress bar (2014)

#61

Earlier quoted context omitted.

"aptitude [...] is a friendly frontend to apt." "The primary command line tool is aptitude. apt-get fulfills a similar purpose and although it is no longer the recommended primary tool some still use it." If you prefer the apt-* commands: "You can also use Wajig, for an unified and more logical command-line interface to all package management functions." (Apparently, apt is the new Wajig, except that apt doesn't auto…

Yeah, until you do an upgrade: "The upgrade process for some previous releases recommended the use of aptitude for the upgrade. This tool is not recommended for upgrades from wheezy to jessie." See https://www.debian.org/releases/stable/amd64/release-notes/c...

Debian's zigzagging between package management frontends (dselect, apt-*, aptitude, dpkg, now apt?, … all in use in parallel) is incredibly frustrating. Pacman e.g. is so much easier to use because everything's in one well-structured command.

Re: The apt command: Combining apt-get and apt-cache and adds a progress bar (2014)

#62
post #8

I've never understood why debian insists on having these be different commands. It would make sense if install, search, upgrade and uninstall were all discrete, but the way it is today feels half implemented.

Same. Having to search for what you wanted to install via apt-cache, but then actually install it via apt-get, was a triumph of some unexplainable factor over usability.

And remove an application with apt-get? I prefer yum and dnf much over apt.

Re: The apt command: Combining apt-get and apt-cache and adds a progress bar (2014)

#63
post #60
post #27

Earlier quoted context omitted.

I can't answer specifically for `apt`, but many commands take significantly longer if you let them display to stdout versus piping their output to a file or `/dev/null`. cf.: $ time ls -R /usr real 0m7.570s user 0m0.104s sys 0m2.286s $ time ls -R /usr > /dev/null real 0m0.193s user 0m0.036s sys 0m0.154s (edit: when will I grok HN markup?? cough support markdown cough )

I've always assumed something like the above is slow due to the terminal blocking the program to perform updates to the display. Whereas a status indicator isn't exactly pushing much data to the terminal. So, It shouldn't impact run time.

Yes, that's a reasonable assumption. I am by no means a terminal guru, but my understanding is that, for something like a progress bar or spinner (anything that is updated in-place in the terminal), the entire "screen" is being redrawn on update.

Re: The apt command: Combining apt-get and apt-cache and adds a progress bar (2014)

#64
post #61

Earlier quoted context omitted.

Yeah, until you do an upgrade: "The upgrade process for some previous releases recommended the use of aptitude for the upgrade. This tool is not recommended for upgrades from wheezy to jessie." See https://www.debian.org/releases/stable/amd64/release-notes/c...

Debian's zigzagging between package management frontends (dselect, apt-*, aptitude, dpkg, now apt?, … all in use in parallel) is incredibly frustrating. Pacman e.g. is so much easier to use because everything's in one well-structured command.

It probably reflects the classic problem of developer turnover in OSS projects and the resulting approach to technical debt. Old developers fade away, young guns come through (often still in academia), "this code is all crap, let's chuck it out and build something better, how hard can it be?"...

Re: The apt command: Combining apt-get and apt-cache and adds a progress bar (2014)

#65
post #27

Earlier quoted context omitted.

I can't answer specifically for `apt`, but many commands take significantly longer if you let them display to stdout versus piping their output to a file or `/dev/null`. cf.: $ time ls -R /usr real 0m7.570s user 0m0.104s sys 0m2.286s $ time ls -R /usr > /dev/null real 0m0.193s user 0m0.036s sys 0m0.154s (edit: when will I grok HN markup?? cough support markdown cough )

Did you run those two commands in sequence? Did you account for disk-cache effects? Try running it 4 times, alternating the versions and see what your last 2 times are ...

You can actually show different speeds in different terminals - the speed of terminal rendering affects the duration of the test. In the tests below, I have no custom terminal prompts or similar (no git status lines etc) - they're all distribution defaults running bash.

    # all the below run in the same MATE desktop
    # lxterm (from lxde - is easiest on my eye)
    $ time ls -R /usr
    real    0m19.974s
    user    0m0.860s
    sys	    0m0.832s

    # gnome terminal
    $ time ls -R /usr
    real    0m19.902s
    user    0m0.800s
    sys     0m0.776s

    # xterm (yes, it really is 10x the speed)
    $ time ls -R /usr
    real    0m1.872s
    user    0m0.856s
    sys     0m0.800s

    # rerun in the first terminal, and the time hasn't changed - still 19s

    # now in lxterm redirecting to null
    # (and xterm gives similar results here)
    $ time ls -R /usr > /dev/null

    real    0m0.418s
    user    0m0.256s
    sys     0m0.156s

All that prettification and rendering takes time; if you want raw speed, use xterm... or pipe output to /dev/null.

Interestingly, 'time' on gterm and lxterm had tabs between the above field:value pairs (I had to reformat to show them nicely), but xterm used spaces. I don't know enough about the terminal underpinnings to guess as to why.

Re: The apt command: Combining apt-get and apt-cache and adds a progress bar (2014)

#66
post #60
post #27

Earlier quoted context omitted.

I can't answer specifically for `apt`, but many commands take significantly longer if you let them display to stdout versus piping their output to a file or `/dev/null`. cf.: $ time ls -R /usr real 0m7.570s user 0m0.104s sys 0m2.286s $ time ls -R /usr > /dev/null real 0m0.193s user 0m0.036s sys 0m0.154s (edit: when will I grok HN markup?? cough support markdown cough )

I've always assumed something like the above is slow due to the terminal blocking the program to perform updates to the display. Whereas a status indicator isn't exactly pushing much data to the terminal. So, It shouldn't impact run time.

I also suspect (though have not verified) that any output to terminal is quite a bit slower than the raw operation -- that sort of difference that we should all know, as programmers.

http://norvig.com/21-days.html#answers

Re: The apt command: Combining apt-get and apt-cache and adds a progress bar (2014)

#67
post #38

Earlier quoted context omitted.

I have this problem too. If I did myself shelling out to grep with pcre flags to find a simple library then there's a UX issue.

Search uses regular expressions so generally no need for grep unless you need more complex filters; --names-only has the -n short-form: apt-cache search -n More generally apt-get and apt-cache are designed to be backward-compatible for use in scripts whereas apt is not[0]: SCRIPT USAGE AND DIFFERENCES FROM OTHER APT TOOLS The apt(8) commandline is designed as an end-user tool and it may change behavior between versio…

Great tip thank you!

Re: The apt command: Combining apt-get and apt-cache and adds a progress bar (2014)

#68
post #8

I've never understood why debian insists on having these be different commands. It would make sense if install, search, upgrade and uninstall were all discrete, but the way it is today feels half implemented.

Only one of them requires readwrite system administrator privileges (eg sudo). apt-cache can be run by any user as it doesn't expose any secret data and can't be used to make changes. apt-get can install and uninstall software as well as download packages and thus needs root privileges in the classic UNIX model.

On CentOS, I can do "yum search something" as a regular user, while "yum install something" or "yum upgrade" require root privileges.

I think it's similar with the pkg command on FreeBSD.

Re: The apt command: Combining apt-get and apt-cache and adds a progress bar (2014)

#69
post #68

Earlier quoted context omitted.

Only one of them requires readwrite system administrator privileges (eg sudo). apt-cache can be run by any user as it doesn't expose any secret data and can't be used to make changes. apt-get can install and uninstall software as well as download packages and thus needs root privileges in the classic UNIX model.

On CentOS, I can do "yum search something" as a regular user, while "yum install something" or "yum upgrade" require root privileges. I think it's similar with the pkg command on FreeBSD.

and same with pacman on Arch (and derivatives)

Re: The apt command: Combining apt-get and apt-cache and adds a progress bar (2014)

#70
post #61

Earlier quoted context omitted.

Yeah, until you do an upgrade: "The upgrade process for some previous releases recommended the use of aptitude for the upgrade. This tool is not recommended for upgrades from wheezy to jessie." See https://www.debian.org/releases/stable/amd64/release-notes/c...

Debian's zigzagging between package management frontends (dselect, apt-*, aptitude, dpkg, now apt?, … all in use in parallel) is incredibly frustrating. Pacman e.g. is so much easier to use because everything's in one well-structured command.

Well, just use apt(8):

apt install - Install packages

apt remove - Remove packages

apt upgrade - Upgrade packages without removing

apt full-upgrade - Upgrade packages, allowing removals

apt update - Refresh sources

apt show - Show a package

apt list - List packages, you can filter by stuff like --installed or --upgradable

Post reply on HN