aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilly Tarreau <w@1wt.eu>2006-07-16 14:53:16 +0200
committerWilly Tarreau <willy@wtap.(none)>2006-07-26 10:48:56 +0200
commitc3b5c7e66d92b09348de5e09474838ed430c1195 (patch)
tree89e3ecc862328405a872abbe8edb18b4c8cdbb71
parent[RELEASE] flxutils-0.1.8 (diff)
downloadflxutils-c3b5c7e66d92b09348de5e09474838ed430c1195.tar.gz
[RELEASE] flxutils-0.1.9v0.1.9
-rwxr-xr-xscripts/flxextract95
-rwxr-xr-xscripts/flxsearch23
-rwxr-xr-xscripts/pkg6
3 files changed, 60 insertions, 64 deletions
diff --git a/scripts/flxextract b/scripts/flxextract
index 43d4ca0..bfecb25 100755
--- a/scripts/flxextract
+++ b/scripts/flxextract
@@ -1,41 +1,55 @@
#!/bin/bash
function main {
- local file packages pack
+ local file packages pack pkgsrc
exec 3>&0
# cette boucle permet de rechercher le package à utiliser pour trouver
# le fichier si cela est possible
while read file packages; do
echo -n \# >&2
- if [ -z "$packages" ] ; then echo "$file -" >> $SFILES ; continue ; fi
- packagesgrep=${packages//,/\\|}
- files=( $(grep -m 1 "^$file .*/\($packagesgrep\).*$" $SOURCE | awk '{print $2}') )
- pkgsrc=""
- for pack in ${packages//,/ } ; do
- i=0; while [ $i -lt ${#files[*]} ] ; do
- [ ${files[$i]/$pack} != ${files[$i]} ] && pkgsrc=${files[$i]} && break
- i=$[$i+1]
- done
+ if [ -z "$packages" ] ; then echo "##no package## $file" >> $LOGFILE ; continue ; fi
+
+ for pack in ${packages//,/ }; do
+ pkgsrc=$(find $SEARCHPATH -name ${pack}'*'.lst | head -1)
[ "$pkgsrc" ] && break
- done
- if [ "$pkgsrc" ] ; then
- echo "$file $pkgsrc" >> $SFILES
+ done
+
+ if [ -z "$pkgsrc" ]; then
+ echo "##no package## $file $packages" >> $LOGFILE
+ continue
+ fi
+
+ set -- $( grep "$file" $pkgsrc | awk '{ if ($8=="'$file'") print $0; }' )
+ if [ -z "$*" ]; then
+ echo "##not found## $file $pkgsrc" >> $LOGFILE
+ continue
+ fi
+ if [ "x$1" = "xd" ]; then
+ # it's a directory
+ rm -f $ROOTDIR/$8 # just in case it was something else
+ mkdir -p $ROOTDIR/$8
+ touch -t `date -d "Jan 1 00:00:$7 UTC 1970" +"%Y%m%d%H%M.%S" ` $ROOTDIR/$8
+ chown $3:$4 $ROOTDIR/$8
+ chmod $2 $ROOTDIR/$8
+ echo "$8/" >> $LOGFILE
else
- echo "$file -" >> $SFILES
+ # it's a regular file
+ echo $8 $pkgsrc >> $SFILES
fi
done < $LFILES
- echo
+
+ echo >&2 ; echo -n "Extracting files ..." >&2
for lst in $( awk '{print $2}' $SFILES | sort -u ) ; do
- if [ "x$lst" = "x-" ] ; then continue ; fi
tgz="$(dirname $lst)/$(basename $lst .lst).tgz"
- grep -- " $lst$" $SFILES | awk '{print $1}' | tar zxpvf $tgz -C $ROOTDIR -T - >> $LOGFILE
+ grep -- " $lst$" $SFILES | awk '{print $1}' | tar zUxpvf $tgz -C $ROOTDIR -T - >> $LOGFILE
+ echo -n "." >&2
done
- grep -- " -$" $SFILES | awk '{print "##unresolved##",$1}' >> $LOGFILE
+ echo "." >&2
}
# repertoire contenant les .lst et les .tgz servant de source
SEARCHPATH=$PKGROOT
-SEARCHPATH=${SEARCHPATH:-.}
+SEARCHPATH=${SEARCHPATH:-.}/.
# temporary file and directory
TMP=$(date +%y%m%d)-$RANDOM
@@ -52,7 +66,7 @@ while [ $# -gt 0 ] ; do
case "$1" in
-i) # <infile> fichiers sources des autres fichiers
[ "$2" ] || PRINTUSAGE=1
- INPUT="$INPUT $2"
+ INPUT=( $INPUT $2 )
shift;
;;
-l) # <logfile> fichier de reference pour les associations fichier/package
@@ -62,7 +76,7 @@ while [ $# -gt 0 ] ; do
;;
-p) # <pkgdir> repertoire de recherche pour les packages
[ "$2" ] || PRINTUSAGE=1
- SEARCHPATH="$SEARCHPATH $2"
+ SEARCHPATH="$SEARCHPATH $2/."
shift
;;
-R) # <destdir> répertoire d'extraction pour les fichiers
@@ -89,12 +103,12 @@ fi
# par défaut, ROOTDIR est fonction de la date
DATE=$(date +%Y%m%d-%H%M%S)
ROOTDIR=${ROOTDIR:-/tmp/package-$DATE}
-if [ -e $ROOTDIR ] ; then
- echo "Error : directory $ROOTDIR already exists."
- exit 1
-fi
+#if [ -e $ROOTDIR ] ; then
+# echo "Error : directory $ROOTDIR already exists."
+# exit 1
+#fi
-LOGFILE=${LOGFILE:-/tmp/package-$DATE}.log
+LOGFILE=${LOGFILE:-/tmp/package-$DATE.log}
if [ -e $LOGFILE ] ; then
echo "Error : log file $LOGFILE exists."
exit 0
@@ -104,41 +118,14 @@ mkdir -p $ROOTDIR
# fabrication des fichiers temporaires
mkdir -p -m 700 $TMPDIR
-# fichier contenant l'ensemble des fichiers disponibles et leur package source
-SOURCE=$TMPDIR/source ; touch $SOURCE
# fichier contenant l'ensemble des fichiers requis
LFILES=$TMPDIR/lfiles ; touch $LFILES
# fichier contenant la correspondance non du package source du package
SFILES=$TMPDIR/sfiles ; touch $SFILES
-
-
-# fabrication d'un fichier contenant l'ensemble des fichiers disponibles avec leur package
-# source
-OLDIFS=$IFS ; IFS=$'\n'
-for path in $SEARCHPATH ; do
- if [ -d $path ] ; then
- for file in $( ls $path/*.lst ) ; do
- # echo -n \# >&2
- # pkgname=$( basename $file .lst )
- # matchlist=$pkgname # ,${pkgname%-*},${pkgname%-*-*},${pkgname%%-*}
- # attention aucun traitement d'un espace (\ ) dans le nom de fichier
- awk '{print $8,"'$file'"}' $file >> $SOURCE
- done
- fi
-done
-
-IFS=$OLDIFS
-
# fabrication d'un fichier contenant la liste de tous les fichiers recherchés
# le fichier source peut contenir lui-même des informations de packages de provenance
-if [ "$INPUT" ] ; then
- for file in $INPUT ; do
- cat $file >> $LFILES
- done
-else
- cat >> $LFILES
-fi
+cat $INPUT > $LFILES
sort -u $LFILES > $LFILES.new ; rm $LFILES ; mv $LFILES.new $LFILES
main
diff --git a/scripts/flxsearch b/scripts/flxsearch
index 41e435d..1820020 100755
--- a/scripts/flxsearch
+++ b/scripts/flxsearch
@@ -66,7 +66,7 @@ function choice {
function main {
local file
local packages pack
- local -a sources
+ local -a sources forced
local pkgname matchlist
exec 3>&0
@@ -82,15 +82,23 @@ function main {
# check forced packages
if [ ${#sources[*]} -gt 1 ] ; then
- local -a forced=( $( for i in ${sources[*]} ; do f=${i##*/} ; f=${f%%.lst};
- [ "x${FORCED/* $f */}" == "x" ] && echo $i ; done ) )
- [ "${#forced[*]}" -gt 0 ] && sources=( $forced[*] )
+ forced=( $( for i in ${sources[*]} ; do f=${i##*/} ;
+ f=${f%%.lst}; [ "x${FORCED/* $f */}" == "x" ] && echo $i && break ;
+ f=${f%-*}; [ "x${FORCED/* $f */}" == "x" ] && echo $i && break ;
+ f=${f%-*}; [ "x${FORCED/* $f */}" == "x" ] && echo $i && break ;
+ f=${f%%[._-][0-9]*}; [ "x${FORCED/* $f */}" == "x" ] && echo $i && break ;
+ done ) )
+ [ "${#forced[*]}" -gt 0 ] && sources=( ${forced[*]} )
fi
# remove rejected package
if [ ${#sources[*]} -gt 1 ] ; then
- sources=( $( for i in ${sources[*]} ; do f=${i##*/} ; f=${f%%-*};
- [ "x${EXCEPT/* $f */}" != "x" ] && echo $i ; done ) )
+ sources=( $( for i in ${sources[*]} ; do f=${i##*/} ;
+ f=${f%%.lst}; [ "x${EXCEPT/* $f */}" == "x" ] && echo $i && break ;
+ f=${f%-*}; [ "x${EXCEPT/* $f */}" == "x" ] && echo $i && break ;
+ f=${f%-*}; [ "x${EXCEPT/* $f */}" == "x" ] && echo $i && break ;
+ f=${f%%[._-][0-9]*}; [ "x${EXCEPT/* $f */}" == "x" ] && echo $i && break ;
+ done ) )
fi
if [ "$RECHECK" = 1 -a "$packages" ] ; then
@@ -223,8 +231,9 @@ LFILES=$TMPDIR/lfiles ; touch $LFILES
# fabrication d'un fichier contenant l'ensemble des fichiers disponibles avec leur package
# source
-OLDIFS=$IFS ; IFS=$'\n'
+OLDIFS=$IFS
for path in $SEARCHPATH ; do
+ IFS=$'\n'
if [ -d $path ] ; then
for file in $( ls $path/*.lst ) ; do
# echo -n \# >&2
diff --git a/scripts/pkg b/scripts/pkg
index 950c41c..4d564ee 100755
--- a/scripts/pkg
+++ b/scripts/pkg
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# /usr/sbin/pkg - Formilux source package manager - version 0.2.1 - 2003-02-11
+# /usr/sbin/pkg - Formilux source package manager - version 0.2.2 - 2003-02-14
#
# Copyright (C) 2001-2003 Benoit Dolez & Willy Tarreau
# mailto: benoit@ant-computing.com,willy@ant-computing.com
@@ -281,7 +281,7 @@ function do_pack_files {
echo "done."
echo -n "Creating $PKGROOT/$packver.lst ... "
- (flx sign --no-depth --ignore-dot `cut -f1 -d' ' $FILE_LIST` > $PKGROOT/$packver.lst) > /dev/null 2>&1
+ (flx sign --no-depth --ignore-dot `cut -f1 -d' ' $FILE_LIST|sed -e 's,/$,,'` > $PKGROOT/$packver.lst) > /dev/null 2>&1
echo "done."
F=$PKGROOT/$packver.$PKGSUFF
@@ -289,7 +289,7 @@ function do_pack_files {
# we want everything, and directories only if they're empty. All this without './'
# we shouldn't get an empty line since . should contain at least what we want to tar !
- cut -f1 -d' ' $FILE_LIST | tar -T - -cf - | gzip -9 >$F 2>/dev/null
+ cut -f1 -d' ' $FILE_LIST|sed -e 's,/$,,' | tar -T - --no-recursion -cf - | gzip -9 >$F 2>/dev/null
echo "done."
if [ -n "$CFGFILE" ]; then