summaryrefslogtreecommitdiff
path: root/pcr/pactools
diff options
context:
space:
mode:
Diffstat (limited to 'pcr/pactools')
-rw-r--r--pcr/pactools/PKGBUILD18
-rwxr-xr-xpcr/pactools/pactools63
-rwxr-xr-xpcr/pactools/pt-deptree54
-rwxr-xr-xpcr/pactools/pt-pacfix22
-rwxr-xr-xpcr/pactools/pt-pacman-cage152
-rwxr-xr-xpcr/pactools/pt-pacman-info77
-rwxr-xr-xpcr/pactools/pt-pacman-uncage108
-rwxr-xr-xpcr/pactools/pt-pacsize21
-rwxr-xr-xpcr/pactools/pt-repolist42
9 files changed, 557 insertions, 0 deletions
diff --git a/pcr/pactools/PKGBUILD b/pcr/pactools/PKGBUILD
new file mode 100644
index 000000000..d05953b99
--- /dev/null
+++ b/pcr/pactools/PKGBUILD
@@ -0,0 +1,18 @@
+# Contributor: Pierluigi <pierluigi88@gmail.com>
+# Maintainer : Parabola GNU / Linux-libre Aurelien Desbrieres <aurelien@cwb.io>
+
+pkgname=pactools
+pkgver=0.8.2
+pkgrel=1
+pkgdesc="A collection of the best tools for pacman"
+arch=('i686' 'x86_64')
+url="http://pierloz.com/pactools"
+license=("GPL")
+depends=('perl' 'bash' 'python')
+source=(pactools pt-pacman-cage pt-pacman-uncage pt-pacsize \
+pt-deptree pt-pacman-info pt-repolist pt-pacfix)
+
+build() {
+ install -d $pkgdir/usr/bin
+ install -m 755 $srcdir/* $pkgdir/usr/bin
+}
diff --git a/pcr/pactools/pactools b/pcr/pactools/pactools
new file mode 100755
index 000000000..1fe3ddbe8
--- /dev/null
+++ b/pcr/pactools/pactools
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+green() {
+ echo -e "\033[1;32m${1}\033[1;0m"
+ }
+
+red() {
+ echo -e "\033[1;31m${1}\033[1;0m"
+ }
+
+
+echo 'pactools is a set of useful tools for pacman'
+echo
+echo 'Tools installed:'
+echo
+green ' * pt-pacman-cage'
+echo ' by: ody'
+echo ' A script to keep the pacman db in a contiguous as possible'
+echo ' place on your hd to make reading it quicker.'
+echo ' Attention: be sure to have the module loop loaded in rc.conf'
+echo ' WEB: http://bbs.archlinux.org/viewtopic.php?id=20385'
+echo
+green ' * pt-pacman-uncage'
+echo ' by: ody'
+echo ' To uncage your pacman db, after pt-pacman-cage.'
+echo ' Use only if you have problem with pt-pacman-cage and you'
+echo ' want to come back to standard db system'
+echo ' WEB: http://bbs.archlinux.org/viewtopic.php?id=20385'
+echo
+green ' * pt-pacsize'
+echo ' by: hads'
+echo ' How much disk space do my installed packages use?'
+echo ' This script answers to the question.'
+echo ' WEB: http://bbs.archlinux.org/viewtopic.php?id=20971'
+echo
+green ' * pt-deptree'
+echo ' by: skoal'
+echo ' A visual representation of packages dependencies'
+echo ' WEB: http://bbs.archlinux.org/viewtopic.php?id=10283'
+echo
+green ' * pt-pacman-info'
+echo ' by: Pável Varela Rodríguez [aka NeOnsKuLL]'
+echo ' List the names of configured repos in your pacman.conf'
+echo ' Calculates the total number of available packages'
+echo ' in each repo;'
+echo ' calculates the number of installed packages.'
+echo ' WEB: http://bbs.archlinux.org/viewtopic.php?id=23124'
+echo
+green ' * pt-repolist'
+echo ' by: dtw'
+echo ' Shows installed packages from a certain repo.'
+echo ' USAGE: pt-repolist <reponame> [all]'
+echo ' <reponame> is the repository name'
+echo ' [all] to include also NOT installed packages.'
+echo ' WEB: http://bbs.archlinux.org/viewtopic.php?id=12369'
+echo
+green ' * pt-pacfix'
+echo ' by: pierluigi and fixed by Chris.Giles'
+echo ' A script to list all the packages currently installed,'
+echo ' according to /var/log/pacman.log'
+echo ' WEB: http://bbs.archlinux.org/viewtopic.php?pid=227510'
+echo
+red 'Please remember: pactools comes with NO WARRANTY, use at your own risk'
diff --git a/pcr/pactools/pt-deptree b/pcr/pactools/pt-deptree
new file mode 100755
index 000000000..edb6f538b
--- /dev/null
+++ b/pcr/pactools/pt-deptree
@@ -0,0 +1,54 @@
+#!/bin/sh
+# Pacman Dependency Tree
+# does NOT handle group names -> unexpected results.
+# Package names using aliases, like x-server, should work.
+# Breaks on circular dependencies -> you better hit ctrl-c.
+
+export LC_ALL=en_US
+
+progname=`basename $0`
+pacexec='pacman'
+leafnull='None'
+branch=""
+vbranch="| "
+vprune=" "
+hbranch="+---"
+
+_showdep () {
+
+ # Try to use specific pkg req
+ if $pacexec -Qi $1 &> /dev/null ; then
+ # Grab deps list|from "Depends"|Remove Tag \| specific version req's.
+ deplist=`$pacexec -Qi $1|grep Depends|sed 's/^.*: \|>[^ ]*//g;s/ $//'`
+ else # Oops! Failed on alias, try this...
+ deplist=`$pacexec -Qs $1 | sed '1!d;s/\(^.*\/\)\(.*\)\( .*$\)/\2/'`
+ fi
+
+ [ "x$deplist" = "x$leafnull" ] && return
+
+ while [ -n "$deplist" ]
+ do
+ set -- $deplist && echo "$branch$hbranch$1"
+ if [ $# -gt 1 ] ; then
+ branch=${branch}$vbranch
+ else
+ branch=${branch}$vprune
+ fi
+
+ _showdep $1
+
+ deplist=${*:2}
+ branch=${branch:0:${#branch}-${#vprune}}
+ done
+}
+
+branch=$vprune
+
+for pkg in `$pacexec -Q $1 | sed 's/ .*//'`
+do
+ echo $pkg
+ _showdep $pkg
+done
+
+unset _showdep && set --
+exit 0
diff --git a/pcr/pactools/pt-pacfix b/pcr/pactools/pt-pacfix
new file mode 100755
index 000000000..cd128331e
--- /dev/null
+++ b/pcr/pactools/pt-pacfix
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+#
+# pacfix.py: a script by pierluigi to list all the packages currently installed according to /var/log/pacman.log
+# 2008-07-04: Modified by Chris Giles to prevent failure when "pacman.log" has lines with only two words
+
+
+pkg=[]
+
+logfile = open("/var/log/pacman.log","r")
+log=logfile.readlines()
+for myline in log:
+ myarray = myline.strip("\n").split(" ")
+ if len(myarray) >= 3 :
+ if (myarray[2]=="installed" or myarray[2]=="upgraded"):
+ if (pkg.count(myarray[3])==0):
+ pkg.append(myarray[3])
+ if (myarray[2]=="removed"):
+ if (pkg.count(myarray[3])!=0):
+ pkg.remove(myarray[3])
+pkg.sort()
+for p in pkg:
+ print(p)
diff --git a/pcr/pactools/pt-pacman-cage b/pcr/pactools/pt-pacman-cage
new file mode 100755
index 000000000..f9248e496
--- /dev/null
+++ b/pcr/pactools/pt-pacman-cage
@@ -0,0 +1,152 @@
+#!/bin/bash
+#
+# pacman-cage
+#
+# Copyright (c) 2002-2006 by Andrew Rose <rose.andrew@gmail.com>
+# I used Judds pacman-optimise as a framework.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+# USA.
+#
+
+myver='2.9.8.1'
+dbroot="/var/lib/pacman"
+pacmandb="/var/lib/pacman.db"
+
+usage() {
+ echo "pacman-cage $myver"
+ echo "usage: $0 pacman_db_size(MB)"
+ echo
+ echo "pacman-cage creates a loopbacked filesystem in a contigious file."
+ echo "This will give better response times when using pacman"
+ echo "A safe value for pacman_db_size should be > 40"
+ echo
+ echo "If you are unsure, use this:"
+ echo " $0 60"
+ echo
+}
+
+die() {
+ echo "pacman-cage: $*" >&2
+ exit 1
+}
+
+die_r() {
+ rm -f /tmp/pacman.lck
+ die $*
+}
+
+loop_check=`zcat /proc/config.gz | grep CONFIG_BLK_DEV_LOOP | cut -d\= -f2`
+
+if [ "$loop_check" == "m" ]; then
+ if [ `lsmod | grep loop | cut -d\ -f1` != "loop" ]; then
+ echo "Error. You have to load the module 'loop' in rc.conf."
+ exit 1
+ fi
+fi
+
+if [ "$loop_check" == "CONFIG_BLK_DEV_LOOP" ]; then
+ echo "Error. Your kernel config doesn't include CONFIG_BLK_DEV_LOOP."
+ exit 1
+fi
+
+
+if [ "$#" != "1" ]; then echo "wrong number of parameters" 1>&2 ; usage; exit 0; fi
+
+if [ "$1" != "" ]; then
+ if [ "$1" = "-h" -o "$1" = "--help" ]; then
+ usage
+ exit 0
+ fi
+ dbsize=$1
+fi
+
+if [ "`id -u`" != 0 ]; then
+ die "You must be root to cage the database"
+fi
+
+# make sure pacman isn't running
+if [ -f /tmp/pacman.lck ]; then
+ die "Pacman lockfile was found. Cannot run while pacman is running."
+fi
+# make sure pacman.db hasnt already been made
+if [ -f $pacmandb ]; then
+ die "$pacmandb already exists!."
+fi
+
+if [ ! -d $dbroot ]; then
+ die "$dbroot does not exist or is not a directory"
+fi
+
+# don't let pacman run while we do this
+touch /tmp/pacman.lck
+
+# step 1: sum the old db
+echo "==> md5sum'ing the old database..."
+find $dbroot -type f | sort | xargs md5sum >/tmp/pacsums.old
+
+echo "==> creating pacman.db loopback file..."
+dd if=/dev/zero of=$pacmandb bs=1M count=$dbsize > /dev/null 2>&1
+
+echo "==> creating ext2 -O dir_index -b 1024 -m 0 on $pacmandb..."
+yes | mkfs.ext2 -O dir_index -b 1024 -i 1024 -m 0 -F $pacmandb > /dev/null 2>&1
+
+echo "==> creating temporary mount point /mnt/tmp-pacman.."
+mkdir /mnt/tmp-pacman
+
+echo "==> mounting pacman.db to temporary mount point..."
+mount -o loop $pacmandb /mnt/tmp-pacman
+
+echo "==> copying pacman database to temporary mount point..."
+cp -a /var/lib/pacman/. /mnt/tmp-pacman
+
+echo "==> unmounting temporary mount point..."
+umount /mnt/tmp-pacman
+
+echo "==> removing temporary mount point..."
+rmdir /mnt/tmp-pacman
+
+echo "==> moving old /var/lib/pacman to /var/lib/pacman.bak..."
+mv /var/lib/pacman /var/lib/pacman.bak
+
+echo "==> createing new pacman db mount point @ $dbroot..."
+mkdir $dbroot
+
+echo "==> Mounting new pacman db..."
+mount -o loop $pacmandb $dbroot
+
+echo "==> md5sum'ing the new database..."
+find $dbroot -type f | sort | xargs md5sum >/tmp/pacsums.new
+
+echo "==> checking integrity..."
+diff /tmp/pacsums.old /tmp/pacsums.new >/dev/null 2>&1
+if [ $? -ne 0 ]; then
+ # failed, move the old one back into place
+ umount $dbroot
+ rm $pacmandb
+ mv $dbroot.bak $dbroot
+ die_r "integrity check FAILED, reverting to old database"
+fi
+
+echo "==> Updating /etc/fstab to reflect changes..."
+echo "$pacmandb $dbroot ext2 loop,defaults 0 0" >> /etc/fstab
+
+rm -f /tmp/pacman.lck /tmp/pacsums.old /tmp/pacsums.new
+
+echo
+echo "Finished. Your pacman database has been caged!. May the speedy pacman be with you."
+echo
+
+exit 0
diff --git a/pcr/pactools/pt-pacman-info b/pcr/pactools/pt-pacman-info
new file mode 100755
index 000000000..c2c82f219
--- /dev/null
+++ b/pcr/pactools/pt-pacman-info
@@ -0,0 +1,77 @@
+#!/bin/sh
+# pacman-info
+# /usr/bin/pacman-info
+# GPL v2
+# neonskull [at] gmail.com
+
+VERSION="0.1"
+AUTHOR="Pável Varela Rodríguez [aka NeOnsKuLL]"
+
+usage()
+{
+echo "pacman-info v$VERSION"
+echo "usage: `basename $0` [OPTION]
+
+OPTIONS:
+ -cr|--configured-repos List the names of configured repos in your
+ pacman.conf
+
+ -a|--all Calculates the total number of available
+ packages in your repos
+
+ -br|--by-repo Calculates the total number of available
+ packages in each repo
+
+ -i|--installed Calculates the number of installed packages
+
+ -f|--full Generates a full Report
+
+ -h|--help Show this message
+
+ -v|--version Show version
+"
+}
+
+[ "$#" -lt 1 ] && PARAM="-h";
+[ "$#" -gt 1 ] && PARAM="*";
+[ "$#" -eq 1 ] && PARAM="$1";
+
+case $PARAM in
+ "-a"|"--all")
+ echo -e "Repositories information (total of packages in repos): `pacman -Sl|wc -l`"
+ ;;
+ "-cr"|"--configured-repos")
+ echo "Repositories information (name of configured repos):"
+ pacman -Sl|awk '{print $1}'|cut -d"/" -f 2|uniq -c|awk '{print "* " $2}'
+ ;;
+ "-br"|"--by-repo")
+ echo "Repositories information (number of packages by repo):"
+ pacman -Sl|awk '{print $1}'|cut -d"/" -f 2|uniq -c|awk '{print ":: "$2 "\t-> " $1 "\tpkgs"}'
+ ;;
+ "-i"|"--installed")
+ echo -e "System information (total of installed packages): `pacman -Q|wc -l`"
+ ;;
+ "-f"|"--full")
+ echo -e "Full Report about Repositories and Packages for Archlinux"
+ echo -e "Node name: `uname -n`\n"
+ $0 -cr
+ echo
+ $0 -a
+ echo
+ $0 -br
+ echo
+ $0 -i
+ echo
+ echo -e "Generated using `$0 -v` by $AUTHOR"
+ ;;
+ "-h"|"--help")
+ usage
+ ;;
+ "-v"|"--version")
+ echo "`basename $0` v$VERSION"
+ ;;
+ *)
+ echo "Error! Unknown parameter."
+ usage
+ ;;
+esac
diff --git a/pcr/pactools/pt-pacman-uncage b/pcr/pactools/pt-pacman-uncage
new file mode 100755
index 000000000..12b7e41d3
--- /dev/null
+++ b/pcr/pactools/pt-pacman-uncage
@@ -0,0 +1,108 @@
+
+#!/bin/bash
+#
+# pacman-uncage
+#
+# Copyright (c) 2002-2006 by Andrew Rose <rose.andrew@gmail.com>
+# I used Judds pacman-optimise as a framework.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+# USA.
+#
+
+myver='2.9.8'
+dbroot="/var/lib/pacman"
+tmproot="/var/lib/pacman.new"
+pacmandb="/var/lib/pacman.db"
+
+usage() {
+ echo "pacman-uncage $myver"
+ echo "usage: $0 [pacman_db_root]"
+ echo
+ echo "pacman-uncage returns your pacman db to the generic style."
+ echo
+}
+
+die() {
+ echo "pacman-uncage: $*" >&2
+ exit 1
+}
+
+die_r() {
+ rm -f /tmp/pacman.lck
+ die $*
+}
+
+if [ "$1" != "" ]; then
+ if [ "$1" = "-h" -o "$1" = "--help" ]; then
+ usage
+ exit 0
+ fi
+ dbroot=$1
+fi
+
+if [ "`id -u`" != 0 ]; then
+ die "You must be root to uncage the database"
+fi
+
+# make sure pacman isn't running
+if [ -f /tmp/pacman.lck ]; then
+ die "Pacman lockfile was found. Cannot run while pacman is running."
+fi
+
+if [ ! -d $dbroot ]; then
+ die "$dbroot does not exist or is not a directory"
+fi
+
+# don't let pacman run while we do this
+touch /tmp/pacman.lck
+
+# step 1: sum the old db
+echo "==> md5sum'ing the old database..."
+find $dbroot -type f | sort | xargs md5sum >/tmp/pacsums.old
+
+echo "==> copying pacman.db contents back, note: the time needed to get a brew is now."
+mkdir $tmproot
+cp -a $dbroot/. $tmproot
+
+echo "==> unmounting old dbroot and moving new one in"
+umount $dbroot
+rmdir $dbroot
+mv $tmproot $dbroot
+
+echo "==> md5sum'ing the new database..."
+find $dbroot -type f | sort | xargs md5sum >/tmp/pacsums.new
+
+echo "==> checking integrity..."
+diff /tmp/pacsums.old /tmp/pacsums.new >/dev/null 2>&1
+if [ $? -ne 0 ]; then
+ # failed, move the old one back into place
+ rm -rf $dbroot
+ mkdir $dbroot
+ mount -a
+ die_r "integrity check FAILED, reverting to old database"
+fi
+
+echo "==> Removing old pacman.db"
+rm $pacmandb
+
+rm -f /tmp/pacman.lck /tmp/pacsums.old /tmp/pacsums.new
+
+echo
+echo "Finished. Your pacman database has been uncaged!. Welcome home."
+echo "You will need to remove the old mount line from your /etc/fstab"
+echo
+
+exit 0
diff --git a/pcr/pactools/pt-pacsize b/pcr/pactools/pt-pacsize
new file mode 100755
index 000000000..e70a34597
--- /dev/null
+++ b/pcr/pactools/pt-pacsize
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+##AUTHOR: hads
+##See: http://bbs.archlinux.org/viewtopic.php?t=20971
+
+for i in /var/lib/pacman/local/*; do
+ PKG=`echo $i | cut -d '/' -f 6`
+ SIZE=`grep -A 1 SIZE $i/desc | tail -1`
+ if [ -x /usr/bin/bc ]; then
+ if [ $SIZE -gt 1024 ]; then
+ if [ $SIZE -gt 1048576 ]; then
+ SIZE=`echo "scale=1;$SIZE/1048576" | bc`M
+ else
+ SIZE=`echo "scale=1;$SIZE/1024" | bc`K
+ fi
+ else
+ SIZE={$SIZE}B
+ fi
+ fi
+ echo "$PKG | $SIZE"
+done
diff --git a/pcr/pactools/pt-repolist b/pcr/pactools/pt-repolist
new file mode 100755
index 000000000..5f15fe462
--- /dev/null
+++ b/pcr/pactools/pt-repolist
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+pacman -Qi >./all_files
+
+if [ -z "$1" ] ; then
+ echo -e "\033[0;37mNo repo given!"
+ echo " usage: scriptname reponame"
+fi
+
+reponame=$1
+list=$1_list
+pacman -Sl $reponame >./$list
+sed -i "s|\$reponame |g|" ./$list
+repo=`cat ./$list | cut --fields 2 --delim " "`
+
+for pkg in $repo ; do
+ if [[ $(cat ./all_files | grep -w "$pkg") ]] ; then
+ echo -e "\033[0;34m$pkg\033[0;37m is installed"
+ echo "$pkg" >>./installed_files
+ elif [ "$2" == "all" ] ; then
+ echo -e "\033[0;31m$pkg\033[0;37m is NOT installed"
+ fi
+done
+
+echo
+echo -n "Would you like to save the names of these pkgs to a file? (Y/n) "
+read choice
+if [ "$choice" == "Y" -o "$choice" == "y" ] ; then
+ echo "Currently in `pwd`"
+ echo -n " Save as: "
+ read filename
+ if [ -z $filename ] ; then
+ echo "No name given saved as ./installed_files_$reponame"
+ cp -u ./installed_files ./installed_files_$reponame
+ else
+ cp -u ./installed_files $filename
+ fi
+ rm ./installed_files
+else
+ rm ./installed_files
+fi
+rm ./$list ./all_files