Imported from pacman-2.6.tar.gz

This commit is contained in:
Judd Vinet 2003-09-03 02:09:29 +00:00
parent ffe1d50cff
commit f8bfe729e4
27 changed files with 1602 additions and 548 deletions

View file

@ -1,8 +1,27 @@
VERSION DESCRIPTION
------------------------------------------------------------------
2.5.1 - Added retries to the downloader to get around some
transient network errors. (this will likely be an option
in pacman.conf for later versions)
-----------------------------------------------------------------------------
2.6 - Added group handling, so one can run 'pacman -S kde' and
install all files from the KDE group
- Fixed a duplication bug in cascade package removal
- Added support for virtual provisions with "provides" tags
- When conflicts are encountered, pacman now offers the chance
to remove the conflicting packages (provides or literals)
- Added support for renamed/combined packages with a "replaces"
tag
- Added --nostrip option to makepkg
- Improved --search to list all packages from all repos when
a search term is omitted
- Added logging support through syslog()
- Added fakeroot support to makepkg (RomanK)
- Added MD5sum generation/validation to makepkg (RomanK)
- Fixed a progress bar bug (Aurelien Foret)
- Sorted makepkg's .FILELISTs (Aurelien Foret)
- Targets are now re-ordered w.r.t. dependencies when
using -A/-U
- Modified --search to work when called as -Sys
- Modified abs to use ABS_ROOT from /etc/abs/abs.conf (Aurelien)
- Other bug fixes
2.5.1 - Minor bug fixes
2.5 - Added an URL tag to package info
- Sped up package load times by about 500% by introducing
a .FILELIST into the package

View file

@ -34,7 +34,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
PACVER = 2.5.1
PACVER = 2.6
TOPDIR = @srcdir@
SRCDIR = $(TOPDIR)/src/

14
TODO
View file

@ -1,29 +1,15 @@
- fix the broken pipe bug
- add some logging mechanism (/var/log/pacman.log)
- handle version comparators in makepkg dep resolution (eg, glibc>=2.2.5)
- have "group" designations
- record md5sums of all files in a package
- add a way to clean /var/cache/pacman/src
- duplicate dep checks occur with sync (one in sync, one in add)
- if a package is removed with --nodeps and re-installed, the requiredby
fields of it's required packages are not updated
- add an option equivalent to 'pacman -Ql pkg | grep filename'
- add other options to config file: db location, overwrite behaviour, etc.
- use the COLUMNS env var for the progress bar
? use 'set -e' in makepkg?
x if a package fails, ask before aborting the full operation
- can't -- further dependent packages may fail b/c of the first failure
? ask, then remove conflicting packages with --sync
? use a provides tag (instead of an OR operator in depends)
- add a 'cascade' option to --remove that will remove a package and
all requiredby packages under it
- check $PACCONF env var
? use a 'trust pacman' config option for downgrading?
? build-time (source) dependencies in makepkg
? run ldd on every executable in a newly built package to find required so's
- add a --pretend option
- add a consistency/sanity check operation (md5 tracking for all files)
- add a --dbpath option
- use package caches more for performance
- clean up output a bit (message queue?)
- use a files.cache db for --owns and db_find_conflicts

19
cnvpkg
View file

@ -1,19 +0,0 @@
#!/bin/bash
TMPDIR=/tmp/.pkgcnv
TMPFILE=/tmp/.pkgcnvf
tl=`pwd`
for fn in $*; do
rm -rf $TMPDIR;
mkdir -p $TMPDIR;
echo "Converting $fn"
cd $TMPDIR
tar zxvf $tl/$fn | grep -v '^.PKGINFO' | grep -v '._install' >$TMPFILE
mv $TMPFILE ./.FILELIST
if [ -f ._install ]; then
tar cfz /new/$fn .PKGINFO .FILELIST ._install *
else
tar cfz /new/$fn .PKGINFO .FILELIST *
fi
done

View file

