The officially official Devuan Forum!

You are not logged in.

#1 2019-07-12 09:21:39

ILUXA
Member
Registered: 2018-01-10
Posts: 8  

Apt aliases

What I always missed in Debian based distros is good and usable package manager,
while now situation is a little bit better with newer apt versions, but IMO
it is still very annoying to use a lot of apt-* commands to do simple tasks:
apt-cache, apt-file, apt-mark, apt-src, apt-rdepends, apt-get, apt-go-to-sleep…
What a madness! My second favourite OS after Devuan is FreeBSD smile
In FreeBSD there is a file, called pkg.conf, it is possible to configure aliases
for FreeBSD pkg package manager using this file, and it is very useful,
because it's very easy and handy to install a package just with # pkg in package,
or to remove it with # pkg r package, or to search it with # pkg s package...
So I tried to create a simple script to use it with apt-* commands, without need
to remember all animals in apt-* zoo. Maybe it will be useful for someone like me smile
I called it "pkg" and put it to /usr/local/bin, here it is:

#!/bin/sh
FIRST=$1; shift
case $FIRST in
	A) apt-mark auto $@ ;;
	M) apt-mark manual $@ ;;
	a) apt-get autoremove --purge $@ ;;
	r) apt-get purge $@ ;;
	in) apt-get install $@ ;;
	I) aptitude install $@ ;;
	re) apt-get install --reinstall $@ ;;
	ai) apt-get install $@ && apt-mark auto $@ ;;
	s) apt-cache search $@ ;;
	se) apt-cache search --names-only $@ ;;
	S) apt-cache madison $@ ;;
	f) apt-file find $@ ;;
	sh) apt-file show $@ ;;
	d) apt depends $@ ;;
	rd) apt rdepends $@ ;;
	l) dpkg -L $@ ;;
	w) dpkg -S $@ ;;
	u) aptitude safe-upgrade $@ ;;
	U) aptitude full-upgrade $@ ;;
	up) apt update ;;
	bd) aptitude build-dep $@ ;;
	i) [ $1 ] && apt-cache show $@ || dpkg -l ;;
	v) [ $1 ] && apt-show-versions $@ || apt-show-versions | grep -v 'not installed' ;;
	c) dpkg-repack $@ ;;
	add) dpkg -i $@ || apt install -f;;
	src) apt-src install $@ ;;
	cp) git clone $@ ;;
	key) apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $@ ;;
	rkey) apt-key del $@ ;;
	keys) apt-key list ;;
	*) apt $FIRST $@ ;;
esac

Then I executed # chmod +x /usr/local/bin/pkg. So now I'm able to use
just pkg commands, to manipulate my packages on my Devuan systems,
these aliases are very close to my FreeBSD pkg.conf configuration.
So now I'm able to use pkg in package to install a package, pkg r package
to remove it, pkg A package to mark a package as being automatically installed, etc.
If alias won't be found in this script, all pkg commands will be added to apt,
so it is possible to use apt commands with pkg as well, like pkg download package,
or even pkg install --reinstall package, etc.
So I don't need to remember all that apt-* crap anymore wink

Last edited by ILUXA (2019-11-28 15:40:23)


Not by might, nor by power, but by my spirit, said the Lord of Hosts.

Offline

#2 2019-07-12 14:51:56

Panopticon
Member
Registered: 2018-01-27
Posts: 306  

Re: Apt aliases

So what is a user case scenario for this?

alias pkg -d ="apt-get depends"

One could just make bash/sh aliases in a similar fashion and make it less of a typing burden with something like "apd" for apt-get depends and so on.

I think you are just shitting all over the apt package manager for shits and giggles really.

Offline

#3 2019-07-12 23:16:26

macondo
Member
From: Central America
Registered: 2017-06-11
Posts: 52  

Re: Apt aliases

FWIW, this is what i got in my .bash_aliases

alias adu="sudo apt-get update && sudo apt-get dist-upgrade"
alias agi="sudo apt-get install"
alias as="apt-cache search"
alias ash="apt-cache show"

I have sudo configured with the NOPASSWD option


Desktop Dual Core 8 GB RAM - Devuan Ceres - Slackware Current - Grub - JWM
“Just because you're paranoid doesn't mean they aren't after you.” ― Joseph Heller, Catch-22

Offline

#4 2019-07-13 08:04:56

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Apt aliases

ILUXA wrote:

So I don't need to remember all that apt-* crap anymore wink

But then you have to remember what all the letter options do hmm

The APT commands have lots of options because they are so powerful and can do so much, not sure why you're complaining about that.

