util: Added a 'common.sh' for some common stuff and removed add_tar.sh
This commit is contained in:
parent
181cf4ae69
commit
36301e1ffd
5 changed files with 30 additions and 33 deletions
|
|
@ -1,16 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Usage: add_tar.sh <file> <pkgid> <flags>
|
||||
# Requires a recent GNU tar for compression autodetect and xz support.
|
||||
|
||||
|
||||
TMP=`mktemp -d manned.XXXXXXX`
|
||||
|
||||
# TODO: tar throws an error if there are no man pages. This isn't really an error, though.
|
||||
tar --warning=no-unknown-keyword -C "$TMP" $3 -xf "$1" --wildcards '*/man/*'\
|
||||
&& ./add_dir.pl "$TMP" "$2"
|
||||
RET=$?
|
||||
|
||||
rm -rf "$TMP"
|
||||
exit $RET
|
||||
|
||||
|
|
@ -9,10 +9,7 @@ REPOS="core extra community"
|
|||
DEBUG=false
|
||||
SYSID=1
|
||||
|
||||
CURL="curl -fSs -A manual-page-crawler,info@manned.org"
|
||||
PSQL="psql -U manned -Awtq"
|
||||
TMP=`mktemp -d manned.arch.XXXXXX`
|
||||
|
||||
. ./common.sh
|
||||
|
||||
# Returns 0 if the package is already in the database or if an error occured.
|
||||
# Otherwise adds the package, sets PKGID to the new ID, and returns 1.
|
||||
|
|
@ -67,7 +64,7 @@ checkpkg() {
|
|||
echo "===> $FN"
|
||||
F="$TMP/$REPO/$FILENAME"
|
||||
$CURL "$MIRROR/$REPO/os/i686/$FILENAME" -o "$F" || return
|
||||
./add_tar.sh "$F" "$PKGID"
|
||||
add_tar "$F" "$PKGID"
|
||||
rm -f "$F"
|
||||
}
|
||||
|
||||
|
|
@ -91,5 +88,3 @@ for r in $REPOS; do
|
|||
rm -rf "$TMP/$r"
|
||||
done
|
||||
|
||||
rm -rf "$TMP"
|
||||
|
||||
|
|
|
|||
24
util/common.sh
Normal file
24
util/common.sh
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
CURL="curl -fSs -A manual-page-crawler,info@manned.org --limit-rate 500k"
|
||||
PSQL="psql -U manned -Awtq"
|
||||
|
||||
TMP=`mktemp -d manned.XXXXXX`
|
||||
|
||||
# bash-ism, remove the working directory when we're done.
|
||||
trap "rm -rf $TMP" EXIT
|
||||
|
||||
|
||||
|
||||
# Usage: add_tar <file> <pkgid> <flags>
|
||||
# Requires a recent GNU tar for compression autodetect and xz support.
|
||||
# TODO: tar throws an error if there are no man pages, but this isn't really an
|
||||
# error.
|
||||
add_tar() {
|
||||
DIR=`mktemp -d "$TMP/tar.XXXXXXX"`
|
||||
tar --warning=no-unknown-keyword -C "$DIR" $3 -xf "$1" --wildcards '*/man/*'\
|
||||
&& ./add_dir.pl "$DIR" "$2"
|
||||
RET=$?
|
||||
rm -rf "$DIR"
|
||||
return $RET
|
||||
}
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
PSQL="psql -U manned -Awtq"
|
||||
. ./common.sh
|
||||
|
||||
./arch.sh
|
||||
./deb.sh ubuntu_active
|
||||
|
|
|
|||
12
util/deb.sh
12
util/deb.sh
|
|
@ -2,10 +2,7 @@
|
|||
|
||||
# A fetcher for debian-style repositories.
|
||||
|
||||
CURL="curl -fSs -A manual-page-crawler,info@manned.org --limit-rate 500k"
|
||||
PSQL="psql -U manned -Awtq"
|
||||
TMP=`mktemp -d manned.deb.XXXXXX`
|
||||
|
||||
. ./common.sh
|
||||
|
||||
checkpkg() {
|
||||
SYSID=$1
|
||||
|
|
@ -41,7 +38,7 @@ checkpkg() {
|
|||
if [ "$?" -eq 0 -a -n "$PKGID" ]; then
|
||||
# Old format
|
||||
if [ "`head -c8 \"$FN\"`" = "0.939000" ]; then
|
||||
tail -n+3 "$FN" | tail -c+"`head -n2 \"$FN\" | tail -n1`" | tail -c+2 | ./add_tar.sh - $PKGID -z
|
||||
tail -n+3 "$FN" | tail -c+"`head -n2 \"$FN\" | tail -n1`" | tail -c+2 | add_tar - $PKGID -z
|
||||
|
||||
# New format
|
||||
else
|
||||
|
|
@ -54,7 +51,7 @@ checkpkg() {
|
|||
*) echo "No data.tar found, or unknown compression format."; DATAZ="ERR" ;;
|
||||
esac
|
||||
|
||||
[ "$DATAZ" != "ERR" ] && ar p "$FN" "$DATAFN" | ./add_tar.sh - $PKGID $DATAZ
|
||||
[ "$DATAZ" != "ERR" ] && ar p "$FN" "$DATAFN" | add_tar - $PKGID $DATAZ
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
@ -139,7 +136,6 @@ EOP
|
|||
|
||||
|
||||
|
||||
# TODO: Index stuff from snapshot.debian.org
|
||||
# TODO: backports?
|
||||
# TODO: Debian testing?
|
||||
|
||||
|
|
@ -377,5 +373,3 @@ debian_snapshot_month() {
|
|||
|
||||
"$@"
|
||||
|
||||
rm -rf "$TMP"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue