From 0207fad046f76fc37c0fc7c8b6a157225024a3ed Mon Sep 17 00:00:00 2001 From: Judd Vinet Date: Fri, 14 Mar 2003 17:35:57 +0000 Subject: Imported from pacman-2.3.1.tar.gz --- ChangeLog | 12 ++ Makefile.in | 2 +- TODO | 6 +- doc/makepkg.8.html | 365 +++++++++++++++++++++++++++++++++++++++++++++++++++++ doc/makepkg.8.in | 6 +- doc/pacman.8.html | 306 ++++++++++++++++++++++++++++++++++++++++++++ scripts/gensync | 2 +- scripts/makepkg | 10 +- scripts/makeworld | 10 +- src/pacman.c | 75 ++++++----- src/pacman.h | 2 +- src/pacsync.c | 12 +- 12 files changed, 754 insertions(+), 54 deletions(-) create mode 100644 doc/makepkg.8.html create mode 100644 doc/pacman.8.html diff --git a/ChangeLog b/ChangeLog index 7837894e..d9469ea1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ VERSION DESCRIPTION ------------------------------------------------------------------ +2.3.1 - Fixed the progress bar overflow + - Pacman does not ask "Are you sure" when you use --downloadonly + - Switched up a couple makepkg options to be more consistent + with pacman's options + - If you ^C out of a file download, the package will now be + removed from the cache directory +2.3 - The beginnings of source-side dependency resolution, makepkg + can now either A) download/install missing deps with pacman + -S; or B) find missing deps in the /usr/abs tree and + build/install them. + - Added a --nodeps option to makepkg + - Improved the --search output 2.2 - More bugfixes - Added --downloadonly switch to --sync 2.1 - Lots of bugfixes diff --git a/Makefile.in b/Makefile.in index 90a72ffa..b5479d6d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -34,7 +34,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ -PACVER = 2.3 +PACVER = 2.3.1 LIBTAR_VERSION = 1.2.5 TOPDIR = @srcdir@ diff --git a/TODO b/TODO index 475705fe..7b1d6f07 100644 --- a/TODO +++ b/TODO @@ -1,14 +1,14 @@ +- 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 +- IgnorePkg option/switch in pacman.conf to ignore updates from the sync repo - 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 -- have "group" designations -- IgnorePkg option in pacman.conf to ignore updates from the sync repo - add an option equivalent to 'pacman -Ql pkg | grep filename' -- ftp transfer progress bar breaks after ~42000 K - 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? diff --git a/doc/makepkg.8.html b/doc/makepkg.8.html new file mode 100644 index 00000000..66110f90 --- /dev/null +++ b/doc/makepkg.8.html @@ -0,0 +1,365 @@ +Content-type: text/html + +Manpage of makepkg + +

makepkg

+Section: (8)
Updated: March 3, 2003
Index +Return to Main Contents
+ +  +

NAME

+ +makepkg - package build utility +  +

SYNOPSIS

+ +makepkg +  +

DESCRIPTION

+ +makepkg will build packages for you. All it needs is +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, +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 pacman to use. +

+makeworld can be used to rebuild an entire package group, or the +entire build tree. +  +

BUILD PROCESS (or How To Build Your Own Packages)