Note also that the apt command consolidates the abilities of apt-get & apt-cache and provides a more "user-friendly" interface, it is now recommended over apt-get for Debian buster.


Brianna Ghey — Rest In Power

Offline

#5 2019-07-13 09:04:31

yeti
Member
From: I'm not here: U R halucinating
Registered: 2017-02-23
Posts: 335  

Re: Apt aliases

Head_on_a_Stick wrote:

Note also that the apt command consolidates the abilities of apt-get & apt-cache and provides a more "user-friendly" interface, it is now recommended over apt-get for Debian buster.

And in contrast to home grown spells, there is the magic TAB key for the common package management commands' options. I think this is hard to beat with aliases.


*𝚛𝚒𝚋𝚋𝚒𝚝!*

Offline

#6 2019-07-13 12:04:45

Panopticon
Member
Registered: 2018-01-27
Posts: 306  

Re: Apt aliases

@ yeti, only if you have completion setup nicely. Then there is history search via .inputrc up down arrow search in vi mode.

Offline

#7 2019-07-13 13:29:26

yeti
Member
From: I'm not here: U R halucinating
Registered: 2017-02-23
Posts: 335  

Re: Apt aliases

Panopticon wrote:

Then there is history search via .inputrc up down arrow search in vi mode.

# up/dn history search
bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'

..."Works for me."™


*𝚛𝚒𝚋𝚋𝚒𝚝!*

Offline

#8 2019-07-13 19:27:08

ILUXA
Member
Registered: 2018-01-10
Posts: 8  

Re: Apt aliases

BTW, I also use completion with my zsh shell,
I have compdef pkg='apt' in my zshrc file,
so apt completion work with my pkg script as well.
RjMJzDU.png

Head_on_a_Stick wrote:

But then you have to remember what all the letter options do hmm

No need to remember it, because I already use same letters for pkg command with my FreeBSD installation.
Anyway, IMO it is much more easy to remember one letter, than to remember whole new commands with its arguments...

Last edited by ILUXA (2019-07-16 12:19:23)


Not by might, nor by power, but by my spirit, said the Lord of Hosts.

Offline

#9 2019-07-14 15:26:15

Panopticon
Member
Registered: 2018-01-27
Posts: 306  

Re: Apt aliases

Do you think maybe this is subject to error in the future? When you have been trained to think of how Freebsd pkg works you may give a command you unintentionally did not want to give. I suppose then it would be down to memory retention. How closely linked is Freebsd pkg to debians apt?

Case in point: pkg add -M

-M, --accept-missing
		Force the installation of the package with missing dependen-
		cies.

https://www.freebsd.org/cgi/man.cgi?que … +and+Ports

M) apt-mark manual ${@:2} ;;

https://manpages.debian.org/stretch/apt … .8.en.html

manual
manual is used to mark a package as being manually installed, which will prevent the package from being automatically removed if no other packages depend on it.

Last edited by Panopticon (2019-07-14 15:42:53)

Offline

#10 2019-07-14 15:54:39

Panopticon
Member
Registered: 2018-01-27
Posts: 306  

Re: Apt aliases

Another interesting tidbit.

https://aboutthebsds.wordpress.com/2013 … s-apt-get/

Finally by comparing the source code of FreeBSD’s pkgng to Debian’s apt-get, people would find that pkgng is literally pieces of code ripped from apt-get with little to no modification. Indeed discussions on the mailing list in late 2011 show that FreeBSD “developers” including Baptiste Daroussin took apt-get and removed the GPL license together with code they could not understand and renamed the result pkgng. They did this as they were incapable of writing a package manager from scratch. This means pkgng has legal implications for FreeBSD as it is illegal to remove the GPL from a piece of software without the author’s permission. It also shows how blatant the BSD projects can be when fighting against the freedom achieved by Richard Stallman, the FSF, Linus Torvalds and GNU/Linux.

This is probably partly due to how much freebsd is very much dependent on the linux environment to stay relevant, my experience using freebsd was met with loading up boot commands related to linux to get things working. BSD folks like to bag gnu/linux but at the same time borrow so much from it.

Last edited by Panopticon (2019-07-14 15:58:19)

Offline

#11 2019-07-14 18:21:06

ILUXA
Member
Registered: 2018-01-10
Posts: 8  

Re: Apt aliases

