1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-11-12 04:15:06 -05:00

copied up-to-date scripts from pacman 2.9.7

This commit is contained in:
Judd Vinet 2005-10-20 20:46:35 +00:00
parent e37bc739bd
commit 6851ce24ab
5 changed files with 210 additions and 45 deletions

View File

@ -2,7 +2,7 @@
# #
# gensync # gensync
# #
# Copyright (c) 2002-2004 by Judd Vinet <jvinet@zeroflux.org> # Copyright (c) 2002-2005 by Judd Vinet <jvinet@zeroflux.org>
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -20,7 +20,7 @@
# USA. # USA.
# #
myver='2.9.2' myver='2.9.7'
usage() { usage() {
echo "gensync $myver" echo "gensync $myver"
@ -100,6 +100,17 @@ db_write_entry()
done done
echo "" >>desc echo "" >>desc
fi fi
if [ ${#replaces[*]} -gt 0 ]; then
echo "%REPLACES%" >>desc
for it in "${replaces[@]}"; do
echo "$it" >>desc
done
echo "" >>desc
fi
if [ "$force" = "y" -o "$force" = "Y" ]; then
echo "%FORCE%" >>desc
echo "" >>desc
fi
# depends # depends
: >depends : >depends
if [ ${#depends[*]} -gt 0 ]; then if [ ${#depends[*]} -gt 0 ]; then
@ -123,17 +134,6 @@ db_write_entry()
done done
echo "" >>depends echo "" >>depends
fi fi
if [ ${#replaces[*]} -gt 0 ]; then
echo "%REPLACES%" >>depends
for it in "${replaces[@]}"; do
echo "$it" >>depends
done
echo "" >>depends
fi
if [ "$force" = "y" -o "$force" = "Y" ]; then
echo "%FORCE%" >>depends
echo "" >>depends
fi
# preserve the modification time # preserve the modification time
touch -r $1 desc depends touch -r $1 desc depends
} }

View File

@ -2,7 +2,7 @@
# #
# makepkg # makepkg
# #
# Copyright (c) 2002-2004 by Judd Vinet <jvinet@zeroflux.org> # Copyright (c) 2002-2005 by Judd Vinet <jvinet@zeroflux.org>
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -20,7 +20,7 @@
# USA. # USA.
# #
myver='2.9.2' myver='2.9.7'
startdir=`pwd` startdir=`pwd`
PKGDEST=$startdir PKGDEST=$startdir
USE_COLOR="n" USE_COLOR="n"
@ -108,7 +108,7 @@ handledeps() {
local missingdeps=0 local missingdeps=0
local deplist="$*" local deplist="$*"
local haveperm=0 local haveperm=0
if [ "`id -u`" = "0" -a "$INFAKEROOT" != "1" ]; then if [ \( "`id -u`" = "0" -a "$INFAKEROOT" != "1" \) -o "$DEP_SUDO" = 1 ]; then
haveperm=1 haveperm=1
fi fi
@ -122,6 +122,25 @@ handledeps() {
exit 1 exit 1
fi fi
# TODO: check deps again to make sure they were resolved # TODO: check deps again to make sure they were resolved
elif [ "$DEP_SUDO" = "1" ]; then
# install missing deps from binary packages (using pacman -S and sudo)
msg "Installing missing dependencies..."
if [ "$INFAKEROOT" = "1" ]; then
# kinda hacky, but we need to make pacman think that we're NOT
# in fakeroot so it will go ahead and install the dependencies.
FAKEROOTKEY2=$FAKEROOTKEY
unset FAKEROOTKEY
fi
sudo pacman -D $deplist
if [ "$INFAKEROOT" = "1" ]; then
FAKEROOTKEY=$FAKEROOTKEY2
unset FAKEROOTKEY2
fi
if [ "$?" = "127" ]; then
error "Failed to install missing dependencies."
exit 1
fi
# TODO: check deps again to make sure they were resolved
elif [ "$DEP_SRC" = "1" ]; then elif [ "$DEP_SRC" = "1" ]; then
# install missing deps by building them from source. # install missing deps by building them from source.
# we look for each package name in $ABSROOT and build it. # we look for each package name in $ABSROOT and build it.
@ -163,8 +182,8 @@ handledeps() {
fi fi
elif [ "$deplist" != "" -a $haveperm -eq 0 ]; then elif [ "$deplist" != "" -a $haveperm -eq 0 ]; then
if [ "$DEP_SRC" = "1" -o "$DEP_BIN" = "1" ]; then if [ "$DEP_SRC" = "1" -o "$DEP_BIN" = "1" ]; then
warning "Cannot auto-install missing dependencies as a normal user!" warning "Cannot auto-install missing dependencies as a normal user without sudo!"
plain "Run makepkg as root to resolve dependencies automatically." plain "Run makepkg as root or with -S to resolve dependencies automatically."
fi fi
missingdeps=1 missingdeps=1
fi fi
@ -176,6 +195,7 @@ usage() {
echo "usage: $0 [options]" echo "usage: $0 [options]"
echo "options:" echo "options:"
echo " -b, --builddeps Build missing dependencies from source" echo " -b, --builddeps Build missing dependencies from source"
echo " -B, --noccache Do not use ccache during build"
echo " -c, --clean Clean up work files after build" echo " -c, --clean Clean up work files after build"
echo " -C, --cleancache Clean up source files from the cache" echo " -C, --cleancache Clean up source files from the cache"
echo " -d, --nodeps Skip all dependency checks" echo " -d, --nodeps Skip all dependency checks"
@ -191,6 +211,7 @@ usage() {
echo " -p <buildscript> Use an alternate build script (instead of PKGBUILD)" echo " -p <buildscript> Use an alternate build script (instead of PKGBUILD)"
echo " -r, --rmdeps Remove installed dependencies after a successful build" echo " -r, --rmdeps Remove installed dependencies after a successful build"
echo " -s, --syncdeps Install missing dependencies with pacman" echo " -s, --syncdeps Install missing dependencies with pacman"
echo " -S, --sudosync Install missing dependencies with pacman and sudo"
echo " -w <destdir> Write package to <destdir> instead of the working dir" echo " -w <destdir> Write package to <destdir> instead of the working dir"
echo echo
echo " if -p is not specified, makepkg will look for a PKGBUILD" echo " if -p is not specified, makepkg will look for a PKGBUILD"
@ -200,19 +221,21 @@ usage() {
# Options # Options
BUILDSCRIPT="./PKGBUILD"
CLEANUP=0 CLEANUP=0
CLEANCACHE=0 CLEANCACHE=0
INSTALL=0
GENMD5=0
DEP_BIN=0 DEP_BIN=0
DEP_SRC=0 DEP_SRC=0
NODEPS=0 DEP_SUDO=0
FORCE=0 FORCE=0
GENMD5=0
INSTALL=0
NOBUILD=0
NOCCACHE=0
NODEPS=0
NOEXTRACT=0 NOEXTRACT=0
NOSTRIP=0 NOSTRIP=0
NOBUILD=0
RMDEPS=0 RMDEPS=0
BUILDSCRIPT="./PKGBUILD"
ARGLIST=$@ ARGLIST=$@
@ -221,7 +244,9 @@ while [ "$#" -ne "0" ]; do
--clean) CLEANUP=1 ;; --clean) CLEANUP=1 ;;
--cleancache) CLEANCACHE=1 ;; --cleancache) CLEANCACHE=1 ;;
--syncdeps) DEP_BIN=1 ;; --syncdeps) DEP_BIN=1 ;;
--sudosync) DEP_SUDO=1 ;;
--builddeps) DEP_SRC=1 ;; --builddeps) DEP_SRC=1 ;;
--noccache) NOCCACHE=1 ;;
--nodeps) NODEPS=1 ;; --nodeps) NODEPS=1 ;;
--noextract) NOEXTRACT=1 ;; --noextract) NOEXTRACT=1 ;;
--install) INSTALL=1 ;; --install) INSTALL=1 ;;
@ -240,11 +265,12 @@ while [ "$#" -ne "0" ]; do
exit 1 exit 1
;; ;;
-*) -*)
while getopts "cCsbdehifgj:mnorp:w:-" opt; do while getopts "bBcCdefghij:mnop:rsSw:-" opt; do
case $opt in case $opt in
b) DEP_SRC=1 ;;
B) NOCCACHE=1 ;;
c) CLEANUP=1 ;; c) CLEANUP=1 ;;
C) CLEANCACHE=1 ;; C) CLEANCACHE=1 ;;
b) DEP_SRC=1 ;;
d) NODEPS=1 ;; d) NODEPS=1 ;;
e) NOEXTRACT=1 ;; e) NOEXTRACT=1 ;;
f) FORCE=1 ;; f) FORCE=1 ;;
@ -261,6 +287,7 @@ while [ "$#" -ne "0" ]; do
p) BUILDSCRIPT=$OPTARG ;; p) BUILDSCRIPT=$OPTARG ;;
r) RMDEPS=1 ;; r) RMDEPS=1 ;;
s) DEP_BIN=1 ;; s) DEP_BIN=1 ;;
S) DEP_SUDO=1 ;;
w) PKGDEST=$OPTARG ;; w) PKGDEST=$OPTARG ;;
-) -)
OPTIND=0 OPTIND=0
@ -280,6 +307,12 @@ while [ "$#" -ne "0" ]; do
shift shift
done done
# check for sudo
if [ "$DEP_SUDO" = "1" -a ! "`type -p sudo`" ]; then
error "Cannot find the sudo binary! Is sudo installed?"
exit 1
fi
# convert a (possibly) relative path to absolute # convert a (possibly) relative path to absolute
cd $PKGDEST 2>/dev/null cd $PKGDEST 2>/dev/null
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
@ -320,6 +353,10 @@ if [ `echo $pkgrel | grep '-'` ]; then
error "pkgrel is not allowed to contain hyphens." error "pkgrel is not allowed to contain hyphens."
exit 1 exit 1
fi fi
if [ "$install" -a ! -f "$install" ]; then
error "install scriptlet ($install) does not exist."
exit 1
fi
if [ -f $PKGDEST/${pkgname}-${pkgver}-${pkgrel}.pkg.tar.gz -a "$FORCE" = "0" -a "$GENMD5" = "0" ]; then if [ -f $PKGDEST/${pkgname}-${pkgver}-${pkgrel}.pkg.tar.gz -a "$FORCE" = "0" -a "$GENMD5" = "0" ]; then
if [ "$INSTALL" = "1" ]; then if [ "$INSTALL" = "1" ]; then
@ -553,7 +590,9 @@ if [ "$NOBUILD" = "1" ]; then
fi fi
# use ccache if it's available # use ccache if it's available
[ -d /usr/lib/ccache/bin ] && export PATH=/usr/lib/ccache/bin:$PATH if [ "$NOCCACHE" = "0" ]; then
[ -d /usr/lib/ccache/bin ] && export PATH=/usr/lib/ccache/bin:$PATH
fi
# build # build
msg "Starting build()..." msg "Starting build()..."
@ -567,6 +606,7 @@ fi
cd $startdir cd $startdir
rm -rf pkg/usr/info pkg/usr/share/info rm -rf pkg/usr/info pkg/usr/share/info
rm -rf pkg/usr/doc pkg/usr/share/doc rm -rf pkg/usr/doc pkg/usr/share/doc
rm -rf pkg/{usr,opt/gnome}/share/gtk-doc
# move /usr/share/man files to /usr/man # move /usr/share/man files to /usr/man
if [ -d pkg/usr/share/man ]; then if [ -d pkg/usr/share/man ]; then
@ -631,9 +671,6 @@ echo "pkgname = $pkgname" >>.PKGINFO
echo "pkgver = $pkgver-$pkgrel" >>.PKGINFO echo "pkgver = $pkgver-$pkgrel" >>.PKGINFO
echo "pkgdesc = $pkgdesc" >>.PKGINFO echo "pkgdesc = $pkgdesc" >>.PKGINFO
echo "url = $url" >>.PKGINFO echo "url = $url" >>.PKGINFO
for it in "${license[@]}"; do
echo "license = $it" >>.PKGINFO
done
echo "builddate = $builddate" >>.PKGINFO echo "builddate = $builddate" >>.PKGINFO
echo "packager = $packager" >>.PKGINFO echo "packager = $packager" >>.PKGINFO
echo "size = $size" >>.PKGINFO echo "size = $size" >>.PKGINFO
@ -641,6 +678,9 @@ if [ "$CARCH" != "" ]; then
echo "arch = $CARCH" >>.PKGINFO echo "arch = $CARCH" >>.PKGINFO
fi fi
for it in "${license[@]}"; do
echo "license = $it" >>.PKGINFO
done
for it in "${replaces[@]}"; do for it in "${replaces[@]}"; do
echo "replaces = $it" >>.PKGINFO echo "replaces = $it" >>.PKGINFO
done done
@ -687,9 +727,20 @@ if [ "$CLEANUP" = "1" ]; then
rm -rf src pkg filelist rm -rf src pkg filelist
fi fi
if [ "$RMDEPS" = "1" -a "`id -u`" = "0" -a "$INFAKEROOT" != "1" ]; then if [ "$RMDEPS" = "1" -a "`id -u`" = "0" -a "$INFAKEROOT" != "1" -a \( ! -z "$deplist" -o ! -z "$makedeplist" \) ]; then
msg "Removing installed dependencies..." msg "Removing installed dependencies..."
pacman -R $makedeplist $deplist pacman -R $makedeplist $deplist
elif [ "$RMDEPS" = "1" -a "$DEP_SUDO" = "1" ]; then
msg "Removing installed dependencies..."
if [ "$INFAKEROOT" = "1" ]; then
FAKEROOTKEY2=$FAKEROOTKEY
unset FAKEROOTKEY
fi
sudo pacman -R $makedeplist $deplist
if [ "$INFAKEROOT" = "1" ]; then
FAKEROOTKEY=$FAKEROOTKEY2
unset FAKEROOTKEY2
fi
fi fi
msg "Finished making: $pkgname (`date`)" msg "Finished making: $pkgname (`date`)"

