summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/.gitignore0
-rw-r--r--contrib/Makefile.am5
-rw-r--r--contrib/PKGBUILD.vim2
-rw-r--r--contrib/README10
-rwxr-xr-xcontrib/bacman284
-rw-r--r--contrib/bash_completion13
-rwxr-xr-xcontrib/gensync134
-rwxr-xr-xcontrib/paclist88
-rwxr-xr-xcontrib/pacsearch163
-rwxr-xr-xcontrib/re-pacman77
-rwxr-xr-xcontrib/updatesync137
-rw-r--r--contrib/zsh_completion13
12 files changed, 769 insertions, 157 deletions
diff --git a/contrib/.gitignore b/contrib/.gitignore
deleted file mode 100644
index e69de29b..00000000
--- a/contrib/.gitignore
+++ /dev/null
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index 7066f409..25d5aac2 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -1,9 +1,12 @@
EXTRA_DIST = \
PKGBUILD.vim \
+ bacman \
bash_completion \
+ gensync \
pacdiff \
+ paclist \
pacsearch \
- re-pacman \
+ updatesync \
vimprojects \
wget-xdelta.sh \
zsh_completion \
diff --git a/contrib/PKGBUILD.vim b/contrib/PKGBUILD.vim
index 57e4cf0e..8f45ae44 100644
--- a/contrib/PKGBUILD.vim
+++ b/contrib/PKGBUILD.vim
@@ -151,7 +151,7 @@ hi def link pbValidSha1sums Number
" options
syn keyword pb_k_options options contained
-syn match pbOptions /\(no\)\?\(strip\|docs\|libtool\|emptydirs\|ccache\|distcc\|makeflags\|force\)/ contained
+syn match pbOptions /\(no\)\?\(strip\|docs\|libtool\|emptydirs\|zipman\|ccache\|distcc\|makeflags\|force\)/ contained
syn match pbOptionsNeg /\!/ contained
syn match pbOptionsDeprec /no/ contained
syn region pbOptionsGroup start=/^options=(/ end=/)/ contains=pb_k_options,pbOptions,pbOptionsNeg,pbOptionsDeprec,pbIllegalOption,shDoubleQuote,shSingleQuote
diff --git a/contrib/README b/contrib/README
index 7eb36aae..5ce7ca40 100644
--- a/contrib/README
+++ b/contrib/README
@@ -12,11 +12,15 @@ zsh_completion - a zsh completion script, install (with a rename) to
pacdiff - a simple pacnew/pacorig/pacsave updater for /etc/.
+paclist - list all packages installed from a given repository. Useful for
+seeing which packages you may have installed from the testing repository,
+for instance.
+
pacsearch - a colorized search combining both -Ss and -Qs output. Installed
packages are easily identified with a *** and local-only packages are also
listed.
-re-pacman - regenerate a pacman package based on installed files and the pacman
+bacman - regenerate a pacman package based on installed files and the pacman
database entries. Useful for reuse, or possible config file extension.
vimprojects - a project file for the vim project plugin.
@@ -24,3 +28,7 @@ vimprojects - a project file for the vim project plugin.
wget-xdelta.sh - A download script for pacman which allows binary deltas
generated with makepkg to be used instead of downloading full binary packages.
This should cut download sizes for some package upgrades significantly.
+
+gensync, updatesync - The former repository management scripts that have since
+been superseded by repo-add and repo-remove. They are here for posterity's
+sake, and to show how repo-add and repo-remove can be wrapped in other scripts.
diff --git a/contrib/bacman b/contrib/bacman
new file mode 100755
index 00000000..22940ecb
--- /dev/null
+++ b/contrib/bacman
@@ -0,0 +1,284 @@
+#!/bin/bash
+#
+# bacman: recreate a package from a running system
+# This script rebuilds an already installed package using metadata
+# stored into the pacman database and system files
+#
+# (c) 2008 - locci <carlocci_at_gmail_dot_com>
+#
+# 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, see <http://www.gnu.org/licenses/>.
+#
+
+readonly progname="bacman"
+readonly progver="0.2.0"
+
+#
+# User Friendliness
+#
+function usage(){
+ echo "This program recreates a package using pacman's db and system files"
+ echo "Usage: $progname <installed package name>"
+ echo "Example: $progname kernel26"
+}
+
+if [ $# -ne 1 ] ; then
+ usage
+ exit 1
+fi
+
+if [ "$1" = "--help" -o "$1" = "-h" ] ; then
+ usage
+ exit 0
+fi
+
+if [ "$1" = "--version" -o "$1" = "-v" ]; then
+ echo "$progname version $progver"
+ echo "Copyright (C) 2008 locci"
+ exit 0
+fi
+
+#
+# Fakeroot support
+#
+if [ $EUID -gt 0 ]; then
+ if [ -f /usr/bin/fakeroot ]; then
+ echo "Entering fakeroot environment"
+ export INFAKEROOT="1"
+ /usr/bin/fakeroot -u -- $0 $1
+ exit $?
+ else
+ echo "WARNING: installing fakeroot or running ${progname} as root is required to"
+ echo " preserve the ownership permissions of files in some packages"
+ echo ""
+ fi
+fi
+
+#
+# Setting environmental variables
+#
+if [ ! -r /etc/pacman.conf ]; then
+ echo "ERROR: unable to read /etc/pacman.conf"
+ exit 1
+fi
+
+eval $(awk '/DBPath/ {print $1$2$3}' /etc/pacman.conf)
+pac_db="${DBPath:-/var/lib/pacman/}/local"
+
+if [ ! -r /etc/makepkg.conf ]; then
+ echo "ERROR: unable to read /etc/makepkg.conf"
+ exit 1
+fi
+
+source "/etc/makepkg.conf"
+if [ -r ~/.makepkg.conf ]; then
+ source ~/.makepkg.conf
+fi
+
+pkg_arch=${CARCH:-'unknown'}
+pkg_dest="${PKGDEST:-$PWD}"
+pkg_ext=${PKGEXT:-'.pkg.tar.gz'}
+pkg_pkger=${PACKAGER:-'Unknown Packager'}
+
+pkg_name="$1"
+pkg_dir="$(echo $pac_db/$pkg_name-[0-9]*)"
+pkg_namver="${pkg_dir##*/}"
+
+#
+# Checks everything is in place
+#
+if [ ! -d "$pac_db" ] ; then
+ echo "ERROR: pacman database directory ${pac_db} not found"
+ exit 1
+fi
+
+if [ ! -d "$pkg_dir" ] ; then
+ echo "ERROR: package ${pkg_name} not found in pacman database"
+ exit 1
+fi
+
+#
+# Begin
+#
+echo Package: ${pkg_namver}
+work_dir=$(mktemp -d -p /tmp)
+cd "$work_dir" || exit 1
+
+#
+# File copying
+#
+echo "Copying package files..."
+
+cat "$pkg_dir"/files |
+while read i; do
+ if [ -z "$i" ] ; then
+ continue
+ fi
+
+ if [[ "$i" =~ %[A-Z]*% ]] ; then
+ current=$i
+ continue
+ fi
+
+ case $current in
+ %FILES%)
+ ret=0
+ if [ -e "/$i" ]; then
+ bsdtar -cnf - "/$i" 2> /dev/null | bsdtar -xpf -
+
+ # Workaround to bsdtar not reporting a missing file as an error
+ if [ ! -e "$work_dir/$i" ] && [ -L "$work_dir/$i"]; then
+ echo ""
+ echo "ERROR: unable to add /$i to the package"
+ echo " If your user does not have permssion to read this file then"
+ echo " you will need to run $progname as root"
+ rm -rf "$work_dir"
+ exit 1
+ fi
+ else
+ echo ""
+ echo "WARNING: package file /$i is missing"
+ echo ""
+ fi
+
+
+ ;;
+ esac
+done
+
+ret=$?
+if [ $ret -ne 0 ]; then
+ rm -rf "$work_dir"
+ exit 1
+fi
+
+pkg_size=$(du -sk | awk '{print $1 * 1024}')
+
+if [ -f "$pkg_dir/install" ] ; then
+ cp "$pkg_dir/install" "$work_dir/.INSTALL"
+fi
+if [ -f $pkg_dir/changelog ] ; then
+ cp "$pkg_dir/changelog" "$work_dir/.CHANGELOG"
+fi
+
+#
+# .PKGINFO stuff
+#
+echo Generating .PKGINFO metadata...
+echo "# Generated by $progname $progver" > .PKGINFO
+if [ "$INFAKEROOT" = "1" ]; then
+ echo "# Using $(fakeroot -v)" >> .PKGINFO
+fi
+echo "# $(LC_ALL=C date)" >> .PKGINFO
+echo "#" >> .PKGINFO
+
+cat "$pkg_dir"/{desc,files,depends} |
+while read i; do
+ if [[ -z "$i" ]]; then
+ continue;
+ fi
+
+ if [[ "$i" =~ %[A-Z]*% ]] ; then
+ current=$i
+ continue
+ fi
+
+ case "$current" in
+ # desc
+ %NAME%)
+ echo "pkgname = $i" >> .PKGINFO
+ ;;
+ %VERSION%)
+ echo "pkgver = $i" >> .PKGINFO
+ ;;
+ %DESC%)
+ echo "pkgdesc = $i" >> .PKGINFO
+ ;;
+ %URL%)
+ echo "url = $i" >> .PKGINFO
+ ;;
+ %LICENSE%)
+ echo "license = $i" >> .PKGINFO
+ ;;
+ %ARCH%)
+ echo "arch = $i" >> .PKGINFO
+ ;;
+ %BUILDDATE%)
+ echo "builddate = $(date -u "+%s")" >> .PKGINFO
+ ;;
+ %PACKAGER%)
+ echo "packager = $pkg_pkger" >> .PKGINFO
+ ;;
+ %SIZE%)
+ echo "size = $pkg_size" >> .PKGINFO
+ ;;
+ %GROUPS%)
+ echo "group = $i" >> .PKGINFO
+ ;;
+ %REPLACES%)
+ echo "replaces = $i" >> .PKGINFO
+ ;;
+ %FORCE%)
+ echo "force = true" >> .PKGINFO
+ ;;
+
+ # files
+ %BACKUP%)
+ # strip the md5sum after the tab
+ echo "backup = ${i%%$'\t'*}" >> .PKGINFO
+ ;;
+
+ # depends
+ %DEPENDS%)
+ echo "depend = $i" >> .PKGINFO
+ ;;
+ %OPTDEPENDS%)
+ echo "optdepend = $i" >> .PKGINFO
+ ;;
+ %CONFLICTS%)
+ echo "conflict = $i" >> .PKGINFO
+ ;;
+ %PROVIDES%)
+ echo "provides = $i" >> .PKGINFO
+ ;;
+ esac
+done
+
+#
+# Fixes owner:group and permissions for .PKGINFO, .CHANGELOG, .INSTALL
+#
+chown root:root "$work_dir"/{.PKGINFO,.CHANGELOG,.INSTALL} 2> /dev/null
+chmod 644 "$work_dir"/{.PKGINFO,.CHANGELOG,.INSTALL} 2> /dev/null
+
+#
+# Generate the package
+#
+echo "Generating the package..."
+
+ret=0
+bsdtar -czf "$pkg_dest/$pkg_namver-$pkg_arch$pkg_ext" $(ls -A) || ret=$?
+if [ $ret -ne 0 ]; then
+ echo "ERROR: unable to write package to $pkg_dest"
+ echo " Maybe the disk is full or you do not have write access"
+ rm -rf "$work_dir"
+ exit 1
+fi
+
+rm -rf "$work_dir"
+
+echo Done
+
+exit 0
+
+# vim: set ts=2 sw=2 noet:
+
diff --git a/contrib/bash_completion b/contrib/bash_completion
index 77192858..11f021c8 100644
--- a/contrib/bash_completion
+++ b/contrib/bash_completion
@@ -146,14 +146,13 @@ _pacman ()
toparse="${a:2}"
case "${arg}" in
- -@(A|U|R|S|Q|h|V))
+ -@(U|R|S|Q|h|V))
op="${arg/-}"
mod="${mod}${a:2}"
;;
--)
arg="${a:2}"
case "${arg}" in
- add) op="A" ;;
remove) op="R" ;;
upgrade) op="U" ;;
query) op="Q" ;;
@@ -187,6 +186,7 @@ _pacman ()
dbonly) mod="${mod}k" ;;
nosave) mod="${mod}n" ;;
recursive) mod="${mod}s" ;;
+ unneeded) mod="${mod}u" ;;
esac ;;
*) toparse="${a}" ;;
esac
@@ -202,7 +202,6 @@ _pacman ()
if [ $COMP_CWORD -eq 1 ] && [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '\
- -A --add \
-h --help \
-Q --query \
-R --remove \
@@ -216,9 +215,10 @@ _pacman ()
if [[ "$cur" == -* ]]; then
case "${op}" in
- A|U)
+ U)
COMPREPLY=( $( compgen -W '\
--asdeps \
+ --asexplicit \
-d --nodeps \
-f --force \
-h --help \
@@ -242,6 +242,7 @@ _pacman ()
-k --dbonly \
-n --nosave \
-s --recursive \
+ -u --unneeded \
--config \
--logfile \
--noconfirm \
@@ -257,9 +258,9 @@ _pacman ()
S)
COMPREPLY=( $( compgen -W '\
--asdeps \
+ --asexplicit \
-c --clean \
-d --nodeps \
- -e --dependsonly \
-f --force \
-g --groups \
-h --help \
@@ -316,7 +317,7 @@ _pacman ()
rem_selected
else
case "${op}" in
- A|U)
+ U)
COMPREPLY=( $( compgen -d -- "$cur" ) \
$( compgen -f -X '!*.pkg.tar.gz' -- "$cur" ) )
return 0
diff --git a/contrib/gensync b/contrib/gensync
new file mode 100755
index 00000000..51d32ceb
--- /dev/null
+++ b/contrib/gensync
@@ -0,0 +1,134 @@
+#!/bin/bash
+#
+# gensync
+#
+# Copyright (c) 2002-2007 by Judd Vinet <jvinet@zeroflux.org>
+#
+# 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, see <http://www.gnu.org/licenses/>.
+#
+
+myver='3.1.1'
+
+# functions
+
+usage() {
+ printf "gensync (pacman) %s\n\n" "$myver"
+ printf "Usage: %s <root> <destfile> [package_directory]\n\n" "$0"
+ printf "\
+gensync will generate a sync database by reading all PKGBUILD files\n\
+from <root>. gensync builds the database in a temporary directory\n\
+and then compresses it to <destfile>.\n\n"
+ printf "\
+gensync will calculate md5sums of packages in the same directory as\n\
+<destfile>, unless an alternate [package_directory] is specified.\n\n"
+ printf "\
+note: The <destfile> name is important. It must be of the form\n\
+ {treename}.db.tar.gz where {treename} is the name of the custom\n\
+ package repository you configured in /etc/pacman.conf. The\n\
+ generated database must reside in the same directory as your\n\
+ custom packages (also configured in /etc/pacman.conf)\n\n"
+ echo "Example: gensync /var/abs/local /home/mypkgs/custom.db.tar.gz"
+}
+
+version() {
+ printf "gensync (pacman) %s\n" "$myver"
+ printf "\
+Copyright (C) 2002-2007 Judd Vinet <jvinet@zeroflux.org>.\n\n\
+This is free software; see the source for copying conditions.\n\
+There is NO WARRANTY, to the extent permitted by law.\n"
+}
+
+error () {
+ local mesg=$1; shift
+ printf "==> ERROR: ${mesg}\n" "$@" >&2
+}
+
+die () {
+ error $*
+ exit 1
+}
+
+# PROGRAM START
+
+if [ "$1" = "-h" -o "$1" = "--help" ]; then
+ usage
+ exit 0
+fi
+
+if [ "$1" = "-V" -o "$1" = "--version" ]; then
+ version
+ exit 0
+fi
+
+if [ $# -lt 2 ]; then
+ usage
+ exit 1
+fi
+
+# source system and user makepkg.conf
+if [ -r /etc/makepkg.conf ]; then
+ source /etc/makepkg.conf
+else
+ die "/etc/makepkg.conf not found. Cannot continue."
+fi
+
+if [ -r ~/.makepkg.conf ]; then
+ source ~/.makepkg.conf
+fi
+
+
+d=$(dirname $1)
+rootdir="$(cd $d && pwd)/$(basename $1)"
+d="$(dirname $2)"
+destdir="$(cd $d && pwd)"
+destfile="$destdir/$(basename $2)"
+pkgdir=""
+if [ "$3" != "" ]; then
+ pkgdir="$3"
+fi
+
+[ ! -d "$rootdir" ] && die "invalid root dir: $rootdir"
+
+echo "gensync: building database entries, generating md5sums..." >&2
+cd "$destdir"
+
+pkgs=""
+
+for file in $(find "$rootdir"/* -name "$BUILDSCRIPT"); do
+ unset pkgname pkgver pkgrel options
+
+ source $file || die "failed to parse $file"
+ if [ "$arch" = 'any' ]; then
+ CARCH='any'
+ fi
+ if [ "$pkgdir" != "" ]; then
+ pkgfile="$pkgdir/$pkgname-$pkgver-$pkgrel-${CARCH}${PKGEXT}"
+ else
+ pkgfile="$destdir/$pkgname-$pkgver-$pkgrel-${CARCH}${PKGEXT}"
+ fi
+
+ if [ ! -f "$pkgfile" ]; then
+ error "could not find %s-%s-%s-%s%s - skipping" $pkgname $pkgver $pkgrel $CARCH $PKGEXT
+ else
+ pkgs="$pkgs $pkgfile"
+ fi
+done
+
+echo "creating repo DB..."
+
+# we'll trim the output just a tad, as gensync may be used on large repos
+repo-add $destfile $pkgs \
+ | grep -e "package" -e "database"
+
+# vim: set ts=2 sw=2 noet:
diff --git a/contrib/paclist b/contrib/paclist
new file mode 100755
index 00000000..0379a4c5
--- /dev/null
+++ b/contrib/paclist
@@ -0,0 +1,88 @@
+#!/usr/bin/perl
+# paclist - List all packages installed from a given repo
+#
+# Copyright (C) 2008 Dan McGee <dpmcgee@gmail.com>
+#
+# 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, see <http://www.gnu.org/licenses/>.
+
+use strict;
+use warnings;
+
+my $progname = "paclist";
+my $version = "1.0";
+
+if ($#ARGV != 0 || $ARGV[0] eq "--help" || $ARGV[0] eq "-h") {
+ print "$progname - List all packages installed from a given repo\n";
+ print "Usage: $progname <repo>\n";
+ print "Example: $progname testing\n";
+ if ($#ARGV != 0) {
+ exit 1;
+ }
+ exit 0;
+}
+
+if ( $ARGV[0] eq "--version" || $ARGV[0] eq "-v") {
+ print "$progname version $version\n";
+ print "Copyright (C) 2008 Dan McGee\n";
+ exit 0;
+}
+
+# This hash table will be used to store pairs of ('name version', count) from
+# the return of both pacman -Sl <repo> and pacman -Q output. We then check to
+# see if a value was added twice (count = 2)- if so, we will print that package
+# as it is both in the repo we queried and installed on our local system.
+my %packages = ();
+my $output;
+
+$output = `pacman -Sl $ARGV[0]`;
+if ($? != 0) {
+ exit 1;
+}
+my @sync = split(/\n/, $output);
+# sample output from pacman -Sl:
+# testing foobar 1.0-1
+foreach $_ (@sync) {
+ my @info = split(/ /);
+ # we only want to store 'foobar 1.0-1' in our hash table
+ my $pkg = $info[1] . " " . $info[2];
+ $packages{$pkg}++;
+}
+
+$output = `pacman -Q`;
+if ($? != 0) {
+ exit 1;
+}
+# sample output from pacman -Q:
+# foobar 1.0-1
+my @local = split(/\n/, $output);
+foreach $_ (@local) {
+ # store 'foobar 1.0-1' in our hash table
+ $packages{$_}++;
+}
+
+# run comparison check- if value was added twice, it was in the intersection
+my @intersection;
+foreach $_ (keys %packages) {
+ if ($packages{$_} == 2) {
+ push @{ \@intersection }, $_;
+ }
+}
+
+# print our intersection, and bask in the glory and speed of perl
+@intersection = sort @intersection;
+foreach $_ (@intersection) {
+ print $_ . "\n";
+}
+
+#vim: set noet:
diff --git a/contrib/pacsearch b/contrib/pacsearch
index c07c28a8..3cf8b925 100755
--- a/contrib/pacsearch
+++ b/contrib/pacsearch
@@ -1,6 +1,9 @@
-#!/bin/bash
+#!/usr/bin/perl
# pacsearch - Adds color and install information to a 'pacman -Ss' search
#
+# Copyright (C) 2008 Dan McGee <dpmcgee@gmail.com>
+#
+# Based off original shell script version:
# Copyright (C) 2006-2007 Dan McGee <dpmcgee@gmail.com>
#
# This program is free software; you can redistribute it and/or
@@ -18,72 +21,112 @@
#TODO: colors flag on commandline
-readonly progname="pacsearch"
-readonly version="1.0"
+use strict;
+use warnings;
+
+my $progname = "pacsearch";
+my $version = "2.0";
+
+if ($#ARGV lt 0 || $ARGV[0] eq "--help" || $ARGV[0] eq "-h") {
+ print "$progname - Add color and install information to a pacman -Ss search\n";
+ print "Usage: $progname <pattern>\n";
+ print "Example: $progname ^gnome\n";
+ if ($#ARGV lt 0) {
+ exit 1;
+ }
+ exit 0;
+}
-readonly CLR1='\\\e[0;34m'
-readonly CLR2='\\\e[0;32m'
-readonly CLR3='\\\e[0;35m'
-readonly CLR4='\\\e[0;36m'
-readonly CLR5='\\\e[0;31m'
-readonly CLR6='\\\e[0;33m'
-readonly CLR7='\\\e[1;36m'
-readonly INST='\\\e[1;31m'
-readonly BASE='\\\e[0m'
+if ($ARGV[0] eq "--version" || $ARGV[0] eq "-v") {
+ print "$progname version $version\n";
+ print "Copyright (C) 2006-2008 Dan McGee\n";
+ exit 0;
+}
-if [ "$1" = "--help" -o "$1" = "-h" ]; then
- echo "Usage: $progname <pattern>"
- echo "Ex: $progname ^gnome"
- exit 0
-fi
+# define our colors to use when printing
+my $CLR1 = "\e[0;34m";
+my $CLR2 = "\e[0;32m";
+my $CLR3 = "\e[0;35m";
+my $CLR4 = "\e[0;36m";
+my $CLR5 = "\e[0;31m";
+my $CLR6 = "\e[0;33m";
+my $CLR7 = "\e[1;36m";
+my $INST = "\e[1;31m";
+my $BASE = "\e[0m";
+my $INSTMARK = $INST."***";
-if [ "$1" = "--version" -o "$1" = "-v" ]; then
- echo "$progname version $version"
- echo "Copyright (C) 2006-2007 Dan McGee"
- exit 0
-fi
+# color a "repo/pkgname pkgver" line based on the respository name
+sub to_color {
+ my $line = shift;
+ $line =~ s/(^core\/.*)/$CLR1$1$BASE/;
+ $line =~ s/(^extra\/.*)/$CLR2$1$BASE/;
+ $line =~ s/(^community\/.*)/$CLR3$1$BASE/;
+ $line =~ s/(^testing\/.*)/$CLR4$1$BASE/;
+ $line =~ s/(^unstable\/.*)/$CLR5$1$BASE/;
+ $line =~ s/(^custom\/.*)/$CLR6$1$BASE/;
+ $line =~ s/(^local\/.*)/$CLR7$1$BASE/;
+ # any other unknown repository
+ $line =~ s/(^[\w-]*\/.*)/$CLR6$1$BASE/;
+ return $line;
+}
-if [ -z "$1" -o "${1:0:1}" = "-" ]; then
- echo "Usage: $progname <pattern>"
- echo "Ex: $progname ^gnome"
- exit 1
-fi
+my %allpkgs = ();
-# Make two temp files and send output of commands to these files
-querydump=$(mktemp)
-pacman -Qs $1 > $querydump
-syncdump=$(mktemp)
-pacman -Ss $1 > $syncdump
+my $syncout = `pacman -Ss @ARGV`;
+# split each sync search entry into its own array entry
+my @syncpkgs = split(/\n^(?=\w)/m, $syncout);
+# remove the extra \n from the last desc entry
+if ($#syncpkgs >= 0) {
+ chomp($syncpkgs[$#syncpkgs]);
+}
-# Strip descriptions and 'local/' from -Qs query
-instpkg=$(mktemp)
-egrep '^[^ ]' $querydump | sed -e 's@^local/@@' > $instpkg
+# counter var for packages, used here and in the query loop too
+my $cnt = 0;
+foreach $_ (@syncpkgs) {
+ # we grab 3 fields here: repo, name/ver, and desc
+ my @pkgfields = /^(.*?)\/(.*?)\n(.*)$/s;
+ # add a fourth field that will indicate install status
+ push (@pkgfields, "");
+ # add a fifth field that indicates original order
+ push (@pkgfields, $cnt++);
+ # add each sync pkg by name/ver to a hash table for quick lookup
+ $allpkgs{$pkgfields[1]} = [ @pkgfields ];
+}
-# Add pkgs not in sync db, mark pkgs that are installed
-cat $instpkg | while read -r pkg; do
- if [ -z "$(grep "$pkg" $syncdump)" ]; then
- # grep package name; pipe to another grep that prints at most one
- # line starting with 'local/', allows for comments >1 line
- grep -A10 "$pkg" $querydump | grep -A10 -m1 "local/" >> $syncdump
- fi
- sed -i "s@^\(.\+/$pkg\)@\***\1@" $syncdump
-done
+my $queryout = `pacman -Qs @ARGV`;
+# split each querysearch entry into its own array entry
+my @querypkgs = split(/\n^(?=\w)/m, $queryout);
+# remove the extra \n from the last desc entry
+if ($#querypkgs >= 0) {
+ chomp ($querypkgs[$#querypkgs]);
+}
-# Print colorized package list and descriptions to screen
-echo -e "$(sed -r \
- -e "s@core/.*@$CLR1&$BASE@" \
- -e "s@extra/.*@$CLR2&$BASE@" \
- -e "s@community/.*@$CLR3&$BASE@" \
- -e "s@testing/.*@$CLR4&$BASE@" \
- -e "s@unstable/.*@$CLR5&$BASE@" \
- -e "s@custom/.*@$CLR6&$BASE@" \
- -e "s@local/.*@$CLR7&$BASE@" \
- -e "s@(^|\*\*\*)([[:alnum:]]*/.* .*)@\1$CLR6\2$BASE@" \
- -e "s@\*\*\*@$INST&@" \
- < $syncdump )"
-echo -en "\e[0m"
+foreach $_ (@querypkgs) {
+ # we grab 3 fields here: repo, name/ver, and desc
+ my @pkgfields = /^(.*?)\/(.*?)\n(.*)$/s;
+ # check if the package was listed in the sync out
+ # if it is we want to mark it with a *** marker
+ if (exists $allpkgs{$pkgfields[1]}) {
+ # mark it in our fourth field as installed
+ @{ $allpkgs{$pkgfields[1]} }[3] = $INSTMARK;
+ } else {
+ # add a fourth field that will indicate install status
+ push (@pkgfields, $INSTMARK);
+ # add a fifth field that indicates original order (after sync)
+ push (@pkgfields, $cnt++);
+ # add our local-only package to the hash
+ $allpkgs{$pkgfields[1]} = [ @pkgfields ];
+ }
+}
-rm $querydump
-rm $syncdump
-rm $instpkg
+# sort by original order (the fifth field) and print
+foreach $_ ( sort{ @{$allpkgs{$a}}[4] <=> @{$allpkgs{$b}}[4] } keys %allpkgs) {
+ my @v = @{$allpkgs{$_}};
+ my $line = "$v[0]/$v[1]";
+ $line = to_color($line);
+ # print install marker + colorized "repo/pkgname pkgver" string
+ print "$v[3]$line\n";
+ print "$v[2]\n";
+}
+#vim: set noet:
diff --git a/contrib/re-pacman b/contrib/re-pacman
deleted file mode 100755
index fff1c873..00000000
--- a/contrib/re-pacman
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/bin/sh
-#
-# re-pacman: regenerate a pacman package based on installed files and the
-# pacman database entries. Useful for reuse, or possible config file
-# extension
-#
-# Copyright (c) 2006 Aaron Griffin <aaron@archlinux.org>
-#
-# 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, see <http://www.gnu.org/licenses/>.
-#
-
-#TODO
-# * Check for md5 changes in backup lines and change pkgrel
-
-pacinfo () {
- [ $# -ne 2 ] && return 1
- #use echo to strip spaces
- echo $(pacman -Qi ${1} | grep "${2}" | cut -d: -f2-)
-}
-
-make_pkginfo () {
- echo "# Generated by re-pacman 1.0.0"
- echo "# On $(date)"
- echo "pkgname =$(pacinfo ${1} Name)"
- echo "pkgver =$(pacinfo ${1} Version)"
- echo "pkgdesc =$(pacinfo ${1} Description)"
- echo "url =$(pacinfo ${1} URL)"
- echo "builddate =$(pacinfo ${1} 'Build Date')"
- echo "packager =$(pacinfo ${1} Packager)"
- echo "size =$(pacinfo ${1} Size)"
- echo "arch =$(pacinfo ${1} Architecture)"
- deps=$(pacinfo ${1} 'Depends On')
- for d in ${deps}; do
- echo "depend = ${d}"
- done
-}
-
-LANG="POSIX"
-
-if [ $# -ne 1 ]; then
- echo "usage: re-pacman <installed package name>"
- exit 1
-fi
-
-ver=$(pacinfo ${1} Version)
-if [ "x${ver}" = "x" ]; then
- echo "Package '${1}' not found, aborting."
- exit 1
-fi
-
-echo ":: Cleaning up old files"
-rm -f .PKGINFO "${1}-${ver}.pkg.tar.gz"
-
-echo ":: Building PKGINFO"
-make_pkginfo ${1} > .PKGINFO
-
-flist=".PKGINFO"
-flist="${flist} $(pacman -Ql ${1} | sed 's|\w* \(.*\)|/\1|g' | grep -v '/$')"
-
-echo ":: Building final package tarball"
-echo ${flist} | tr ' ' '\n' | tar czf "${1}-${ver}.pkg.tar.gz" -T - 2>/dev/null
-
-rm -f .PKGINFO
-echo ":: Package '${1}-${ver}.pkg.tar.gz' is now ready for installation"
-
-# vim: set ts=2 sw=2 noet:
diff --git a/contrib/updatesync b/contrib/updatesync
new file mode 100755
index 00000000..f88e8237
--- /dev/null
+++ b/contrib/updatesync
@@ -0,0 +1,137 @@
+#!/bin/bash
+#
+# updatesync
+#
+# Copyright (c) 2004 by Jason Chu <jason@archlinux.org>
+# Derived from gensync (c) 2002-2006 Judd Vinet <jvinet@zeroflux.org>
+#
+# 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, see <http://www.gnu.org/licenses/>.
+#
+
+myver='3.1.1'
+
+# functions
+
+usage() {
+ printf "updatesync (pacman) %s\n\n" "$myver"
+ printf "Usage: %s <action> <destfile> <option> [package_directory]\n\n" "$0"
+ printf "\
+updatesync will update a sync database by reading a PKGBUILD and\n\
+modifying the destfile. updatesync updates the database in a temporary\n\
+directory and then compresses it to <destfile>.\n\n"
+ printf "There are two types of actions:\n\n"
+ printf "upd - Will update a package's entry or create it if it doesn't exist.\n It takes the package's PKGBUILD as an option.\n"
+ printf "del - Will remove a package's entry from the db. It takes the package's\n name as an option.\n"
+ echo
+ printf "\
+updatesync will calculate md5sums of packages in the same directory as\n\
+<destfile>, unless an alternate [package_directory] is specified.\n\n"
+ echo "Example: updatesync upd /home/mypkgs/custom.db.tar.gz PKGBUILD"
+}
+
+version() {
+ printf "updatesync (pacman) %s\n" "$myver"
+ printf "\
+Copyright (C) 2004 Jason Chu <jason@archlinux.org>.\n\n\
+This is free software; see the source for copying conditions.\n\
+There is NO WARRANTY, to the extent permitted by law.\n"
+}
+
+error () {
+ local mesg=$1; shift
+ printf "==> ERROR: ${mesg}\n" "$@" >&2
+}
+
+die () {
+ error $*
+ exit 1
+}
+
+# PROGRAM START
+
+if [ "$1" = "-h" -o "$1" = "--help" ]; then
+ usage
+ exit 0
+fi
+
+if [ "$1" = "-V" -o "$1" = "--version" ]; then
+ version
+ exit 0
+fi
+
+if [ $# -lt 3 ]; then
+ usage
+ exit 1
+fi
+
+# source system and user makepkg.conf
+if [ -r /etc/makepkg.conf ]; then
+ source /etc/makepkg.conf
+else
+ die "/etc/makepkg.conf not found. Cannot continue."
+fi
+
+if [ -r ~/.makepkg.conf ]; then
+ source ~/.makepkg.conf
+fi
+
+if [ "$1" != "upd" -a "$1" != "del" ]; then
+ usage
+ exit 1
+fi
+
+action=$1
+pkgdb=$2
+option=$3
+pkgdir="$(pwd)"
+if [ "$4" != "" ]; then
+ pkgdir="$4"
+fi
+
+if [ "$action" = "upd" ]; then # INSERT / UPDATE
+ if [ ! -f "$option" ]; then
+ die "$option not found"
+ fi
+
+ unset pkgname pkgver pkgrel options
+
+ source $option || die "failed to parse $option"
+ if [ "$arch" = 'any' ]; then
+ CARCH='any'
+ fi
+ pkgfile="$pkgdir/$pkgname-$pkgver-$pkgrel-${CARCH}${PKGEXT}"
+
+ if [ ! -f "$pkgfile" ]; then
+ die "could not find %s-%s-%s-%s%s - aborting" $pkgname $pkgver $pkgrel $CARCH $PKGEXT
+ fi
+
+ repo-add "$pkgdb" "$pkgfile"
+else # DELETE
+ fname="$(basename $option)"
+ if [ "$fname" = "PKGBUILD" ]; then
+ if [ ! -f "$option" ]; then
+ die "%s not found" $option
+ fi
+
+ unset pkgname pkgver pkgrel options
+ source $option
+ else
+ pkgname=$option
+ fi
+
+ repo-remove "$pkgdb" "$pkgname"
+fi
+
+exit 0
+# vim: set ts=2 sw=2 noet:
diff --git a/contrib/zsh_completion b/contrib/zsh_completion
index 8dec06df..e1273184 100644
--- a/contrib/zsh_completion
+++ b/contrib/zsh_completion
@@ -6,7 +6,6 @@ typeset -A opt_args
# options for passing to _arguments: main pacman commands
_pacman_opts_commands=(
- '-A[Add a package to the system]'
'-Q[Query the package database]'
'-R[Remove a package from the system]'
'-S[Synchronize packages]'
@@ -29,7 +28,7 @@ _pacman_opts_common=(
'--noscriptlet[Do not execute the install scriptlet if one exists]'
)
-# options for passing to _arguments: options for --add and --update commands
+# options for passing to _arguments: options for --upgrade commands
_pacman_opts_pkgfile=(
'-d[Skip dependency checks]'
'-f[Overwrite conflicting files]'
@@ -78,7 +77,6 @@ _pacman_opts_sync_actions=(
# options for passing to _arguments: options for --sync command
_pacman_opts_sync_modifiers=(
'-d[Skip dependency checks]'
- '-e[Install dependencies only]'
'-f[Overwrite conflicting files]'
'-i[View package information]'
'-l[List all packages in a repository]'
@@ -91,15 +89,9 @@ _pacman_opts_sync_modifiers=(
'*--ignoregroup[Ignore a group upgrade]:package group:
_pacman_completions_all_groups'
'--asdeps[Install packages as non-explicitly installed]'
+ '--asexplicit[Install packages as explicitly installed]'
)
-# handles --action subcommand
-_pacman_action_add() {
- _arguments -s : \
- "$_pacman_opts_common[@]" \
- "$_pacman_opts_pkgfile[@]"
-}
-
# handles --help subcommand
_pacman_action_help() {
_arguments -s : \
@@ -290,7 +282,6 @@ _pacman_get_command() {
# main dispatcher
_pacman() {
case $words[2] in
- -A*) _pacman_action_add ;;
-Q*g*) # ipkg groups
_arguments -s : \
"$_pacman_opts_common[@]" \