You are not logged in.

#1 2011-10-10 20:03:25

Vamp898
Member
From: ドイツではまだ住んでいる
Registered: 2009-01-03
Posts: 866
Website

[brkgrp] A small tool to find uninstalled packages of a group

I think the subject says everything.

I wrote a small BASH-Skript which just gives you all non-installed packages of a group.

So if packages gets added for example to the gnome group, you can find them using "brkgrp gnome"

https://aur.archlinux.org/packages.php?ID=53054

Changelog 0.8.20
Uses LANG=C to prevent locale-problems

Changelog 0.8.19
Uses $HOME instead of ~/

Changelog 0.8.18
Added support to install the found packages by adding the "install" parameter
Also the help which appears if you type no parameter is more complete now

Changelog 0.8.17
brkgrp now uses a DB (plain txtfile) where the information about installed packages are stored. This is faster than running pacman -Ss for every search

Last edited by Vamp898 (2011-10-12 19:44:15)

Offline

#2 2011-10-10 20:45:43

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,094
Website

Re: [brkgrp] A small tool to find uninstalled packages of a group

This could be shortened up a bit...

grep -xFvf <(pacman -Qqg base) <(pacman -Sqg base)

Would show you packages missing from base

Last edited by falconindy (2011-10-10 20:51:48)

Offline

#3 2011-10-10 21:00:29

azleifel
Member
Registered: 2007-10-28
Posts: 476

Re: [brkgrp] A small tool to find uninstalled packages of a group

That's useful but is it meant to create "~/.config/brkgrp" in the current working directory (rather than $HOME/.config/brkgrp)?

Offline

#4 2011-10-10 21:06:07

Vamp898
Member
From: ドイツではまだ住んでいる
Registered: 2009-01-03
Posts: 866
Website

Re: [brkgrp] A small tool to find uninstalled packages of a group

azleifel wrote:

That's useful but is it meant to create "~/.config/brkgrp" in the current working directory (rather than $HOME/.config/brkgrp)?

fixed

btw.
~ is for the home-directory

which means ~/something is identically with $HOME/something

but i used $HOME now instead of ~

Last edited by Vamp898 (2011-10-10 21:19:34)

Offline

#5 2011-10-10 21:11:08

Vamp898
Member
From: ドイツではまだ住んでいる
Registered: 2009-01-03
Posts: 866
Website

Re: [brkgrp] A small tool to find uninstalled packages of a group

falconindy wrote:

This could be shortened up a bit...

grep -xFvf <(pacman -Qqg base) <(pacman -Sqg base)

Would show you packages missing from base

Its indeed shorter but harder to extend because its a closed commend in itself.

Maybe im wrong, but i can do the tool the best how i did it now. For sure, if you think something can be done better you can provide a patch and i will implement it if it works.

Offline

#6 2011-10-10 21:56:56

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,094
Website

Re: [brkgrp] A small tool to find uninstalled packages of a group

Harder to extend? Not seeing it...

I think its pretty useful on its own as a one liner, but if you insist on making it pretty and giving feedback all over the place...

#!/bin/bash

if [[ -z $1 ]]; then
  printf 'usage: %s <group>\n' "${0##*/}" >&2
  exit 1
fi

IFS=$'\n' read -rd '' -a pkggroup < <(pacman -Sgq "$1")

if (( ! ${#pkggroup[@]} )); then
  printf 'error: package group not found: %s\n' "$1" >&2
  exit 1
fi

IFS=$'\n' read -rd '' -a missing < <(printf '%s\n' "${pkggroup[@]}" | grep -xFvf <(pacman -Qqg "$1"))

if (( ${#missing[*]} == 0 )); then
  printf "All packages from the '%s' group are installed\n" "$1" >&2
else
  printf 'Missing packages from %s:\n' "$1" >&2
  printf '%s\n' "${missing[@]}" | { [[ -t 1 ]] && column -c$(tput cols) || cat; } 
fi

Offline

#7 2011-10-11 07:17:22

Vamp898
Member
From: ドイツではまだ住んでいる
Registered: 2009-01-03
Posts: 866
Website

Re: [brkgrp] A small tool to find uninstalled packages of a group

Hmmm

seems to be longer than this

if [ "$1" == "" ]; then
	echo "Usage: brkgrp <regexp>"
fi

OUTPUT=`pacman -Ss | grep "($1)" | grep -v instal -i | cut -d '/' -f 2-99 | cut -d ' ' -f 1`

if [ "$OUTPUT" == "" ]; then
	echo "You have all packages of $1 installed or the group $1 does not exist"
else
	echo "The following packages of the group $1 are not installed: "
	for i in $OUTPUT; do
		echo $i
	done
fi

and does the same if i understand it right

Offline

#8 2011-10-11 10:20:21

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,094
Website

Re: [brkgrp] A small tool to find uninstalled packages of a group

I'll just leave this here.

$ LANG=zh_CN.utf8 pacman -Ss | grep '(base)' | grep -v instal
allanbrokeit/coreutils 8.13.29.43a9-1 (base) [已安装]
allanbrokeit/findutils 4.5.10-1 (base) [已安装]
testing/filesystem 2011.10-1 (base) [已安装]
testing/initscripts 2011.09.2-1 (base)
core/bash 4.2.010-1 (base) [已安装]
core/binutils 2.21.1-2 (base) [已安装]
core/bzip2 1.0.6-2 (base) [已安装]
core/coreutils 8.13-2 (base) [已安装: 8.13.29.43a9-1]
core/cronie 1.4.8-1 (base)
core/cryptsetup 1.3.1-2 (base)
core/device-mapper 2.02.88-1 (base) [已安装]
core/dhcpcd 5.2.12-1 (base) [已安装]
core/diffutils 3.2-1 (base) [已安装]
core/e2fsprogs 1.41.14-1 (base) [已安装]
...

Offline

#9 2011-10-11 11:11:34

Vamp898
Member
From: ドイツではまだ住んでいる
Registered: 2009-01-03
Posts: 866
Website

Re: [brkgrp] A small tool to find uninstalled packages of a group

hmmm poor chinese people.

but as i said wink patches are all welcome, to change the grep which searches for installed packages is no hard work

or i just run the command with LANG=C

Last edited by Vamp898 (2011-10-11 11:17:17)

Offline

#10 2011-10-11 20:09:46

azleifel
Member
Registered: 2007-10-28
Posts: 476

Re: [brkgrp] A small tool to find uninstalled packages of a group

Vamp898 wrote:
azleifel wrote:

That's useful but is it meant to create "~/.config/brkgrp" in the current working directory (rather than $HOME/.config/brkgrp)?

fixed

btw.
~ is for the home-directory

which means ~/something is identically with $HOME/something

but i used $HOME now instead of ~

Thanks.

PS.  I know about ~ but in version 0.8.17

CONFIG_DIR="~/.config/brkgrp"

followed by

mkdir -p $CONFIG_DIR

would literally create "~/.config/brkgrp" in the current working directory, so if I ran the script from /home/david it would create /home/david/~/.config/brkgrp ;-)

Offline

Board footer

Powered by FluxBB