Finally by comparing the source code of FreeBSD’s pkgng to Debian’s apt-get, people would find that pkgng is literally pieces of code ripped from apt-get with little to no modification. Indeed discussions on the mailing list in late 2011 show that FreeBSD “developers” including Baptiste Daroussin took apt-get and removed the GPL license together with code they could not understand and renamed the result pkgng. They did this as they were incapable of writing a package manager from scratch. This means pkgng has legal implications for FreeBSD as it is illegal to remove the GPL from a piece of software without the author’s permission. It also shows how blatant the BSD projects can be when fighting against the freedom achieved by Richard Stallman, the FSF, Linus Torvalds and GNU/Linux.

This is complete delirium, no comments.

apt-mark manual

FreeBSD equivalent is pkg set -A 0, or pkg set -A 1 to mark package as automatically installed.
But after I've configured pkg aliases I'm using pkg M package or pkg A package.
But I don't understand, why you're trying to write something about FreeBSD to me,
what I've posted, is just a simple script to use it with Debian based distros, there is really
no real connection between it and FreeBSD, I use some of same letters on my FBSD installation but that's all.
You're barking up the wrong tree.

Last edited by ILUXA (2019-07-14 18:33:11)


Not by might, nor by power, but by my spirit, said the Lord of Hosts.

Offline

#12 2019-07-15 12:49:38

Panopticon
Member
Registered: 2018-01-27
Posts: 306  

Re: Apt aliases

ILUXA wrote:

Finally by comparing the source code of FreeBSD’s pkgng to Debian’s apt-get, people would find that pkgng is literally pieces of code ripped from apt-get with little to no modification. Indeed discussions on the mailing list in late 2011 show that FreeBSD “developers” including Baptiste Daroussin took apt-get and removed the GPL license together with code they could not understand and renamed the result pkgng. They did this as they were incapable of writing a package manager from scratch. This means pkgng has legal implications for FreeBSD as it is illegal to remove the GPL from a piece of software without the author’s permission. It also shows how blatant the BSD projects can be when fighting against the freedom achieved by Richard Stallman, the FSF, Linus Torvalds and GNU/Linux.

This is complete delirium, no comments.

apt-mark manual

FreeBSD equivalent is pkg set -A 0, or pkg set -A 1 to mark package as automatically installed.
But after I've configured pkg aliases I'm using pkg M package or pkg A package.
But I don't understand, why you're trying to write something about FreeBSD to me,
what I've posted, is just a simple script to use it with Debian based distros, there is really
no real connection between it and FreeBSD, I use some of same letters on my FBSD installation but that's all.
You're barking up the wrong tree.

I think what you are doing is confusing.

I have experience with more than one package manager - apt, apk, pacman,xbps, pkgsrc, pkgng,rpm, etc. Each one is unique in its own use, if you are using debian/devuan then apt should be memorized and so forth. Just my opinion, not barking up the any tree by the way, just posting some interesting information.

Offline

#13 2019-07-16 09:55:51

ILUXA
Member
Registered: 2018-01-10
Posts: 8  

Re: Apt aliases

Panopticon wrote:

just posting some interesting information.

I don't think that part from article dated 2 February 2013, which was written by schizophrenic on his blog, may be called "interesting information". Only he and his psychotherapist know why he think that FreeBSD package manager is somehow related to Debian apt package manager...

Panopticon wrote:

I have experience with more than one package manager - apt, apk, pacman,xbps, pkgsrc, pkgng,rpm, etc.

Good for you. Me too, BTW. But IMO it is much more handy to use the same commands everywhere, because you don't need to always remember what OS you're using, especially if you're using two machines at the same time, like me.

Last edited by ILUXA (2019-07-16 10:03:04)


Not by might, nor by power, but by my spirit, said the Lord of Hosts.

Offline

#14 2019-07-16 12:21:40

Panopticon
Member
Registered: 2018-01-27
Posts: 306  

Re: Apt aliases

ILUXA wrote:
Panopticon wrote:

just posting some interesting information.

I don't think that part from article dated 2 February 2013, which was written by schizophrenic on his blog, may be called "interesting information". Only he and his psychotherapist know why he think that FreeBSD package manager is somehow related to Debian apt package manager...

Panopticon wrote:

I have experience with more than one package manager - apt, apk, pacman,xbps, pkgsrc, pkgng,rpm, etc.

Good for you. Me too, BTW. But IMO it is much more handy to use the same commands everywhere, because you don't need to always remember what OS you're using, especially if you're using two machines at the same time, like me.

You are quite right, no evidence to back the "interesting" claim up for sure. Would be interesting to see the particular mailing lists from 2011 he speaks of. Anyhow old news.

Welcome to devuan wink

Offline

Board footer