@ -8,7 +8,7 @@ makepkg \- package build utility
a build-capable linux platform, wget, and some build scripts. The advantage
to a script-based build is that you only really do the work once. Once you
have the build script for a package, you just need to run makepkg and it
will do the rest: download source files, check dependencies,
will do the rest: download and validate source files, check dependencies,
configure the buildtime settings, build the package, install the package
into a temporary root, make customizations, generate meta-info, and package
the whole thing up for \fBpacman\fP to use.
@ -31,20 +31,23 @@ the \fBabs\fP script included with pacman/makepkg.
.RS
.nf
pkgname=modutils
pkgver=2.4.13
pkgver=2.4.25
pkgrel=1
pkgdesc="Utilities for inserting and removing modules from the linux kernel"
url="http://www.kernel.org"
backup=(etc/modules.conf)
depends=('glibc>=2.2.5' 'bash' 'zlib')
source=(ftp://ftp.server.com/$pkgname-$pkgver.tar.gz modules.conf)
depends=('mawk' 'bash' 'glibc' 'zlib')
source=(ftp://ftp.kernel.org/pub/linux/utils/kernel/$pkgname/v2.4/$pkgname-$pkgver.tar.bz2 \\
modules.conf)
md5sums=('2c0cca3ef6330a187c6ef4fe41ecaa4d' \\
'35175bee593a7cc7d6205584a94d8625')
build() {
cd $startdir/src/$pkgname-$pkgver
./configure --prefix=/usr
./configure --prefix=/usr --enable-insmod-static
make || return 1
make prefix=$startdir/pkg/usr install
# copy our custom modules.conf into the package root
mv $startdir/pkg/usr/sbin $startdir/pkg
mkdir -p $startdir/pkg/etc
cp ../modules.conf $startdir/pkg/etc
}
@ -61,10 +64,14 @@ The line with \fIbackup=\fP specifies files that should be treated specially
when removing or upgrading packages. See \fBHANDLING CONFIG FILES\fP in
the \fIpacman\fP manpage for more information on this.
The sixth line lists the dependencies for this package. In order to build/run
The seventh line lists the dependencies for this package. In order to build/run
the package, all dependencies must be satisifed first. makepkg will check this
before attempting to build the package.
The \fIsource\fP array tells makepkg which files to download/extract before compiling
begins. The \fImd5sums\fP array provides md5sums for each of these files. These
are used to validate the integrity of the source files.
Once your PKGBUILD is created, you can run \fImakepkg\fP from the build directory.
makepkg will then check dependencies and look for the source files required to
build. If some are missing it will attempt to download them, provided there is
@ -193,7 +200,28 @@ This field contains an optional URL that is associated with the piece of softwar
being packaged. This is typically the project's website.
.TP
.B backup
.B install
Specifies a special install script that is to be included in the package.
This file should reside in the same directory as the PKGBUILD, and will be
copied into the package by makepkg. It does not need to be included in the
\fIsource\fP array. (eg, install=modutils.install)
.TP
.B source \fI(array)\fP
The \fIsource\fP line is an array of source files required to build the
package. Source files must reside in the same directory as the PKGBUILD
file, unless they have a fully-qualified URL. Then if the source file
does not already exist in /var/cache/pacman/src, the file is downloaded
by wget.
.TP
.B groups \fI(array)\fP
This is an array of symbolic names that represent groups of packages, allowing
you to install multiple packages by requesting a single target. For example,
one could install all KDE packages by installing the 'kde' group.
.TP
.B backup \fI(array)\fP
A space-delimited array of filenames (without a preceding slash). The
\fIbackup\fP line will be propagated to the package meta-info file for
pacman. This will designate all files listed there to be backed up if this
@ -201,14 +229,7 @@ package is ever removed from a system. See \fBHANDLING CONFIG FILES\fP in
the \fIpacman\fP manpage for more information.
.TP
.B install
Specified a special install script that is to be included in the package.
This file should reside in the same directory as the PKGBUILD, and will be
copied into the package by makepkg. It does not need to be included in the
\fIsource\fP array. (eg, install=modutils.install)
.TP
.B depends
.B depends \fI(array)\fP
An array of packages that this package depends on to build and run. Packages
in this list should be surrounded with single quotes and contain at least the
package name. They can also include a version requirement of the form
@ -217,18 +238,24 @@ package name. They can also include a version requirement of the form
See the PKGBUILD example above for an example of the \fIdepends\fP directive.
.TP
.B conflicts
.B conflicts \fI(array)\fP
An array of packages that will conflict with this package (ie, they cannot both
be installed at the same time). This directive follows the same format as
\fIdepends\fP except you cannot specify versions here, only package names.
.TP
.B source
The \fIsource\fP line is an array of source files required to build the
package. Source files must reside in the same directory as the PKGBUILD
file, unless they have a fully-qualified URL. Then if the source file
does not already exist in /var/cache/pacman/src, the file is downloaded
by wget.
.B provides \fI(array)\fP
An array of "virtual provisions" that this package provides. This allows a package
to provide dependency names other than it's own package name. For example, the
kernel-scsi and kernel-ide packages can each provide 'kernel' which allows packages
to simply depend on 'kernel' rather than "kernel-scsi OR kernel-ide OR ..."
.TP
.B replaces \fI(array)\fP
This is an array of packages that this package should replace, and can be used to handle
renamed/combined packages. For example, if the kernel package gets renamed
to kernel-ide, then subsequent 'pacman -Syu' calls will not pick up the upgrade, due
to the differing package names. \fIreplaces\fP handles this.
.SH MAKEPKG OPTIONS
.TP
@ -255,9 +282,20 @@ process if all of the dependencies aren't installed.
file already exists in the build directory. You can override this behaviour with
the \fB--force\fP switch.
.TP
.B "\-g, \-\-genmd5"
Download all source files (if required) and use \fImd5sum\fP to generate md5 hashes
for each of them. You can then redirect the output into your PKGBUILD for source
validation (makepkg -g >>PKGBUILD).
.TP
.B "\-h, \-\-help"
Output syntax and commandline options.
.TP
.B "\-i, \-\-install"
Install/Upgrade the package after a successful build.
.TP
.B "\-n, \-\-nostrip"
Do not strip binaries and libraries.
.TP
.B "\-p <buildscript>"
Read the package script \fI<buildscript>\fP instead of the default (\fIPKGBUILD\fP).
.TP

View file

@ -96,6 +96,10 @@ Remove packages from the cache. When pacman downloads packages,
it saves them in \fI/var/cache/pacman/pkg\fP. If you need to free up
diskspace, you can remove these packages by using the --clean option.
.TP
.B "\-g, \-\-groups"
Display all the members for each package group specified. If no group
names are provided, all groups and members will be listed.
.TP
.B "\-s, \-\-search <string>"
This will search each package in the package list for names or descriptions
that contains <string>.
@ -117,6 +121,10 @@ defined in \fI/etc/pacman.conf\fP. This should typically be used each
time you use \fB--sysupgrade\fP.
.SH QUERY OPTIONS
.TP
.B "\-g, \-\-groups"
Display all groups that a specified package is part of. If no package
names are provided, all groups and members will be listed.
.TP
.B "\-i, \-\-info"
Display information on a given package. If it is used with the \fB-p\fP
option then the .PKGINFO file will be printed.
@ -179,15 +187,15 @@ Server = ftp://ftp.archlinux.org/current
Server = ftp://ftp.mirror.com/archlinux/current
[custom]
Server = local:///home/pkgs
Server = file:///home/pkgs
.fi
.RE
.SH CONFIG: OPTIONS
.TP
.B "DBPath = /path/to/db/dir"
.B "DBPath = path/to/db/dir"
Overrides the default location of the toplevel database directory. The default is
\fI/var/lib/pacman\fP.
\fIvar/lib/pacman\fP.
.TP
.B "IgnorePkg = <package> [package] ..."
Instructs pacman to ignore any upgrades for this package when performing a
@ -199,13 +207,17 @@ Disables passive ftp connections when downloading packages. (aka Active Mode)
.B "NoUpgrade = <file> [file] ..."
All files listed with a \fBNoUpgrade\fP directive will never be touched during a package
install/upgrade. \fINote:\fP do not include the leading slash when specifying files.
.TP
.B "UseSyslog"
Log action messages through syslog(). This will insert pacman log entries into your
/var/log/messages or equivalent.
.SH CONFIG: REPOSITORIES
Each repository section defines a section name and at least one location where the packages
can be found. The section name is defined by the string within square brackets (eg, the two
above are 'current' and 'custom'). Locations are defined with the \fIServer\fP directive and
follow a URL naming structure. Currently only ftp is supported for remote servers. If you
want to use a local directory, you can specify the full path with a 'local://' prefix, as
want to use a local directory, you can specify the full path with a 'file://' prefix, as
shown above.
.SH USING YOUR OWN REPOSITORY
Let's say you have a bunch of custom packages in \fI/home/pkgs\fP and their respective PKGBUILD

View file

@ -10,21 +10,23 @@ export FTPAGENT="/usr/bin/wget --continue --passive-ftp --tries=3 --waitretry=3"
#export FTPAGENT="/usr/bin/snarf"
#export FTPAGENT="/usr/bin/lftpget -c"
# Pentium Pro/Pentium II/Pentium III+/Pentium 4/Athlon exclusive (binaries
# will use the P6 instruction set and only run on P6+ systems)
export CHOST="i686-pc-linux-gnu"
export CFLAGS="-march=i686 -O2 -pipe"
export CXXFLAGS="-march=i686 -O2 -pipe"
# Pentium Pro/Pentium II/Pentium III+/Pentium 4/Athlon optimized (but binaries
# will run on any x86 system)
#export CHOST="i686-pc-linux-gnu"
#export CFLAGS="-mcpu=i686 -O2 -pipe"
#export CXXFLAGS="-mcpu=i686 -O2 -pipe"
# Pentium Pro/Pentium II/Pentium III+/Pentium 4/Athlon exclusive (binaries
# will use the P6 instruction set and only run on P6+ systems)
export CHOST="i686-pc-linux-gnu"
export CFLAGS="-march=i686 -O2 -pipe"
export CXXFLAGS="-march=i686 -O2 -pipe"
# SMP Systems
#export MAKEFLAGS="-j 2"
# Enable fakeroot for building packages as a non-root user
export USE_FAKEROOT="y"
# if you want your name to show up in the packages you build, set this.
#export PACKAGER="John Doe <john@doe.com>"

View file

@ -8,9 +8,11 @@
# GENERAL OPTIONS
#
[options]
UseSyslog
NoUpgrade = etc/passwd etc/group etc/shadow
NoUpgrade = etc/fstab etc/rc.conf etc/rc.local
NoUpgrade = etc/lilo.conf etc/raidtab
NoUpgrade = etc/fstab etc/raidtab
NoUpgrade = etc/rc.conf etc/rc.local
NoUpgrade = etc/lilo.conf boot/grub/menu.lst
#IgnorePkg = lilo gcc
#
@ -28,6 +30,20 @@ Server = ftp://gd.tuwien.ac.at/opsys/linux/archlinux/current
Server = ftp://saule.mintis.lt/pub/linux/current
Server = ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/archlinux/current
# The "unofficial" package set
#
[unofficial]
Server = ftp://ftp.archlinux.org/unofficial
Server = ftp://ftp.ibiblio.org/pub/linux/distributions/archlinux/unofficial
Server = ftp://ftp.webtrek.com/pub/mirrors/archlinux/unofficial
Server = ftp://ftp.mpi-sb.mpg.de/pub/linux/mirror/ftp.ibiblio.org/pub/Linux/distributions/archlinux/unofficial
Server = ftp://ftp.oit.unc.edu/pub/Linux/distributions/archlinux/unofficial
Server = ftp://ftp.tu-chemnitz.de/pub/linux/sunsite.unc-mirror/distributions/archlinux/unofficial
Server = ftp://ftp.parrswood.net/Mirrors/ftp.archlinux.org/unofficial
Server = ftp://gd.tuwien.ac.at/opsys/linux/archlinux/unofficial
Server = ftp://saule.mintis.lt/pub/linux/unofficial
Server = ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/archlinux/unofficial
# If you use the 'stable' tree, you should disable the 'current'
# tree to avoid conflicts
#
@ -43,26 +59,12 @@ Server = ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/archlinux/current
#Server = ftp://saule.mintis.lt/pub/linux/stable
#Server = ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/archlinux/stable
# Uncomment this block to access the 'unofficial' package set
#
#[unofficial]
#Server = ftp://ftp.ibiblio.org/pub/linux/distributions/archlinux/unofficial
#Server = ftp://ftp.webtrek.com/pub/mirrors/archlinux/unofficial
#Server = ftp://ftp.archlinux.org/unofficial
#Server = ftp://ftp.mpi-sb.mpg.de/pub/linux/mirror/ftp.ibiblio.org/pub/Linux/distributions/archlinux/unofficial
#Server = ftp://ftp.oit.unc.edu/pub/Linux/distributions/archlinux/unofficial
#Server = ftp://ftp.tu-chemnitz.de/pub/linux/sunsite.unc-mirror/distributions/archlinux/unofficial
#Server = ftp://ftp.parrswood.net/Mirrors/ftp.archlinux.org/unofficial
#Server = ftp://gd.tuwien.ac.at/opsys/linux/archlinux/unofficial
#Server = ftp://saule.mintis.lt/pub/linux/unofficial
#Server = ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/archlinux/unofficial
# Uncomment this block to access the 'unstable' package set
#
#[unstable]
#Server = ftp://ftp.archlinux.org/unstable
#Server = ftp://ftp.ibiblio.org/pub/linux/distributions/archlinux/unstable
#Server = ftp://ftp.webtrek.com/pub/mirrors/archlinux/unstable
#Server = ftp://ftp.archlinux.org/unstable
#Server = ftp://ftp.mpi-sb.mpg.de/pub/linux/mirror/ftp.ibiblio.org/pub/Linux/distributions/archlinux/unstable
#Server = ftp://ftp.oit.unc.edu/pub/Linux/distributions/archlinux/unstable
#Server = ftp://ftp.tu-chemnitz.de/pub/linux/sunsite.unc-mirror/distributions/archlinux/unstable
@ -74,5 +76,5 @@ Server = ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/archlinux/current
# An example of a custom package repository. See the pacman manpage for
# tips on creating your own repositories.
#[custom]
#Server = local:///home/custompkgs
#Server = file:///home/custompkgs

View file

@ -1,6 +1,26 @@
#!/bin/bash
#
# gensync
#
# Copyright (c) 2002-2003 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, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.
#
myver='2.5.1'
myver='2.6'
usage() {
echo "gensync $myver"
@ -24,14 +44,15 @@ usage() {
db_write_entry()
{
unset pkgname pkgver pkgrel
unset depends conflicts
unset pkgname pkgver pkgrel pkgdesc
unset groups replaces provides depends conflicts
source $1 || return 1
cd /tmp/.gensync
mkdir $pkgname-$pkgver-$pkgrel
cd $pkgname-$pkgver-$pkgrel
# desc
echo "%NAME%" >desc
: >desc
echo "%NAME%" >>desc
echo "$pkgname" >>desc
echo "" >>desc
echo "%VERSION%" >>desc
@ -40,17 +61,43 @@ db_write_entry()
echo "%DESC%" >>desc
echo "$pkgdesc" >>desc
echo "" >>desc
if [ ${#groups[*]} -gt 0 ]; then
echo "%GROUPS%" >>desc
for it in "${groups[@]}"; do
echo "$it" >>desc
done
echo "" >>desc
fi
if [ ${#replaces[*]} -gt 0 ]; then
echo "%REPLACES%" >>desc
for it in "${replaces[@]}"; do
echo "$it" >>desc
done
echo "" >>desc
fi
# depends
echo "%DEPENDS%" >depends
for depend in "${depends[@]}"; do
echo "$depend" >>depends
done
echo "" >>depends
echo "%CONFLICTS%" >>depends
for conflict in "${conflicts[@]}"; do
echo "$conflict" >>depends
done
echo "" >>depends
: >depends
if [ ${#depends[*]} -gt 0 ]; then
echo "%DEPENDS%" >>depends
for it in "${depends[@]}"; do
echo "$it" >>depends
done
echo "" >>depends
fi
if [ ${#conflicts[*]} -gt 0 ]; then
echo "%CONFLICTS%" >>depends
for it in "${conflicts[@]}"; do
echo "$it" >>depends
done
echo "" >>depends
fi
if [ ${#provides[*]} -gt 0 ]; then
echo "%PROVIDES%" >>depends
for it in "${provides[@]}"; do
echo "$it" >>depends
done
echo "" >>depends
fi
}
if [ $# -lt 2 ]; then

View file

@ -1,17 +1,68 @@
#!/bin/bash
#
# makepkg
#
# Copyright (c) 2002-2003 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, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.
#
myver='2.5.1'
myver='2.6'
startdir=`pwd`
msg() {
echo "$1" >&2
}
[ -f /etc/makepkg.conf ] && source /etc/makepkg.conf
INFAKEROOT=
if [ "$1" = "-F" ]; then
INFAKEROOT=1
shift
fi
if [ "`id -u`" != "0" ]; then
if [ "$USE_FAKEROOT" = "y" -o "$USE_FAKEROOT" = "Y" ]; then
if [ `type -p fakeroot` ]; then
msg "==> Entering fakeroot environment"
fakeroot -- $0 -F $@
exit $?
else
msg "==> WARNING: Fakeroot is not installed. Building as an unprivileged user"
msg "==> will result in non-root ownership of the packaged files."
msg "==> Install the fakeroot package to correctly build as a non-root"
msg "==> user."
msg ""
sleep 1
fi
else
msg "==> WARNING: Running makepkg as an unprivileged user will result in non-root"
msg "==> ownership of the packaged files. Try using the fakeroot"
msg "==> environment. (USE_FAKEROOT=y in makepkg.conf)"
msg ""
sleep 1
fi
fi
strip_url() {
echo $1 | sed 's|^.*://.*/||g'
}
msg() {
echo $* >&2
}
checkdeps() {
local missdep=`pacman -T $*`
@ -50,31 +101,34 @@ usage() {
echo "makepkg version $myver"
echo "usage: $0 [options]"
echo "options:"
echo " -b, --builddeps Build missing dependencies from source"
echo " -c, --clean Clean up work files after build"
echo " -C, --cleancache Clean up source files from the cache"
echo " -s, --syncdeps Install missing dependencies with pacman"
echo " -b, --builddeps Build missing dependencies from source"
echo " -d, --nodeps Skip all dependency checks"
echo " -i, --install Install package after successful build"
echo " -f, --force Overwrite existing package"
echo " -w <destdir> Write package to <destdir> instead of the working dir"
echo " -p <buildscript> Use an alternate build script (instead of PKGBUILD)"
echo " -g, --genmd5 Generate MD5sums for source files"
echo " -h, --help This help"
echo " -i, --install Install package after successful build"
echo " -n, --nostrip Do not strip binaries/libraries"
echo " -p <buildscript> Use an alternate build script (instead of PKGBUILD)"
echo " -s, --syncdeps Install missing dependencies with pacman"
echo " -w <destdir> Write package to <destdir> instead of the working dir"
echo
echo " if -p is not specified, makepkg will look for a PKGBUILD"
echo " file in the current directory."
echo
exit 0
}
# Options
CLEANUP=0
CLEANCACHE=0
INSTALL=0
GENMD5=0
DEP_BIN=0
DEP_SRC=0
NODEPS=0
FORCE=0
NOSTRIP=0
PKGDEST=$startdir
BUILDSCRIPT="./PKGBUILD"
@ -87,12 +141,18 @@ while [ "$#" -ne "0" ]; do
--nodeps) NODEPS=1 ;;
--install) INSTALL=1 ;;
--force) FORCE=1 ;;
--nostrip) NOSTRIP=1 ;;
--genmd5) GENMD5=1 ;;
--help)
usage
exit 0
;;
--*)
usage
exit 1
;;
-*)
while getopts "cCsbdifp:w:-" opt; do
while getopts "cCsbdhifgnp:w:-" opt; do
case $opt in
c) CLEANUP=1 ;;
C) CLEANCACHE=1 ;;
@ -100,9 +160,15 @@ while [ "$#" -ne "0" ]; do
b) DEP_SRC=1 ;;
d) NODEPS=1 ;;
i) INSTALL=1 ;;
g) GENMD5=1 ;;
f) FORCE=1 ;;
n) NOSTRIP=1 ;;
w) PKGDEST=$OPTARG ;;
p) BUILDSCRIPT=$OPTARG ;;
h)
usage
exit 0
;;
-)
OPTIND=0
break
@ -122,13 +188,18 @@ while [ "$#" -ne "0" ]; do
done
if [ "$CLEANCACHE" = "1" ]; then
msg "==> Cleaning up source files from the cache"
rm -rf /var/cache/pacman/src/*
exit 0
if [ "`id -u`" = "0" -a "$INFAKEROOT" != "1" ]; then
msg "==> Cleaning up source files from the cache."
rm -rf /var/cache/pacman/src/*
exit 0
else
msg "==> You must be root to clean the cache."
exit 1
fi
fi
unset pkgname pkgver pkgrel pkgdesc url
unset depends conflicts backup source install build
unset pkgname pkgver pkgrel pkgdesc url groups provides md5sums
unset replaces depends conflicts backup source install build
umask 0022
if [ ! -f $BUILDSCRIPT ]; then
@ -148,11 +219,13 @@ if [ `echo $pkgrel | grep '-'` ]; then
exit 1
fi
if [ -f $PKGDEST/${pkgname}-${pkgver}-${pkgrel}.pkg.tar.gz -a "$FORCE" = "0" ]; then
if [ -f $PKGDEST/${pkgname}-${pkgver}-${pkgrel}.pkg.tar.gz -a "$FORCE" = "0" -a "$GENMD5" = "0" ]; then
msg "==> ERROR: a package has already been built. (use -f to overwrite)"
exit 1
fi
msg "==> Making package: $pkgname (`date`)"
unset deplist
if [ `type -p pacman` -a "$NODEPS" = "0" ]; then
msg "==> Checking Dependencies..."
@ -210,21 +283,19 @@ else
msg "==> WARNING: pacman was not found in PATH. skipping dependency checks."
fi
d=`date`
cd $startdir
msg "==> Making package $pkgname ($d)"
# extract source
msg "==> Acquiring/Extracting Sources..."
msg "==> Retrieving Sources..."
mkdir -p src
cd $startdir/src
for netfile in ${source[@]}; do
file=`strip_url $netfile`
if [ -f ../$file ]; then
msg "==> Found $file in build dir"
msg " |=> Found $file in build dir"
cp ../$file .
elif [ -f /var/cache/pacman/src/$file ]; then
msg "==> Using local copy of $file"
msg " |=> Using local copy of $file"
cp /var/cache/pacman/src/$file .
else
# check for a download utility
@ -245,39 +316,108 @@ for netfile in ${source[@]}; do
msg "==> Aborting..."
exit 1
fi
msg "==> Downloading $file"
msg " |=> Downloading $file"
$FTPAGENT $netfile 2>&1
if [ ! -f $file ]; then
msg "==> ERROR: Failed to download $file"
msg "==> Aborting..."
exit 1
fi
mkdir -p /var/cache/pacman/src && cp $file /var/cache/pacman/src
if [ "`id -u`" = "0" -a "$INFAKEROOT" != "1" ]; then
mkdir -p /var/cache/pacman/src && cp $file /var/cache/pacman/src
else
cp $file ..
fi
fi
unset cmd
case $file in
*.tar.gz|*.tar.Z|*.tgz)
cmd="tar --use-compress-program=gzip -xf $file" ;;
*.tar.bz2)
cmd="tar --use-compress-program=bzip2 -xf $file" ;;
*.tar)
cmd="tar -xf $file" ;;
*.zip)
cmd="unzip -qq $file" ;;
*.gz)
cmd="gunzip $file" ;;
esac
if [ "$cmd" != "" ]; then
msg "==> $cmd"
$cmd
if [ $? -ne 0 ]; then
msg "==> ERROR: Failed to extract $file"
msg "==> Aborting..."
exit 1
if [ "$GENMD5" = "0" ]; then
unset cmd
case $file in
*.tar.gz|*.tar.Z|*.tgz)
cmd="tar --use-compress-program=gzip -xf $file" ;;
*.tar.bz2)
cmd="tar --use-compress-program=bzip2 -xf $file" ;;
*.tar)
cmd="tar -xf $file" ;;
*.zip)
cmd="unzip -qq $file" ;;
*.gz)
cmd="gunzip $file" ;;
esac
if [ "$cmd" != "" ]; then
msg " |=> $cmd"
$cmd
if [ $? -ne 0 ]; then
msg "==> ERROR: Failed to extract $file"
msg "==> Aborting..."
exit 1
fi
fi
fi
done
if [ "$GENMD5" = "1" ]; then
if [ ! `type -p md5sum` ]; then
msg "==> ERROR: Cannot find the md5sum program."
exit 1
fi
msg "==> Generating MD5sums for source files"
msg ""
ct=0
numsrc=${#source[@]}
for netfile in ${source[@]}; do
file=`strip_url $netfile`
sum=`md5sum $file | cut -d' ' -f 1`
if [ $ct -eq 0 ]; then
echo -n "md5sums=("
else
echo -ne "\t"
fi
echo -n "'$sum'"
ct=$(($ct+1))
if [ $ct -eq $numsrc ]; then
echo ')'
else
echo ' \'
fi
done
msg ""
exit 0
fi
# MD5 Validation
if [ ${#md5sums[@]} -ne ${#source[@]} ]; then
msg "==> WARNING: MD5sums are missing or incomplete. Cannot verify source integrity."
# sleep 1
elif [ `type -p md5sum` ]; then
msg "==> Validating source files with MD5sums"
errors=0
idx=0
for netfile in ${source[@]}; do
file=`strip_url $netfile`
echo -n " |=> $file ... " >&2
echo "${md5sums[$idx]} $file" | md5sum -c - >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "FAILED" >&2
errors=1
else
echo "Passed" >&2
fi
idx=$(($idx+1))
done
if [ $errors -gt 0 ]; then
msg "==> ERROR: One or more files did not pass the validity check!"
exit 1
fi
else
msg "==> WARNING: The md5sum program is missing. Cannot verify source files!"
sleep 1
fi
if [ "`id -u`" = "0" ]; then
# chown all source files to root.root
chown -R root.root $startdir/src
fi
# check for existing pkg directory
if [ -d $startdir/pkg ]; then
msg "==> Removing existing pkg directory..."
@ -286,7 +426,7 @@ fi
mkdir -p $startdir/pkg
# build
msg "==> Building Package..."
msg "==> Starting build()..."
build 2>&1
if [ $? -gt 0 ]; then
msg "==> Build Failed. Aborting..."
@ -330,15 +470,18 @@ if [ -d pkg/usr/man ]; then
done
fi
# strip binaries
cd $startdir
msg "==> Stripping debugging symbols from libraries..."
find pkg/{,usr,usr/local,opt/*}/lib -type f -exec /usr/bin/strip --strip-debug '{}' ';' 2>&1
msg "==> Stripping symbols from binaries..."
find pkg/{,usr,usr/local,opt/*}/{bin,sbin} -type f -exec /usr/bin/strip '{}' ';' 2>&1
# strip binaries
if [ "$NOSTRIP" = "0" ]; then
msg "==> Stripping debugging symbols from libraries..."
find pkg/{,usr,usr/local,opt/*}/lib -type f -exec /usr/bin/strip --strip-debug '{}' \; 2>&1
msg "==> Stripping symbols from binaries..."
find pkg/{,usr,usr/local,opt/*}/{bin,sbin} -type f -exec /usr/bin/strip '{}' \; 2>&1
fi
# get some package meta info
builddate=`date -u "+%a %b %d %k:%M:%S %Y"`
builddate=`LC_ALL= ; date -u "+%a %b %d %k:%M:%S %Y"`
if [ "$PACKAGER" != "" ]; then
packager="$PACKAGER"
else
@ -360,14 +503,23 @@ echo "builddate = $builddate" >>.PKGINFO
echo "packager = $packager" >>.PKGINFO
echo "size = $size" >>.PKGINFO
for depend in "${depends[@]}"; do
echo "depend = $depend" >>.PKGINFO
for it in "${replaces[@]}"; do
echo "replaces = $it" >>.PKGINFO
done
for conflict in "${conflicts[@]}"; do
echo "conflict = $conflict" >>.PKGINFO
for it in "${groups[@]}"; do
echo "group = $it" >>.PKGINFO
done
for bakfile in "${backup[@]}"; do
echo "backup = $bakfile" >>.PKGINFO
for it in "${depends[@]}"; do
echo "depend = $it" >>.PKGINFO
done
for it in "${conflicts[@]}"; do
echo "conflict = $it" >>.PKGINFO
done
for it in "${provides[@]}"; do
echo "provides = $it" >>.PKGINFO
done
for it in "${backup[@]}"; do
echo "backup = $it" >>.PKGINFO
done
# check for an install script
@ -377,9 +529,11 @@ if [ "$install" != "" ]; then
fi
# build a filelist
msg "==> Building filelist..."
msg "==> Generating .FILELIST file..."
cd $startdir/pkg
tar cv * >/dev/null 2>.FILELIST
tar cv * >/dev/null 2>.FILELIST.tmp
cat .FILELIST.tmp | sort >.FILELIST
rm -f .FILELIST.tmp
# tar it up
msg "==> Compressing package..."
@ -389,7 +543,7 @@ if [ -f $startdir/pkg/.INSTALL ]; then
else
cmd="tar czvf $PKGDEST/$pkgname-$pkgver-$pkgrel.pkg.tar.gz .PKGINFO .FILELIST *"
fi
$cmd >../filelist
$cmd | sort >../filelist
cd $startdir
if [ "$CLEANUP" = "1" ]; then
@ -397,7 +551,7 @@ if [ "$CLEANUP" = "1" ]; then
rm -rf src pkg filelist
fi
msg "==> Finished making $pkgname (`date`)"
msg "==> Finished making: $pkgname (`date`)"
if [ "$INSTALL" = "1" ]; then
msg "==> Running pacman --upgrade"

View file

@ -1,102 +1,130 @@
#!/bin/bash
#
# makeworld
#
# Copyright (c) 2002-2003 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, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.
#
toplevel=`pwd`
version="2.5.1"
version="2.6"
usage() {
echo "makeworld version $version"
echo "usage: $0 [options] <destdir> <category> [category] ..."
echo "options:"
echo " -b, --builddeps Build missing dependencies from source"
echo " -c, --clean Clean up work files after build"
echo " -d, --nodeps Skip all dependency checks"
echo " -f, --force Overwrite existing packages"
echo " -i, --install Install package after successful build"
echo " -h, --help This help"
echo " -s, --syncdeps Install missing dependencies with pacman"
echo
echo " where <category> is one or more directory names under the ABS root"
echo " eg: makeworld -c /packages base lib editors"
echo
echo " this should be run from the toplevel directory of ABS (usually /usr/abs)"
echo "makeworld version $version"
echo "usage: $0 [options] <destdir> <category> [category] ..."
echo "options:"
echo " -b, --builddeps Build missing dependencies from source"
echo " -c, --clean Clean up work files after build"
echo " -d, --nodeps Skip all dependency checks"
echo " -f, --force Overwrite existing packages"
echo " -i, --install Install package after successful build"
echo " -h, --help This help"
echo " -s, --syncdeps Install missing dependencies with pacman"
echo
echo " where <category> is one or more directory names under the ABS root"
echo " eg: makeworld -c /packages base lib editors"
echo
echo " this should be run from the toplevel directory of ABS (usually /usr/abs)"
}
if [ $# -lt 2 -o "$1" = "--help" -o "$1" = "-h" ]; then
usage
exit 1
if [ $# -lt 2 ]; then
usage
exit 1
fi
MAKEPKG_OPTS=
for arg in $*; do
case $arg in
--clean) MAKEPKG_OPTS="$MAKEPKG_OPTS -c" ;;
--install) MAKEPKG_OPTS="$MAKEPKG_OPTS -i" ;;
--syncdeps) MAKEPKG_OPTS="$MAKEPKG_OPTS -s" ;;
--builddeps) MAKEPKG_OPTS="$MAKEPKG_OPTS -b" ;;
--nodeps) MAKEPKG_OPTS="$MAKEPKG_OPTS -d" ;;
--force) MAKEPKG_OPTS="$MAKEPKG_OPTS -f" ;;
--*)
usage
exit 1
;;
-*)
while getopts "cisbdf-" opt; do
case $opt in
c) MAKEPKG_OPTS="$MAKEPKG_OPTS -c" ;;
i) MAKEPKG_OPTS="$MAKEPKG_OPTS -i" ;;
s) MAKEPKG_OPTS="$MAKEPKG_OPTS -s" ;;
b) MAKEPKG_OPTS="$MAKEPKG_OPTS -b" ;;
d) MAKEPKG_OPTS="$MAKEPKG_OPTS -d" ;;
f) MAKEPKG_OPTS="$MAKEPKG_OPTS -f" ;;
-)
OPTIND=0
break
;;
esac
done
;;
*)
dest=$arg
shift
break
;;
esac
shift
if [ "$dest" != "" ]; then
break;
fi
case $arg in
--clean) MAKEPKG_OPTS="$MAKEPKG_OPTS -c" ;;
--install) MAKEPKG_OPTS="$MAKEPKG_OPTS -i" ;;
--syncdeps) MAKEPKG_OPTS="$MAKEPKG_OPTS -s" ;;
--builddeps) MAKEPKG_OPTS="$MAKEPKG_OPTS -b" ;;
--nodeps) MAKEPKG_OPTS="$MAKEPKG_OPTS -d" ;;
--force) MAKEPKG_OPTS="$MAKEPKG_OPTS -f" ;;
--help)
usage
exit 0
;;
--*)
usage
exit 1
;;
-*)
while getopts "chisbdf-" opt; do
case $opt in
c) MAKEPKG_OPTS="$MAKEPKG_OPTS -c" ;;
i) MAKEPKG_OPTS="$MAKEPKG_OPTS -i" ;;
s) MAKEPKG_OPTS="$MAKEPKG_OPTS -s" ;;
b) MAKEPKG_OPTS="$MAKEPKG_OPTS -b" ;;
d) MAKEPKG_OPTS="$MAKEPKG_OPTS -d" ;;
f) MAKEPKG_OPTS="$MAKEPKG_OPTS -f" ;;
h)
usage
exit 0
;;
-)
OPTIND=0
break
;;
esac
done
;;
*)
dest=$arg
shift
break
;;
esac
shift
if [ "$dest" != "" ]; then
break
fi
done
if [ "$dest" = "" ]; then
usage
exit 1
usage
exit 1
fi
sd=`date +"[%b %d %H:%M]"`
for category in $*; do
for port in `find $toplevel/$category -type d -maxdepth 1 -mindepth 1 | sort`; do
cd $port
if [ -f PKGBUILD ]; then
. PKGBUILD
buildstatus=0
if [ ! -f $dest/$pkgname-$pkgver-$pkgrel.pkg.tar.gz ]; then
makepkg $MAKEPKG_OPTS -w $dest 2>>$toplevel/makepkg.log
if [ $? -gt 0 ]; then
buildstatus=2
else
buildstatus=1
fi
fi
d=`date +"[%b %d %H:%M]"`
echo -n "$d " >>$toplevel/build.log
case $buildstatus in
0) echo "$pkgname already built -- skipping" >>$toplevel/build.log ;;
1) echo "$pkgname was built successfully" >>$toplevel/build.log ;;
2) echo "$pkgname build failed" >>$toplevel/build.log ;;
esac
fi
done
for port in `find $toplevel/$category -type d -maxdepth 1 -mindepth 1 | sort`; do
cd $port
if [ -f PKGBUILD ]; then
. PKGBUILD
buildstatus=0
if [ ! -f $dest/$pkgname-$pkgver-$pkgrel.pkg.tar.gz ]; then
makepkg $MAKEPKG_OPTS -w $dest 2>>$toplevel/makepkg.log
if [ $? -gt 0 ]; then
buildstatus=2
else
buildstatus=1
fi
fi
d=`date +"[%b %d %H:%M]"`
echo -n "$d " >>$toplevel/build.log
case $buildstatus in
0) echo "$pkgname already built -- skipping" >>$toplevel/build.log ;;
1) echo "$pkgname was built successfully" >>$toplevel/build.log ;;
2) echo "$pkgname build failed" >>$toplevel/build.log ;;
esac
fi
done
done
ed=`date +"[%b %d %H:%M]"`
@ -104,3 +132,4 @@ echo "makeworld complete." >>$toplevel/build.log
echo " started: $sd" >>$toplevel/build.log
echo " finished: $ed" >>$toplevel/build.log
exit 0

View file

@ -1,5 +1,5 @@
/*
* pacman
* convertdb.c
*
* Copyright (c) 2002 by Judd Vinet <jvinet@zeroflux.org>
*

112
src/db.c
View file

@ -1,5 +1,5 @@
/*
* pacman
* db.c
*
* Copyright (c) 2002 by Judd Vinet <jvinet@zeroflux.org>
*
@ -29,13 +29,7 @@
#include "util.h"
#include "db.h"
/* Verify database integrity and build a list of
* installed packages
*
* returns: 0 on success
* 1 if db is not initialized
* 2 if db is corrupt
*/
/* Open a database and return a pacdb_t handle */
pacdb_t* db_open(char *root, char *pkgdir, char *treename)
{
pacdb_t *db = NULL;
@ -111,7 +105,7 @@ PMList* db_loadpkgs(pacdb_t *db, PMList *pkgcache)
cache = list_add(cache, arr[i]);
}
free(arr);
FREE(arr);
return(cache);
}
@ -216,6 +210,11 @@ pkginfo_t* db_read(pacdb_t *db, struct dirent *ent, unsigned int inforeq)
return(NULL);
}
trim(info->desc);
} else if(!strcmp(line, "%GROUPS%")) {
while(fgets(line, 512, fp) && strlen(trim(line))) {
char *s = strdup(line);
info->groups = list_add(info->groups, s);
}
} else if(!strcmp(line, "%URL%")) {
if(fgets(info->url, sizeof(info->url), fp) == NULL) {
return(NULL);
@ -243,6 +242,14 @@ pkginfo_t* db_read(pacdb_t *db, struct dirent *ent, unsigned int inforeq)
}
trim(tmp);
info->size = atol(tmp);
} else if(!strcmp(line, "%REPLACES%")) {
/* the REPLACES tag is special -- it only appears in sync repositories,
* not the local one.
*/
while(fgets(line, 512, fp) && strlen(trim(line))) {
char *s = strdup(line);
info->replaces = list_add(info->replaces, s);
}
}
}
fclose(fp);
@ -303,6 +310,12 @@ pkginfo_t* db_read(pacdb_t *db, struct dirent *ent, unsigned int inforeq)
info->conflicts = list_add(info->conflicts, s);
}
}
if(!strcmp(line, "%PROVIDES%")) {
while(fgets(line, 512, fp) && strlen(trim(line))) {
char *s = strdup(line);
info->provides = list_add(info->provides, s);
}
}
}
fclose(fp);
}
@ -347,6 +360,11 @@ int db_write(pacdb_t *db, pkginfo_t *info)
fprintf(fp, "%s\n\n", info->version);
fputs("%DESC%\n", fp);
fprintf(fp, "%s\n\n", info->desc);
fputs("%GROUPS%\n", fp);
for(lp = info->groups; lp; lp = lp->next) {
fprintf(fp, "%s\n", (char*)lp->data);
}
fprintf(fp, "\n");
fputs("%URL%\n", fp);
fprintf(fp, "%s\n\n", info->url);
fputs("%BUILDDATE%\n", fp);
@ -400,6 +418,11 @@ int db_write(pacdb_t *db, pkginfo_t *info)
fprintf(fp, "%s\n", (char*)lp->data);
}
fprintf(fp, "\n");
fputs("%PROVIDES%\n", fp);
for(lp = info->provides; lp; lp = lp->next) {
fprintf(fp, "%s\n", (char*)lp->data);
}
fprintf(fp, "\n");
fclose(fp);
/* INSTALL */
@ -426,7 +449,6 @@ PMList* db_find_conflicts(pacdb_t *db, PMList *targets, char *root)
*
pkginfo_t *info = NULL;
char *dbstr = NULL;
vprint("Checking database against targets...\n");
rewinddir(db->dir);
while((info = db_scan(db, NULL, INFRQ_DESC | INFRQ_FILES)) != NULL) {
for(i = info->files; i; i = i->next) {
@ -453,7 +475,6 @@ PMList* db_find_conflicts(pacdb_t *db, PMList *targets, char *root)
}*/
/* CHECK 2: check every target against every target */
/* orelien - vprint("Checking targets against targets...\n"); */
for(i = targets; i; i = i->next) {
pkginfo_t *p1 = (pkginfo_t*)i->data;
for(j = i; j; j = j->next) {
@ -480,7 +501,6 @@ PMList* db_find_conflicts(pacdb_t *db, PMList *targets, char *root)
}
/* CHECK 3: check every target against the filesystem */
/* orelien - vprint("Checking targets against filesystem...\n"); */
for(i = targets; i; i = i->next) {
pkginfo_t *p = (pkginfo_t*)i->data;
pkginfo_t *dbpkg = NULL;
@ -509,4 +529,72 @@ PMList* db_find_conflicts(pacdb_t *db, PMList *targets, char *root)
return(conflicts);
}
PMList *whatprovides(pacdb_t *db, char* package)
{
PMList *pkgs, *i = NULL;
pkginfo_t *info;
rewinddir(db->dir);
while((info = db_scan(db, NULL, INFRQ_DESC | INFRQ_DEPENDS)) != NULL) {
if(is_in(package, info->provides)) {
i = list_add(i, strdup(info->name));
}
freepkg(info);
}
pkgs = list_sort(i);
list_free(i);
return(pkgs);
}
/*
* return a list of all groups present in *db
*
*/
PMList *find_groups(pacdb_t *db)
{
PMList *groups, *i = NULL;
PMList *lp = NULL;
pkginfo_t *info;
rewinddir(db->dir);
while((info = db_scan(db, NULL, INFRQ_DESC)) != NULL) {
for(lp = info->groups; lp; lp = lp->next) {
if(!is_in((char*)lp->data, i)) {
i = list_add(i, strdup((char*)lp->data));
}
}
freepkg(info);
}
groups = list_sort(i);
list_free(i);
return(groups);
}
/*
* return a list of all members of the specified group
*
*/
PMList *pkg_ingroup(pacdb_t *db, char *group)
{
PMList *pkg, *i = NULL;
PMList *lp = NULL;
pkginfo_t *info;
rewinddir(db->dir);
while((info = db_scan(db, NULL, INFRQ_DESC)) != NULL) {
for(lp = info->groups; lp; lp = lp->next) {
if(!strcmp((char*)lp->data, group)) {
i = list_add(i, strdup(info->name));
}
}
freepkg(info);
}
pkg = list_sort(i);
list_free(i);
return(pkg);
}
/* vim: set ts=2 sw=2 noet: */

View file

@ -1,5 +1,5 @@
/*
* pacman
* db.h
*
* Copyright (c) 2002 by Judd Vinet <jvinet@zeroflux.org>
*
@ -42,6 +42,9 @@ pkginfo_t* db_scan(pacdb_t *db, char *target, unsigned int inforeq);
pkginfo_t* db_read(pacdb_t *db, struct dirent *ent, unsigned int inforeq);
int db_write(pacdb_t *db, pkginfo_t *info);
PMList* db_find_conflicts(pacdb_t *db, PMList* targets, char *root);
PMList *whatprovides(pacdb_t *db, char* package);
PMList *find_groups(pacdb_t *db);
PMList *pkg_ingroup(pacdb_t *db, char *group);
#endif
/* vim: set ts=2 sw=2 noet: */

View file

@ -1,5 +1,5 @@
/*
* pacman
* list.c
*
* Copyright (c) 2002 by Judd Vinet <jvinet@zeroflux.org>
*
@ -174,7 +174,9 @@ PMList *list_sort(PMList *list)
lp = list_add(lp, strdup(arr[i]));
}
free(arr);
if(arr) {
free(arr);
}
return(lp);
}

View file

@ -1,5 +1,5 @@
/*
* pacman
* list.h
*
* Copyright (c) 2002 by Judd Vinet <jvinet@zeroflux.org>
*

View file

@ -1,7 +1,7 @@
/*
* pacman
* package.c
*
* Copyright (c) 2002 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2002-2003 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
@ -181,6 +181,8 @@ int parse_descfile(char *descfile, pkginfo_t *info, PMList **backup, int output)
strncpy(info->version, ptr, sizeof(info->version));
} else if(!strcmp(key, "PKGDESC")) {
strncpy(info->desc, ptr, sizeof(info->desc));
} else if(!strcmp(key, "GROUP")) {
info->groups = list_add(info->groups, strdup(ptr));
} else if(!strcmp(key, "URL")) {
strncpy(info->url, ptr, sizeof(info->url));
} else if(!strcmp(key, "BUILDDATE")) {
@ -194,14 +196,15 @@ int parse_descfile(char *descfile, pkginfo_t *info, PMList **backup, int output)
strncpy(tmp, ptr, sizeof(tmp));
info->size = atol(tmp);
} else if(!strcmp(key, "DEPEND")) {
char *s = strdup(ptr);
info->depends = list_add(info->depends, s);
info->depends = list_add(info->depends, strdup(ptr));
} else if(!strcmp(key, "CONFLICT")) {
char *s = strdup(ptr);
info->conflicts = list_add(info->conflicts, s);
info->conflicts = list_add(info->conflicts, strdup(ptr));
} else if(!strcmp(key, "REPLACES")) {
info->replaces = list_add(info->replaces, strdup(ptr));
} else if(!strcmp(key, "PROVIDES")) {
info->provides = list_add(info->provides, strdup(ptr));
} else if(!strcmp(key, "BACKUP")) {
char *s = strdup(ptr);
bak = list_add(bak, s);
bak = list_add(bak, strdup(ptr));
} else {
fprintf(stderr, "%s: syntax error in description file line %d\n",
info->name[0] != '\0' ? info->name : "error", linenum);
@ -235,6 +238,9 @@ pkginfo_t* newpkg()
pkg->files = NULL;
pkg->backup = NULL;
pkg->depends = NULL;
pkg->groups = NULL;
pkg->provides = NULL;
pkg->replaces = NULL;
return(pkg);
}
@ -250,6 +256,9 @@ void freepkg(pkginfo_t *pkg)
list_free(pkg->depends);
list_free(pkg->conflicts);
list_free(pkg->requiredby);
list_free(pkg->groups);
list_free(pkg->provides);
list_free(pkg->replaces);
FREE(pkg);
return;
}
@ -298,24 +307,30 @@ void dump_pkg(pkginfo_t *info)
return;
}
printf("Name : %s\n", info->name);
printf("Version : %s\n", info->version);
printf("Packager : %s\n", info->packager);
printf("URL: : %s\n", info->url);
printf("Size : %ld\n", info->size);
printf("Build Date : %s %s\n", info->builddate, strlen(info->builddate) ? "UTC" : "");
printf("Install Date : %s %s\n", info->installdate, strlen(info->installdate) ? "UTC" : "");
printf("Install Script: %s\n", (info->scriptlet ? "yes" : "no"));
printf("Name : %s\n", info->name);
printf("Version : %s\n", info->version);
pm = list_sort(info->groups);
list_display("Groups : ", pm);
FREE(pm);
printf("Packager : %s\n", info->packager);
printf("URL : %s\n", (info->url ? info->url : "None"));
printf("Size : %ld\n", info->size);
printf("Build Date : %s %s\n", info->builddate, strlen(info->builddate) ? "UTC" : "");
printf("Install Date : %s %s\n", info->installdate, strlen(info->installdate) ? "UTC" : "");
printf("Install Script : %s\n", (info->scriptlet ? "Yes" : "No"));
pm = list_sort(info->provides);
list_display("Provides : ", pm);
FREE(pm);
pm = list_sort(info->depends);
list_display("Depends On : ", pm);
list_display("Depends On : ", pm);
FREE(pm);
pm = list_sort(info->requiredby);
list_display("Required By : ", pm);
list_display("Required By : ", pm);
FREE(pm);
pm = list_sort(info->conflicts);
list_display("Conflicts With: ", pm);
list_display("Conflicts With : ", pm);
FREE(pm);
printf("Description : %s\n", info->desc);
printf("Description : %s\n", info->desc);
}
/* vim: set ts=2 sw=2 noet: */

View file

@ -1,5 +1,5 @@
/*
* pacman
* package.h
*
* Copyright (c) 2002 by Judd Vinet <jvinet@zeroflux.org>
*
@ -41,11 +41,14 @@ typedef struct __pkginfo_t {
char packager[64];
unsigned long size;
unsigned short scriptlet;
PMList *replaces;
PMList *groups;
PMList *files;
PMList *backup;
PMList *depends;
PMList *requiredby;
PMList *conflicts;
PMList *provides;
} pkginfo_t;
typedef struct __depend_t {

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
/*
* pacman
* pacman.h
*
* Copyright (c) 2002 by Judd Vinet <jvinet@zeroflux.org>
*
@ -22,7 +22,7 @@
#define _PAC_PACMAN_H
#ifndef PACVER
#define PACVER "2.5.1"
#define PACVER "2.6"
#endif
#ifndef PKGDIR
@ -51,6 +51,7 @@ int pacman_query(pacdb_t *db, PMList *targets);
int pacman_sync(pacdb_t *db, PMList *targets);
int pacman_deptest(pacdb_t *db, PMList *targets);
PMList* sortbydeps(PMList *targets);
PMList* checkdeps(pacdb_t *db, unsigned short op, PMList *targets);
int resolvedeps(pacdb_t *local, PMList *databases, syncpkg_t *sync, PMList *list, PMList *trail);
int splitdep(char *depstr, depend_t *depend);
@ -62,7 +63,9 @@ int parseconfig(char *configfile);
void usage(int op, char *myname);
void version(void);
int vprint(char *fmt, ...);
void vprint(char *fmt, ...);
void logaction(char *fmt, ...);
char* buildstring(PMList *strlist);
int lckmk(char *file, int retries, unsigned int sleep_secs);
int lckrm(char *lckfile);
void cleanup(int signum);

View file

@ -1,5 +1,5 @@
/*
* pacman
* pacsync.c
*
* Copyright (c) 2002 by Judd Vinet <jvinet@zeroflux.org>
*
@ -21,6 +21,7 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
@ -39,10 +40,12 @@ static int offset;
/* pacman options */
extern char *pmo_root;
extern char *pmo_dbpath;
extern unsigned short pmo_nopassiveftp;
/* sync servers */
extern PMList *pmc_syncs;
extern int maxcols;
int sync_synctree()
{
@ -55,7 +58,7 @@ int sync_synctree()
for(i = pmc_syncs; i; i = i->next) {
sync_t *sync = (sync_t*)i->data;
snprintf(ldir, PATH_MAX, "%s%s", pmo_root, PKGDIR);
snprintf(ldir, PATH_MAX, "%s%s", pmo_root, pmo_dbpath);
/* build a one-element list */
snprintf(path, PATH_MAX, "%s.db.tar.gz", sync->treename);
@ -66,13 +69,12 @@ int sync_synctree()
fprintf(stderr, "failed to synchronize %s\n", sync->treename);
success = 0;
}
/*printf("\n");*/
list_free(files);
files = NULL;
snprintf(path, PATH_MAX, "%s/%s.db.tar.gz", ldir, sync->treename);
if(success) {
snprintf(ldir, PATH_MAX, "%s%s/%s", pmo_root, PKGDIR, sync->treename);
snprintf(ldir, PATH_MAX, "%s%s/%s", pmo_root, pmo_dbpath, sync->treename);
/* remove the old dir */
vprint("removing %s (if it exists)\n", ldir);
rmrf(ldir);
@ -111,7 +113,7 @@ int downloadfiles(PMList *servers, char *localpath, PMList *files)
for(i = servers; i && !done; i = i->next) {
server_t *server = (server_t*)i->data;
if(!server->islocal) {
if(!strcmp(server->protocol, "ftp")) {
FtpInit();
if(!FtpConnect(server->server, &control)) {
fprintf(stderr, "error: cannot connect to %s\n", server->server);
@ -153,50 +155,42 @@ int downloadfiles(PMList *servers, char *localpath, PMList *files)
sync_fnm[j] = ' ';
}
sync_fnm[24] = '\0';
offset = 0;
if(!server->islocal) {
int tries = 2;
while(tries) {
if(!FtpSize(fn, &fsz, FTPLIB_IMAGE, control)) {
fprintf(stderr, "warning: failed to get filesize for %s\n", fn);
}
offset = 0;
if(!stat(output, &st)) {
offset = (int)st.st_size;
}
if(offset) {
if(!FtpRestart(offset, control)) {
fprintf(stderr, "warning: failed to resume download -- restarting\n");
/* can't resume: */
/* unlink the file in order to restart download from scratch */
unlink(output);
}
}
/* set up our progress bar's callback */
FtpOptions(FTPLIB_CALLBACK, (long)log_progress, control);
FtpOptions(FTPLIB_IDLETIME, (long)1000, control);
FtpOptions(FTPLIB_CALLBACKARG, (long)&fsz, control);
FtpOptions(FTPLIB_CALLBACKBYTES, (10*1024), control);
if(!FtpGet(output, lp->data, FTPLIB_IMAGE, control)) {
fprintf(stderr, "\nfailed downloading %s from %s: %s\n",
fn, server->server, FtpLastResponse(control));
/* we leave the partially downloaded file in place so it can be resumed later */
/* try each file twice in case it was just one of those transient network errors */
tries--;
} else {
char completefile[PATH_MAX];
log_progress(control, fsz-offset, &fsz);
complete = list_add(complete, fn);
tries = 0;
/* rename "output.part" file to "output" file */
snprintf(completefile, PATH_MAX, "%s/%s", localpath, fn);
rename(output, completefile);
}
printf("\n");
fflush(stdout);
if(!strcmp(server->protocol, "ftp")) {
if(!FtpSize(fn, &fsz, FTPLIB_IMAGE, control)) {
fprintf(stderr, "warning: failed to get filesize for %s\n", fn);
}
} else {
if(!stat(output, &st)) {
offset = (int)st.st_size;
if(!FtpRestart(offset, control)) {
fprintf(stderr, "warning: failed to resume download -- restarting\n");
/* can't resume: */
/* unlink the file in order to restart download from scratch */
unlink(output);
}
}
/* set up our progress bar's callback */
FtpOptions(FTPLIB_CALLBACK, (long)log_progress, control);
FtpOptions(FTPLIB_IDLETIME, (long)1000, control);
FtpOptions(FTPLIB_CALLBACKARG, (long)&fsz, control);
FtpOptions(FTPLIB_CALLBACKBYTES, (10*1024), control);
if(!FtpGet(output, lp->data, FTPLIB_IMAGE, control)) {
fprintf(stderr, "\nfailed downloading %s from %s: %s\n",
fn, server->server, FtpLastResponse(control));
/* we leave the partially downloaded file in place so it can be resumed later */
} else {
char completefile[PATH_MAX];
log_progress(control, fsz-offset, &fsz);
complete = list_add(complete, fn);
/* rename "output.part" file to "output" file */
snprintf(completefile, PATH_MAX, "%s/%s", localpath, fn);
rename(output, completefile);
}
printf("\n");
fflush(stdout);
} else if(!strcmp(server->protocol, "file")) {
/* local repository, just copy the file */
char src[PATH_MAX], dest[PATH_MAX];
snprintf(src, PATH_MAX, "%s%s", server->path, fn);
@ -206,10 +200,10 @@ int downloadfiles(PMList *servers, char *localpath, PMList *files)
fprintf(stderr, "failed copying %s\n", src);
} else {
char out[56];
printf("%s [", sync_fnm);
printf(" %s [", sync_fnm);
strncpy(out, server->path, 33);
printf("%s", out);
for(j = strlen(out); j < 33; j++) {
for(j = strlen(out); j < maxcols-44; j++) {
printf(" ");
}
fputs("] 100% | LOCAL\n", stdout);
@ -223,7 +217,7 @@ int downloadfiles(PMList *servers, char *localpath, PMList *files)
done = 1;
}
if(!server->islocal) {
if(!strcmp(server->protocol, "ftp")) {
FtpQuit(control);
}
}
@ -235,37 +229,44 @@ static int log_progress(netbuf *ctl, int xfered, void *arg)
{
int fsz = *(int*)arg;
int pct = ((float)(xfered+offset) / fsz) * 100;
int i;
int i, cur;
char *cenv = NULL;
printf("%s [", sync_fnm);
for(i = 0; i < (int)(pct/3); i++) {
printf("#");
cenv = getenv("COLUMNS");
if(cenv) {
maxcols = atoi(cenv);
}
for(i = (int)(pct/3); i < (int)(100/3); i++) {
printf(" ");
printf(" %s [", sync_fnm);
cur = (int)((maxcols-44)*pct/100);
for(i = 0; i < maxcols-44; i++) {
(i < cur) ? printf("#") : printf(" ");
}
printf("] %3d%% | %6dK\r ", pct, ((xfered+offset)/1024));
printf("] %3d%% | %6dK\r", pct, ((xfered+offset)/1024));
fflush(stdout);
return(1);
}
/* Test for existence of a package in a PMList*
* of syncpkg_t*
/* Test for existance of a package in a PMList* of syncpkg_t*
* If found, return a pointer to the respective syncpkg_t*
*/
int is_pkginsync(syncpkg_t *needle, PMList *haystack)
syncpkg_t* find_pkginsync(char *needle, PMList *haystack)
{
PMList *lp;
PMList *i;
syncpkg_t *sync;
int found = 0;
for(lp = haystack; lp && !found; lp = lp->next) {
sync = (syncpkg_t*)lp->data;
if(sync && !strcmp(sync->pkg->name, needle->pkg->name)) {
for(i = haystack; i && !found; i = i->next) {
sync = (syncpkg_t*)i->data;
if(sync && !strcmp(sync->pkg->name, needle)) {
found = 1;
}
}
if(!found) {
sync = NULL;
}
return found;
return sync;
}
/* vim: set ts=2 sw=2 noet: */

View file

@ -1,5 +1,5 @@
/*
* pacman
* pacsync.h
*
* Copyright (c) 2002 by Judd Vinet <jvinet@zeroflux.org>
*
@ -23,7 +23,7 @@
/* Servers */
typedef struct __server_t {
unsigned short islocal;
char* protocol;
char* server;
char* path;
} server_t;
@ -44,11 +44,12 @@ typedef struct __dbsync_t {
typedef struct __syncpkg_t {
pkginfo_t *pkg;
dbsync_t *dbs;
PMList *replaces;
} syncpkg_t;
int sync_synctree();
int downloadfiles(PMList *servers, char *localpath, PMList *files);
int is_pkginsync(syncpkg_t *needle, PMList *haystack);
syncpkg_t* find_pkginsync(char *needle, PMList *haystack);
#endif

View file

@ -1,5 +1,5 @@
/*
* pacman
* rpmvercmp.c
*
* Copyright (c) 2002 by Judd Vinet <jvinet@zeroflux.org>
*

View file

@ -1,5 +1,5 @@
/*
* pacman
* rpmvercmp.h
*
* Copyright (c) 2002 by Judd Vinet <jvinet@zeroflux.org>
*

View file

@ -1,5 +1,5 @@
/*
* pacman
* util.c
*
* Copyright (c) 2002 by Judd Vinet <jvinet@zeroflux.org>
*
@ -117,6 +117,7 @@ int copyfile(char *src, char *dest)
return(0);
}
/* does the same thing as 'mkdir -p' */
int makepath(char *path)
{
char *orig, *str, *ptr;
@ -146,6 +147,7 @@ int makepath(char *path)
return(0);
}
/* does the same thing as 'rm -rf' */
int rmrf(char *path)
{
int errflag = 0;
@ -157,13 +159,13 @@ int rmrf(char *path)
if(!unlink(path)) {
return(0);
} else {
if (errno == ENOENT) {
if(errno == ENOENT) {
return(0);
} else if (errno == EPERM) {
} else if(errno == EPERM) {
/* fallthrough */
} else if (errno == EISDIR) {
} else if(errno == EISDIR) {
/* fallthrough */
} else if (errno == ENOTDIR) {
} else if(errno == ENOTDIR) {
return(1);
} else {
/* not a directory */
@ -174,7 +176,7 @@ int rmrf(char *path)
return(1);
}
for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
if (dp->d_ino) {
if(dp->d_ino) {
sprintf(name, "%s/%s", path, dp->d_name);
if(strcmp(dp->d_name, "..") && strcmp(dp->d_name, ".")) {
errflag += rmrf(name);
@ -190,6 +192,7 @@ int rmrf(char *path)
return(0);
}
/* presents a prompt and gets a Y/N answer */
int yesno(char *fmt, ...)
{
char response[32];

View file

@ -1,5 +1,5 @@
/*
* pacman
* util.h
*
* Copyright (c) 2002 by Judd Vinet <jvinet@zeroflux.org>
*

View file

@ -1,5 +1,5 @@
/*
* pacman
* vercmp.c
*
* Copyright (c) 2002 by Judd Vinet <jvinet@zeroflux.org>
*