View File

@ -2,7 +2,7 @@
# #
# makeworld # makeworld
# #
# Copyright (c) 2002-2004 by Judd Vinet <jvinet@zeroflux.org> # Copyright (c) 2002-2005 by Judd Vinet <jvinet@zeroflux.org>
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -20,8 +20,8 @@
# USA. # USA.
# #
version="2.9.7"
toplevel=`pwd` toplevel=`pwd`
version="2.9.2"
usage() { usage() {
echo "makeworld version $version" echo "makeworld version $version"

114
scripts/pacman-optimize Executable file
View File

@ -0,0 +1,114 @@
#!/bin/bash
#
# pacman-optimize
#
# Copyright (c) 2002-2005 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.9.7'
usage() {
echo "pacman-optimize $myver"
echo "usage: $0 [pacman_db_root]"
echo
echo "pacman-optimize is a little hack that should improve the performance"
echo "of pacman when reading/writing to its filesystem-based database."
echo
echo "Because pacman uses many small files to keep track of packages,"
echo "there is a tendency for these files to become fragmented over time."
echo "This script attempts to relocate these small files into one"
echo "contiguous location on your hard drive. The result is that the hard"
echo "drive should be able to read them faster, since the hard drive head"
echo "does not have to move around the disk as much."
echo
}
die() {
echo "pacman-optimize: $*" >&2
exit 1
}
die_r() {
rm -f /tmp/pacman.lck
die $*
}
dbroot="/var/lib/pacman"
if [ "$1" != "" ]; then
if [ "$1" = "-h" -o "$1" = "--help" ]; then
usage
exit 0
fi
dbroot=$1
fi
if [ "`id -u`" != 0 ]; then
die "You must be root to optimize the database"
fi
# make sure pacman isn't running
if [ -f /tmp/pacman.lck ]; then
die "Pacman lockfile was found. Cannot run while pacman is running."
fi
if [ ! -d $dbroot ]; then
die "$dbroot does not exist or is not a directory"
fi
# don't let pacman run while we do this
touch /tmp/pacman.lck
# step 1: sum the old db
echo "==> md5sum'ing the old database..."
find $dbroot -type f | sort | xargs md5sum >/tmp/pacsums.old
# step 1: copy the entire db directory to a new one
echo "==> copying $dbroot..."
cp -a $dbroot $dbroot.new || die_r "error copying $dbroot"
# step 2: switch the directory names and sum the new one
echo "==> md5sum'ing the new database..."
mv $dbroot $dbroot.bak || die_r "error renaming $dbroot"
mv $dbroot.new $dbroot || die_r "error renaming $dbroot.new"
find $dbroot -type f | sort | xargs md5sum >/tmp/pacsums.new
# step 3: compare sums
echo "==> checking integrity..."
diff /tmp/pacsums.old /tmp/pacsums.new >/dev/null 2>&1
if [ $? -ne 0 ]; then
# failed, move the old one back into place
rm -rf $dbroot
mv $dbroot.bak $dbroot
die_r "integrity check FAILED, reverting to old database"
fi
# step 4: remove the backup
echo "==> removing old database..."
rm -rf $dbroot.bak || die_r "error removing backup $dbroot.bak"
# remove the lock and sum files
rm -f /tmp/pacman.lck /tmp/pacsums.old /tmp/pacsums.new
echo
echo "Finished. Your pacman database has been optimized."
echo
exit 0

View File

@ -3,7 +3,7 @@
# updatesync # updatesync
# #
# Copyright (c) 2004 by Jason Chu <jason@archlinux.org> # Copyright (c) 2004 by Jason Chu <jason@archlinux.org>
# Derived from gensync (c) 2002-2004 Judd Vinet <jvinet@zeroflux.org> # Derived from gensync (c) 2002-2005 Judd Vinet <jvinet@zeroflux.org>
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -21,7 +21,7 @@
# USA. # USA.
# #
myver='2.9.2' myver='2.9.7'
usage() { usage() {
echo "updatesync $myver" echo "updatesync $myver"
@ -103,6 +103,17 @@ db_write_entry()
done done
echo "" >>desc echo "" >>desc
fi fi
if [ ${#replaces[*]} -gt 0 ]; then
echo "%REPLACES%" >>desc
for it in "${replaces[@]}"; do
echo "$it" >>desc
done
echo "" >>desc
fi
if [ "$force" = "y" -o "$force" = "Y" ]; then
echo "%FORCE%" >>desc
echo "" >>desc
fi
# depends # depends
: >depends : >depends
if [ ${#depends[*]} -gt 0 ]; then if [ ${#depends[*]} -gt 0 ]; then
@ -126,17 +137,6 @@ db_write_entry()
done done
echo "" >>depends echo "" >>depends
fi fi
if [ ${#replaces[*]} -gt 0 ]; then
echo "%REPLACES%" >>depends
for it in "${replaces[@]}"; do
echo "$it" >>depends
done
echo "" >>depends
fi
if [ "$force" = "y" -o "$force" = "Y" ]; then
echo "%FORCE%" >>depends
echo "" >>depends
fi
} }
delete_entry() delete_entry()