+ +Start in an isolated directory (ie, it's not used for anything other +than building this package). The build script should be called PKGBUILD +and it should bear resemblance to the example below. +

+NOTE: If you have a local copy of the Arch Build System (ABS) tree +on your computer, you can copy the PKGBUILD.proto file to your new package +build directory and edit it from there. To acquire/sync the ABS tree, use +the abs script included with pacman/makepkg. +

+

+
+  +

PKGBUILD Example:

+ +
+
+
+
+pkgname=modutils
+pkgver=2.4.13
+pkgrel=1
+pkgdesc="Utilities for inserting and removing modules from the linux kernel"
+backup=(etc/modules.conf)
+depends=('glibc>=2.2.5' 'bash' 'zlib')
+source=(ftp://ftp.server.com/$pkgname-$pkgver.tar.gz modules.conf)
+
+build() {
+  cd $startdir/src/$pkgname-$pkgver
+  ./configure --prefix=/usr
+  make || return 1
+  make prefix=$startdir/pkg/usr install
+  # copy our custom modules.conf into the package root
+  mkdir -p $startdir/pkg/etc
+  cp ../modules.conf $startdir/pkg/etc
+}
+
+ +
+ +

+As you can see, the setup is fairly simple. The first three lines define +the package name and version info. They also define the final package name +which will be of the form $pkgname-$pkgver-$pkgrel.pkg.tar.gz. The fourth +line provides a brief description of the package. These four lines should +be present in every PKGBUILD script. +

+The line with backup= specifies files that should be treated specially +when removing or upgrading packages. See HANDLING CONFIG FILES in +the pacman manpage for more information on this. +

+The sixth 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. +

+Once your PKGBUILD is created, you can run makepkg 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 +a fully-qualified URL in the source array. +

+The sources are then extracted into a directory called ./src and +the build function is called. This is where all package configuration, +building, and installing should be done. Any customization will likely take +place here. +

+After a package is built, the build function must install the package +files into a special package root, which can be referenced by $startdir/pkg +in the build function. The typical way to do this is one of the following: +

+
+
+make DESTDIR=$startdir/pkg install
+
+or
+
+make prefix=$startdir/pkg/usr install
+
+
+ +
+ +Notice that the "/usr" portion should be present with "prefix", but not "DESTDIR". +

+Once the package is successfully installed into the package root, makepkg +will remove some directories (as per Arch Linux package guidelines; if you use +this elsewhere, feel free to change it) like /usr/doc and /usr/info. It will +then strip debugging info from libraries and binaries and generate a meta-info +file. Finally, it will compress everything into a .pkg.tar.gz file and leave it +in the directory you ran makepkg from. +

+At this point you should have a package file in the current directory, named +something like name-version-release.pkg.tar.gz. Done! +

+  +

Install/Upgrade/Remove Scripting

+ +Pacman has the ability to store and execute a package-specific script when it +installs, removes, or upgrades a package. This allows a package to "configure +itself" after installation and do the opposite right before it is removed. +

+The exact time the script is run varies with each operation: +

+
post_install + +
+script is run right after files are installed. +

+

post_upgrade + +
+script is run after all files have been upgraded. +

+

pre_remove + +
+script is run right before files are removed. +

+ +To use this feature, just create a file (eg, pkgname.install) and put it in +the same directory as the PKGBUILD script. Then use the install directive: +

+
+install=pkgname.install
+
+ +
+ +

+The install script does not need to be specified in the source array. +

+

+  +

Install scripts must follow this format:

+ +
+
+
+
+# arg 1:  the new package version
+post_install() {
+  #
+  #  do post-install stuff here
+  #
+  /bin/true
+}
+
+# arg 1:  the new package version
+# arg 2:  the old package version
+post_upgrade() {
+  #
+  #  do post-upgrade stuff here
+  #
+  /bin/true
+}
+
+# arg 1:  the old package version
+pre_remove() {
+  #
+  #  do pre-remove stuff here
+  #
+  /bin/true
+}
+
+op=$1
+shift
+
+$op $*
+
+ +
+ +

+This template is also available in your ABS tree (/usr/abs/install.proto). +

+  +

PKGBUILD Directives

+ +
+
pkgname + +
+The name of the package. This has be a unix-friendly name as it will be +used in the package filename. +

+

pkgver + +
+This is the version of the software as released from the author (eg, 2.7.1). +

+

pkgrel + +
+This is the release number specific to Arch Linux packages. +

+

pkgdesc + +
+This should be a brief description of the package and its functionality. +

+

backup + +
+A space-delimited array of filenames (without a preceding slash). The +backup 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 +package is ever removed from a system. See HANDLING CONFIG FILES in +the pacman manpage for more information. +

+

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 +source array. (eg, install=modutils.install) +

+

depends + +
+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 +name<>version, where <> is one of these three comparisons: >= +(greater than equal to), <= (less than or equal to), or = (equal to). +See the PKGBUILD example above for an example of the depends directive. +

+

conflicts + +
+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 +depends except you cannot specify versions here, only package names. +

+

source + +
+The source 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. +

+

+  +

MAKEPKG OPTIONS

+ +
+
-c, --clean + +
+Clean up leftover work files/directories after a successful build. +
-i, --install + +
+Install/Upgrade the package after a successful build. +
-s, --syncdeps + +
+Install missing dependencies using pacman. When makepkg finds missing +dependencies, it will run pacman to try and resolve them. If successful, +pacman will download the missing packages from a package repository and +install them for you. +
-b, --builddeps + +
+Build missing dependencies from source. When makepkg finds missing +dependencies, it will look for the dependencies' PKGBUILD files under +$ABSROOT (set in your /etc/makepkg.conf). If it finds them it will +run another copy of makepkg to build and install the missing dependencies. +The child makepkg calls will be made with the -b and -i options. +
-d, --nodeps + +
+Do not perform any dependency checks. This will let you override/ignore any +dependencies required. There's a good chance this option will break the build +process if all of the dependencies aren't installed. +
-f, --force + +
+makepkg will not build a package if a pkgname-pkgver-pkgrel.pkg.tar.gz +file already exists in the build directory. You can override this behaviour with +the --force switch. +

+

+  +

CONFIGURATION

+ +Configuration options are stored in /etc/makepkg.conf. This file is parsed +as a bash script, so you can export any special compiler flags you wish +to use. This is helpful for building for different architectures, or with +different optimizations. +

+NOTE: This does not guarantee that all package Makefiles will use +your exported variables. Some of them are flaky... +  +

SEE ALSO

+ +pacman is the package manager that uses packages built by makepkg. +

+See the Arch Linux Documentation for package-building guidelines if you wish +to contribute packages to the Arch Linux project. +  +

AUTHOR

+ +
+Judd Vinet <jvinet@zeroflux.org>
+
+ +

+ +


+ 

Index

+
+
NAME
+
SYNOPSIS
+
DESCRIPTION
+
BUILD PROCESS (or How To Build Your Own Packages)
+
PKGBUILD Example:
+
Install/Upgrade/Remove Scripting
+
Install scripts must follow this format:
+
PKGBUILD Directives
+
MAKEPKG OPTIONS
+
CONFIGURATION
+
SEE ALSO
+
AUTHOR
+
+
+This document was created by +man2html, +using the manual pages.
+Time: 17:22:11 GMT, March 04, 2003 + + diff --git a/doc/makepkg.8.in b/doc/makepkg.8.in index 3cc60b2d..35ebc974 100644 --- a/doc/makepkg.8.in +++ b/doc/makepkg.8.in @@ -1,4 +1,4 @@ -.TH makepkg 8 "February 18, 2003" "makepkg #VERSION#" "" +.TH makepkg 8 "March 3, 2003" "makepkg #VERSION#" "" .SH NAME makepkg \- package build utility .SH SYNOPSIS @@ -232,7 +232,7 @@ Clean up leftover work files/directories after a successful build. .B "\-i, \-\-install" Install/Upgrade the package after a successful build. .TP -.B "\-d, \-\-syncdeps" +.B "\-s, \-\-syncdeps" Install missing dependencies using pacman. When makepkg finds missing dependencies, it will run pacman to try and resolve them. If successful, pacman will download the missing packages from a package repository and @@ -245,7 +245,7 @@ $ABSROOT (set in your /etc/makepkg.conf). If it finds them it will run another copy of makepkg to build and install the missing dependencies. The child makepkg calls will be made with the \fB-b\fP and \fB-i\fP options. .TP -.B "\-n, \-\-nodeps" +.B "\-d, \-\-nodeps" Do not perform any dependency checks. This will let you override/ignore any dependencies required. There's a good chance this option will break the build process if all of the dependencies aren't installed. diff --git a/doc/pacman.8.html b/doc/pacman.8.html new file mode 100644 index 00000000..e10c2b27 --- /dev/null +++ b/doc/pacman.8.html @@ -0,0 +1,306 @@ +Content-type: text/html + +Manpage of pacman + +

pacman

+Section: (8)
Updated: January 20, 2003
Index +Return to Main Contents
+ +  +

NAME

+ +pacman - package manager utility +  +

SYNOPSIS

+ +pacman <operation> [options] <package> [package] ... +  +

DESCRIPTION

+ +pacman is a package management utility that tracks installed +packages on a linux system. It has simple dependency support and the ability +to connect to a remote ftp server and automatically upgrade packages on +the local system. pacman package are gzipped tar format. +  +

OPERATIONS

+ +
+
-A, --add + +
+Add a package to the system. Package will be uncompressed +into the installation root and the database will be updated. +
-R, --remove + +
+Remove a package from the system. Files belonging to the +specified package will be deleted, and the database will +be updated. Most configuration files will be saved with a +.pacsave extension unless the --nosave option was +used. +
-U, --upgrade + +
+Upgrade a package. This is essentially a "remove-then-add" +process. See HANDLING CONFIG FILES for an explanation +on how pacman takes care of config files. +
-F, --freshen + +
+This is like --upgrade except that, unlike --upgrade, this will only +upgrade packages that are already installed on your system. +
-Q, --query + +
+Query the package database. This operation allows you to +view installed packages and their files, as well as meta-info +about individual packages (dependencies, conflicts, install date, +build date, size). This can be run against the local package +database or can be used on individual .tar.gz packages. See +QUERY OPTIONS below. +
-S, --sync + +
+Synchronize packages. With this function you can install packages +directly from the ftp servers, complete with all dependencies required +to run the packages. For example, pacman -S qt will download +qt and all the packages it depends on and install them. You could also use +pacman -Su to upgrade all packages that are out of date (see below). +
-V, --version + +
+Display version and exit. +
-h, --help + +
+Display syntax for the given operation. If no operation was +supplied then the general syntax is shown. +
+  +

OPTIONS

+ +
+
-v, --verbose + +
+Output more status and error messages. +
-f, --force + +
+Bypass file conflict checks,, overwriting conflicting files. If the +package that is about to be installed contains files that are already +installed, this option will cause all those files to be overwritten. +This option should be used with care, ideally not at all. +
-d, --nodeps + +
+Skips all dependency checks. Normally, pacman will always check +a package's dependency fields to ensure that all dependencies are +installed and there are no package conflicts in the system. This +switch disables these checks. +
-n, --nosave + +
+(only used with --remove) +Instructs pacman to ignore file backup designations. Normally, when +a file is about to be removed from the system the database is first +checked to see if the file should be renamed to a .pacsave extension. If +--nosave is used, these designations are ignored and the files are +removed. +
-r, --root <path> + +
+Specify alternative installation root (default is "/"). This +should not be used as a way to install software into +e.g. /usr/local instead of /usr. Instead this should be used +if you want to install a package on a temporary mounted partition, +which is "owned" by another system. By using this option you not only +specify where the software should be installed, but you also +specify which package database to use. +
+  +

SYNC OPTIONS

+ +
+
-y, --refresh + +
+Download a fresh copy of the master package list from the ftp server +defined in /etc/pacman.conf. This should typically be used each +time you use --sysupgrade. +
-u, --sysupgrade + +
+Upgrades all packages that are out of date. pacman will examine every +package installed on the system, and if a newer package exists on the +server it will upgrade. pacman will present a report of all packages +it wants to upgrade and will not proceed without user confirmation. +Dependencies are automatically resolved at this level and will be +installed/upgraded if necessary. +
-s, --search <string> + +
+This will search each package in the package list for names or descriptions +that contains <string>. +
-w, --downloadonly + +
+Retrieve all packages from the server, but do not install/upgrade anything. +
-c, --clean + +
+Remove packages from the cache. When pacman downloads packages, +it saves them in /var/cache/pacman/pkg. If you need to free up +diskspace, you can remove these packages by using the --clean option. +
+  +

QUERY OPTIONS

+ +
+
-o, --owns <file> + +
+Search for the package that owns <file>. +
-l, --list + +
+List all files owned by <package>. Multiple packages can be specified on +the command line. +
-i, --info + +
+Display information on a given package. If it is used with the -p +option then the .PKGINFO file will be printed. +
-p, --file + +
+Tells pacman that the package supplied on the command line is a +file, not an entry in the database. Pacman will decompress the +file and query it. This is useful with --info and --list. +
+  +

HANDLING CONFIG FILES

+ +pacman uses the same logic as rpm to determine action against files +that are designated to be backed up. During an upgrade, it uses 3 +md5 hashes for each backup file to determine the required action: +one for the original file installed, one for the new file that's about +to be installed, and one for the actual file existing on the filesystem. +After comparing these 3 hashes, the follow scenarios can result: +
+
original=X, current=X, new=X
+All three files are the same, so we win either way. Install the new file. +
original=X, current=X, new=Y
+The current file is un-altered from the original but the new one is +different. Since the user did not ever modify the file, and the new +one may contain improvements/bugfixes, we install the new file. +
original=X, current=Y, new=X
+Both package versions contain the exact same file, but the one +on the filesystem has been modified since. In this case, we leave +the current file in place. +
original=X, current=Y, new=Y
+The new one is identical to the current one. Win win. Install the new file. +
original=X, current=Y, new=Z
+All three files are different. So we install the new file, but back up the +old one to a .pacsave extension. This way the user can move the old configuration +file back into place if he wishes. +
+  +

CONFIGURATION

+ +pacman will attempt to read /etc/pacman.conf each time it is invoked. This +configuration file is divided into sections or repositories. Each section +defines a package repository that pacman can use when searching for packages in +--sync mode. The exception to this is the options section, which defines +global options. +
+
+  +

Example:

+ +
+
+
+[options]
+NoUpgrade = etc/passed etc/group etc/shadow
+NoUpgrade = etc/fstab
+
+[current]
+Server = ftp://ftp.server.org/linux/archlinux/current
+Server = ftp://ftp.mirror.com/arch/current
+
+[custom]
+Server = local:///home/pkgs
+
+
+ +
+ +All files listed with a NoUpgrade directive will never be touched during a package +install/upgrade. This directive is only valid in the options section. +

+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 Server 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 +shown above. +  +

USING YOUR OWN REPOSITORY

+ +Let's say you have a bunch of custom packages in /home/pkgs and their respective PKGBUILD +files are all in /usr/abs/local. All you need to do is generate a compressed package database +in the /home/pkgs directory so pacman can find it when run with --refresh. +

+

+
+# gensync /usr/abs/local /home/pkgs/custom.db.tar.gz
+
+ +
+ +

+The above command will read all PKGBUILD files in /usr/abs/local and generate a compressed +database called /home/pkgs/custom.db.tar.gz. Note that the database must be of the form +{treename}.db.tar.gz, where {treename} is the name of the section defined in the +configuration file. +That's it! Now configure your custom section in the configuration file as shown in the +config example above. Pacman will now use your package repository. If you add new packages to +the repository, remember to re-generate the database and use pacman's --refresh option. +  +

SEE ALSO

+ +makepkg is the package-building tool that comes with pacman. +  +

AUTHOR

+ +
+Judd Vinet <jvinet@zeroflux.org>
+
+ +

+ +


+ 

Index

+
+
NAME
+
SYNOPSIS
+
DESCRIPTION
+
OPERATIONS
+
OPTIONS
+
SYNC OPTIONS
+
QUERY OPTIONS
+
HANDLING CONFIG FILES
+
CONFIGURATION
+
Example:
+
USING YOUR OWN REPOSITORY
+
SEE ALSO
+
AUTHOR
+
+
+This document was created by +man2html, +using the manual pages.
+Time: 17:22:16 GMT, March 04, 2003 + + diff --git a/scripts/gensync b/scripts/gensync index 8c6dd320..cc825f3b 100755 --- a/scripts/gensync +++ b/scripts/gensync @@ -1,6 +1,6 @@ #!/bin/bash -myver='2.3' +myver='2.3.1' usage() { echo "gensync $myver" diff --git a/scripts/makepkg b/scripts/makepkg index d8c3938c..5f39a832 100755 --- a/scripts/makepkg +++ b/scripts/makepkg @@ -1,6 +1,6 @@ #!/bin/bash -myver='2.3' +myver='2.3.1' startdir=`pwd` [ -f /etc/makepkg.conf ] && source /etc/makepkg.conf @@ -52,9 +52,9 @@ if [ "$1" = "--help" -o "$1" = "-h" ]; then echo "usage: $0 [options] [build_script]" echo "options:" echo " -c, --clean Clean up work files after build" - echo " -d, --syncdeps Install missing dependencies with pacman" + echo " -s, --syncdeps Install missing dependencies with pacman" echo " -b, --builddeps Build missing dependencies from source" - echo " -n, --nodeps Skip all dependency checks" + echo " -d, --nodeps Skip all dependency checks" echo " -i, --install Install package after successful build" echo " -f, --force Overwrite existing package" echo " -h, --help This help" @@ -79,13 +79,13 @@ for arg in $*; do -c|--clean) CLEANUP=1 ;; - -d|--syncdeps) + -s|--syncdeps) DEP_BIN=1 ;; -b|--builddeps) DEP_SRC=1 ;; - -n|--nodeps) + -d|--nodeps) NODEPS=1 ;; -i|--install) diff --git a/scripts/makeworld b/scripts/makeworld index 4591c145..3c523f9c 100755 --- a/scripts/makeworld +++ b/scripts/makeworld @@ -1,16 +1,16 @@ #!/bin/bash toplevel=`pwd` -version="2.3" +version="2.3.1" usage() { echo "makeworld version $version" echo "usage: $0 [options] [category] ..." echo "options:" echo " -c, --clean Clean up work files after build" - echo " -d, --syncdeps Install missing dependencies with pacman" + echo " -s, --syncdeps Install missing dependencies with pacman" echo " -b, --builddeps Build missing dependencies from source" - echo " -n, --nodeps Skip all dependency checks" + echo " -d, --nodeps Skip all dependency checks" echo " -i, --install Install package after successful build" echo " -f, --force Overwrite existing packages" echo " -h, --help This help" @@ -35,13 +35,13 @@ for arg in $*; do -i|--install) MAKEPKG_OPTS="$MAKEPKG_OPTS -i" ;; - -d|--syncdeps) + -s|--syncdeps) MAKEPKG_OPTS="$MAKEPKG_OPTS -d" ;; -b|--builddeps) MAKEPKG_OPTS="$MAKEPKG_OPTS -b" ;; - -n|--nodeps) + -d|--nodeps) MAKEPKG_OPTS="$MAKEPKG_OPTS -n" ;; -f|--force) diff --git a/src/pacman.c b/src/pacman.c index b6714d22..5ea0c1a7 100644 --- a/src/pacman.c +++ b/src/pacman.c @@ -85,7 +85,8 @@ PMList *pm_packages = NULL; /* list of targets specified on command line */ PMList *pm_targets = NULL; -char *lckfile = "/tmp/pacman.lck"; +char *lckfile = "/tmp/pacman.lck"; +char *workfile = NULL; int main(int argc, char *argv[]) { @@ -470,7 +471,7 @@ int pacman_sync(pacdb_t *db, PMList *targets) allgood = 0; continue; } - if(local) { + if(local && !pmo_s_downloadonly) { /* this is an upgrade, compare versions and determine if it is necessary */ cmp = rpmvercmp(local->version, sync->pkg->version); if(cmp > 0) { @@ -1502,44 +1503,45 @@ int resolvedeps(pacdb_t *local, PMList *databases, syncpkg_t *syncpkg, PMList *l list_free(targ); for(i = deps; i; i = i->next) { int found = 0; - syncpkg_t *sync = NULL; depmissing_t *miss = (depmissing_t*)i->data; - MALLOC(sync, sizeof(syncpkg_t)); - - /* find the package in one of the repositories */ - for(j = databases; !found && j; j = j->next) { - dbsync_t *dbs = (dbsync_t*)j->data; - for(k = dbs->pkgcache; !found && k; k = k->next) { - pkginfo_t *pkg = (pkginfo_t*)k->data; - if(!strcmp(miss->depend.name, pkg->name)) { - found = 1; - /* re-fetch the package record with dependency info */ - sync->pkg = db_scan(dbs->db, pkg->name, INFRQ_DESC | INFRQ_DEPENDS); - sync->dbs = dbs; - } - } - } - if(!found) { - fprintf(stderr, "error: cannot resolve dependencies for \"%s\":\n", miss->target); - fprintf(stderr, " \"%s\" is not in the package set\n", miss->depend.name); - return(1); - } - found = 0; - for(j = list; j; j = j->next) { - syncpkg_t *tmp = (syncpkg_t*)j->data; - if(tmp && !strcmp(tmp->pkg->name, sync->pkg->name)) { - found = 1; - } - } - if(found) { - /* this dep is already in the target list */ - continue; - } + if(miss->type == CONFLICT) { fprintf(stderr, "error: cannot resolve dependencies for \"%s\":\n", miss->target); fprintf(stderr, " %s conflicts with %s\n", miss->target, miss->depend.name); return(1); } else if(miss->type == DEPEND) { + syncpkg_t *sync = NULL; + MALLOC(sync, sizeof(syncpkg_t)); + + /* find the package in one of the repositories */ + for(j = databases; !found && j; j = j->next) { + dbsync_t *dbs = (dbsync_t*)j->data; + for(k = dbs->pkgcache; !found && k; k = k->next) { + pkginfo_t *pkg = (pkginfo_t*)k->data; + if(!strcmp(miss->depend.name, pkg->name)) { + found = 1; + /* re-fetch the package record with dependency info */ + sync->pkg = db_scan(dbs->db, pkg->name, INFRQ_DESC | INFRQ_DEPENDS); + sync->dbs = dbs; + } + } + } + if(!found) { + fprintf(stderr, "error: cannot resolve dependencies for \"%s\":\n", miss->target); + fprintf(stderr, " \"%s\" is not in the package set\n", miss->depend.name); + return(1); + } + found = 0; + for(j = list; j; j = j->next) { + syncpkg_t *tmp = (syncpkg_t*)j->data; + if(tmp && !strcmp(tmp->pkg->name, sync->pkg->name)) { + found = 1; + } + } + if(found) { + /* this dep is already in the target list */ + continue; + } /*printf("resolving %s\n", sync->pkg->name); fflush(stdout);*/ found = 0; for(j = trail; j; j = j->next) { @@ -1865,6 +1867,11 @@ void cleanup(int signum) if(lckrm(lckfile)) { fprintf(stderr, "warning: could not remove lock file %s\n", lckfile); } + if(workfile) { + /* remove the current file being downloaded (as it's not complete) */ + unlink(workfile); + FREE(workfile); + } exit(signum); } diff --git a/src/pacman.h b/src/pacman.h index c9b06219..2c9b19a4 100644 --- a/src/pacman.h +++ b/src/pacman.h @@ -22,7 +22,7 @@ #define _PAC_PACMAN_H #ifndef PACVER -#define PACVER "2.3" +#define PACVER "2.3.1" #endif #ifndef PKGDIR diff --git a/src/pacsync.c b/src/pacsync.c index a76da444..f61a61e0 100644 --- a/src/pacsync.c +++ b/src/pacsync.c @@ -104,6 +104,7 @@ int downloadfiles(PMList *servers, char *localpath, PMList *files) int done = 0; PMList *complete = NULL; PMList *i; + extern char* workfile; if(files == NULL) { return(0); @@ -161,6 +162,14 @@ int downloadfiles(PMList *servers, char *localpath, PMList *files) FtpOptions(FTPLIB_IDLETIME, (long)1000, control); FtpOptions(FTPLIB_CALLBACKARG, (long)&fsz, control); FtpOptions(FTPLIB_CALLBACKBYTES, (10*1024), control); + + /* declare our working file so it can be removed it on interrupt */ + /* by the cleanup() function */ + if(workfile) { + FREE(workfile); + } + MALLOC(workfile, PATH_MAX); + strcpy(workfile, output); if(!FtpGet(output, lp->data, FTPLIB_IMAGE, control)) { fprintf(stderr, "\nfailed downloading %s from %s: %s\n", @@ -171,6 +180,7 @@ int downloadfiles(PMList *servers, char *localpath, PMList *files) log_progress(control, fsz, &fsz); complete = list_add(complete, fn); } + FREE(workfile); printf("\n"); fflush(stdout); } else { @@ -211,7 +221,7 @@ int downloadfiles(PMList *servers, char *localpath, PMList *files) static int log_progress(netbuf *ctl, int xfered, void *arg) { int fsz = *(int*)arg; - int pct = (unsigned int)(xfered * 100) / fsz; + int pct = ((float)xfered / fsz) * 100; int i; printf("%s [", sync_fnm); -- cgit v1.2.3-24-g4f1b