FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CRUX > CRUX

 
 
LinkBack Thread Tools
 
Old 02-17-2008, 09:38 PM
Jose V Beneyto
 
Default Package Guidelines - pkgmk patch - repoverify

Hi!

I write a patch for 'pkgmk' in order to test results in runtime > see
attached files <


Its only an idea, not a definitive patch, and surely others can write
better code,so the
objective is validate ports to avoid porting errors disagree with the
Per idea.


That could be very useful for packagers and also for users who wants to
have a CRUX

system as described in Handbook2-4#ntoc26

In addition I write another tool for automating the verification of
port's repositories
based on' prtverify' which could be nice for repo maintainers > see
attached files <



What are your opinions about that?


Some tests:

* pkgmk without the patch

$ pkgmk
=======> WARNING: Packages should be built as root.
=======> Building
'/devel/tmp/pkgmk.patches/testport/testport#1-1.pkg.tar.gz'.

+ build
+ mkdir -p /devel/tmp/pkgmk.patches/testport/work/pkg/opt
+ mkdir -p /devel/tmp/pkgmk.patches/testport/work/pkg/usr/share/doc
/devel/tmp/pkgmk.patches/testport/work/pkg/usr/share/locale

+ mkdir -p /devel/tmp/pkgmk.patches/testport/work/pkg/usr/share/man/man1
+ touch
/devel/tmp/pkgmk.patches/testport/work/pkg/usr/share/man/man1/test.1

=======> Build result:
drwxr-xr-x sepen/users 0 2008-02-17 21:39 opt/
drwxr-xr-x sepen/users 0 2008-02-17 21:39 usr/
drwxr-xr-x sepen/users 0 2008-02-17 21:39 usr/share/
drwxr-xr-x sepen/users 0 2008-02-17 21:39 usr/share/doc/
drwxr-xr-x sepen/users 0 2008-02-17 21:39 usr/share/man/
drwxr-xr-x sepen/users 0 2008-02-17 21:39 usr/share/man/man1/
-rw-r--r-- sepen/users 27 2008-02-17 21:39
usr/share/man/man1/test.1.gz

drwxr-xr-x sepen/users 0 2008-02-17 21:39 usr/share/locale/
=======> Building
'/devel/tmp/pkgmk.patches/testport/testport#1-1.pkg.tar.gz' succeeded.



* pkgmk with the patch

$ ./pkgmk
=======> WARNING: Packages should be built as root.
=======> Building
'/devel/tmp/pkgmk.patches/testport/testport#1-1.pkg.tar.gz'.

+ build
+ mkdir -p /devel/tmp/pkgmk.patches/testport/work/pkg/opt
+ mkdir -p /devel/tmp/pkgmk.patches/testport/work/pkg/usr/share/doc
/devel/tmp/pkgmk.patches/testport/work/pkg/usr/share/locale

+ mkdir -p /devel/tmp/pkgmk.patches/testport/work/pkg/usr/share/man/man1
+ touch
/devel/tmp/pkgmk.patches/testport/work/pkg/usr/share/man/man1/test.1

=======> ERROR: /usr/share/locale directory found.
... and to get the same results as pkgmk does now without the patch
$ ../pkgmk -it
=======> WARNING: Packages should be built as root.
=======> Building
'/devel/tmp/pkgmk.patches/testport/testport#1-1.pkg.tar.gz'.

+ build
+ mkdir -p /devel/tmp/pkgmk.patches/testport/work/pkg/opt
+ mkdir -p /devel/tmp/pkgmk.patches/testport/work/pkg/usr/share/doc
/devel/tmp/pkgmk.patches/testport/work/pkg/usr/share/locale

+ mkdir -p /devel/tmp/pkgmk.patches/testport/work/pkg/usr/share/man/man1
+ touch
/devel/tmp/pkgmk.patches/testport/work/pkg/usr/share/man/man1/test.1

=======> Build result:
drwxr-xr-x sepen/users 0 2008-02-17 21:41 opt/
drwxr-xr-x sepen/users 0 2008-02-17 21:41 usr/
drwxr-xr-x sepen/users 0 2008-02-17 21:41 usr/share/
drwxr-xr-x sepen/users 0 2008-02-17 21:41 usr/share/doc/
drwxr-xr-x sepen/users 0 2008-02-17 21:41 usr/share/man/
drwxr-xr-x sepen/users 0 2008-02-17 21:41 usr/share/man/man1/
-rw-r--r-- sepen/users 27 2008-02-17 21:41
usr/share/man/man1/test.1.gz

drwxr-xr-x sepen/users 0 2008-02-17 21:41 usr/share/locale/
=======> WARNING: Footprint not found, creating new.
=======> Building
'/devel/tmp/pkgmk.patches/testport/testport#1-1.pkg.tar.gz' succeeded.




* repoverify (example with gdesklets form nym repository)

$ cat > ~/.repoverify-nym.conf
nym_repodeps="core opt xorg contrib gnome"

$ repoverify -p gdesklets nym -c ~/.repoverify-nym.conf
/usr/ports/nym/gdesklets (Aaron Marks <nymacro AT gmail DOT com>)
Redundant deps for gdesklets are: pygtk pyorbit python
WARN nym/gdesklets ............ invalid email address: <nymacro AT gmail DOT com>











#!/bin/bash
#
# Description: Script for verifying an entire repository of crux's ports
# Author: Jose V Beneyto, sepen at users dot sourceforge dot net
# License: GNU/GPL (http://www.gnu.org/copyleft/gpl.html

DEBUG=0

FIND_REDUNDANT_DEPS=/usr/bin/findredundantdeps
PRT_VERIFY=/usr/bin/prtverify
PRTGET_CONF=/etc/prt-get.conf
PORTS_PATH=/usr/ports
TMP_FILE=/tmp/$(basename $0).$$
USER_CONFIG_FILE=$HOME/.$(basename $0).conf

core_repodeps="core"
opt_repodeps="core opt xorg"
xorg_repodeps="core opt xorg"
contrib_repodeps="core opt xorg contrib"
gnome_repodeps="core opt xorg gnome"
kde_repodeps="core opt xorg kde"
xfce_repodeps="core opt xorg xfce"
e17_repodeps="core opt xorg e17"
user_repodeps="core opt xorg contrib"

msgUsage() {
echo "Usage: `basename $0` <options> repository"
echo "Where options are:"
echo " -l loglevel Filter level for ouput messages (info,warn,error,fatal)"
echo " -p port Verify only selected port"
echo " -c c_file Use alternative configuration file"
echo " -o o_file Print results to output file"
echo " -h Shows this help information"
echo " -v Verbose output"
exit 1
}
msgError() {
message="$1"
echo "error, $message" 2>&1
exit 1
}
verifyDepsAndFiles() {
portpath="$1"
portname=$(basename $portpath)
reponame=$(basename $(dirname $portpath))
$FIND_REDUNDANT_DEPS $portname 2>&1
$PRT_VERIFY -l $LOG_LEVEL -m missing-deps $collections $portpath 2>&1
$PRT_VERIFY -l $LOG_LEVEL -m file-conflict $collections $portpath 2>&1
}

verifySources() {
portpath="$1"
. $portpath/Pkgfile
for src in ${source[@]}; do
if [[ "$(echo $src | grep '^http://')" != "" ]]; then
httpheader=$(curl --connect-timeout 10 --silent -I $src | sed 1q)
httpcode=$(echo $httpheader | cut -d' ' -f2)
if [[ $httpcode == 302 ]] || [[ $httpcode == 301 ]]; then
[[ $LOG_LEVEL -eq 8 ]] && echo "INFO Url '$src': $httpheader"
elif [[ $httpcode != 200 ]]; then
[[ $LOG_LEVEL -gt 1 ]] && echo "ERROR Url '$src': $httpheader"
fi
elif [[ "$(echo $src | grep '^ftp://')" != "" ]]; then
ftpheader=$(curl --connect-timeout 10 --silent -I $src | sed 1q)
if [[ -z $ftpheader ]]; then
[[ $LOG_LEVEL -gt 1 ]] && echo "ERROR Url '$src': Not Found"
fi
elif [[ ! -f $portpath/$src ]]; then
[[ $LOG_LEVEL -gt 1 ]] && echo "ERROR File '$portpath/$src': Not Found"
fi
done
}


# main
[[ ! -x $FIND_REDUNDANT_DEPS ]] && msgError "can't execute '$FIND_REDUNDANT_DEPS'"
[[ ! -x $PRT_VERIFY ]] && msgError "can't execute '$PRTVERIFY'"
[[ ! -r $PRTGET_CONF ]] && msgError "can't read '$PRTGET_CONF'"

# parse
LOG_LEVEL=4
CONFIG=0
VERBOSE=0
if [[ $# -lt 1 ]]; then
msgUsage
elif [[ $# -eq 1 ]]; then
REPO="$1"
else
# options
for arg in $@; do
case $arg in
-l) prev_arg="-l" ;;
-p) prev_arg="-p" ;;
-c) prev_arg="-c" ;;
-o) prev_arg="-o" ;;
-v) prev_arg="-v"; VERBOSE=1 ;;
-h) msgUsage ;;
-*) msgUsage ;;
*) case $prev_arg in
-l) case $arg in
info) LOG_LEVEL=8 ;;
warn) LOG_LEVEL=4 ;;
err) LOG_LEVEL=2 ;;
fatal) LOG_LEVEL=1 ;;
esac ;;
-p) PORT="$arg" ;;
-c) USER_CONFIG_FILE="$arg"; CONFIG=1 ;;
-o) OUTPUT_FILE="$arg" ;;
-*) prev_arg="NA" ;;
*) REPO="$arg" ;;
esac
prev_arg="NA" ;;
esac
done
fi

if [[ $DEBUG -eq 1 ]]; then
echo "LOG_LEVEL: $LOG_LEVEL"
echo "VERBOSE: $VERBOSE"
echo "CONFIG: $CONFIG"
echo "CONFIG_FILE: $USER_CONFIG_FILE"
echo "OUTPUT_FILE: $OUTPUT_FILE"
echo "REPO: $REPO"
echo "PORT: $PORT"
exit 1
fi

[[ ! -d $PORTS_PATH/$REPO ]] && msgError "'$PORTS_PATH/$REPO' is not a repository"

if [[ $CONFIG -eq 1 ]]; then
[[ ! -r $USER_CONFIG_FILE ]] && msgError "can't read '$USER_CONFIG_FILE'"
userline=$(grep ${repo}_repodeps $USER_CONFIG_FILE)
if [[ ! -z $userline ]]; then
user_repodeps="$(echo $userline | sed -e "s|"||g" -e "s|${repo}_repodeps=||")"
fi
fi

case $REPO in
core) repodeps=$core_repodeps ;;
opt) repodeps=$opt_repodeps ;;
xorg) repodeps=$xorg_repodeps ;;
contrib) repodeps=$contrib_repodeps ;;
gnome) repodeps=$gnome_repodeps ;;
kde) repodeps=$kde_repodeps ;;
xfce) repodeps=$xfce_repodeps ;;
e17) repodeps=$e17_repodeps ;;
*) repodeps=$user_repodeps ;;
esac

collections=$(for repo in ${repodeps[@]}; do echo -ne " -c $PORTS_PATH/$REPO"; done)

if [[ ! -z $PORT ]]; then
ports=$(find $PORTS_PATH/$REPO -type d -name $PORT)
else
ports=$(find $PORTS_PATH/$REPO -maxdepth 2 -name 'Pkgfile' -exec dirname {}
fi

[[ ! -z $OUTPUT_FILE ]] && : > $OUTPUT_FILE

for path2port in ${ports[@]}; do
maintainer=$(grep '^# Maintainer: ' $path2port/Pkgfile | sed 's|^# Maintainer: ||')
echo "$path2port ($maintainer)" >$TMP_FILE
verifyDepsAndFiles $path2port 2>&1 >>$TMP_FILE
verifySources $path2port 2>&1 >>$TMP_FILE
echo >> $TMP_FILE
if [[ $(wc -l $TMP_FILE | cut -d' ' -f1) -gt 2 ]] || [[ $VERBOSE -eq 1 ]]; then
if [[ ! -z $OUTPUT_FILE ]]; then
cat $TMP_FILE | awk '!s[$0]++' 2>&1 >>$OUTPUT_FILE
else
cat $TMP_FILE | awk '!s[$0]++' 2>&1
fi
fi
done

[[ -f $TMP_FILE ]] && rm -f $TMP_FILE

# End of File
--- /usr/bin/pkgmk 2007-12-25 22:55:08.000000000 +0100
+++ pkgmk 2008-02-17 05:37:34.000000000 +0100
@@ -276,6 +276,31 @@ strip_files() {
done
}

+test_directories() {
+ local DIR TARGET
+
+ for DIR in $PKG/usr/share/locale
+ $PKG/usr/share/doc
+ $PKG/usr/doc
+ $PKG/usr/info
+ $PKG/usr/share/man
+ $PKG/opt
+ $PKG/usr/libexec
+ $PKG/usr/X11R6; do
+
+ if [ -d $DIR ]; then
+ TARGET=`echo $DIR | sed "s|$PKG||"`
+ error "$TARGET directory found."
+ exit 1
+ fi
+ done
+}
+
+test_files() {
+ # todo: something like prtverify to look for junk files
+ local FILE TARGET
+}
+
compress_manpages() {
local FILE DIR TARGET

@@ -361,7 +386,12 @@ build_package() {
if [ "$PKGMK_NO_STRIP" = "no" ]; then
strip_files
fi
-
+
+ if [ "$PKGMK_IGNORE_TESTS" = "no" ]; then
+ test_directories
+ test_files
+ fi
+
compress_manpages

cd $PKG
@@ -493,6 +523,7 @@ interrupted() {
print_help() {
echo "usage: `basename $PKGMK_COMMAND` [options]"
echo "options:"
+ echo " -it --ignore-tests ignore tests for invalid directories and files"
echo " -i, --install build and install package"
echo " -u, --upgrade build and install package (as upgrade)"
echo " -r, --recursive search for and build packages recursively"
@@ -516,6 +547,8 @@ print_help() {
parse_options() {
while [ "$1" ]; do
case $1 in
+ -it|--ignore-tests)
+ PKGMK_IGNORE_TESTS="yes" ;;
-i|--install)
PKGMK_INSTALL="install" ;;
-u|--upgrade)
@@ -658,6 +691,7 @@ PKGMK_SOURCE_DIR="$PWD"
PKGMK_PACKAGE_DIR="$PWD"
PKGMK_WORK_DIR="$PWD/work"

+PKGMK_IGNORE_TESTS="no"
PKGMK_INSTALL="no"
PKGMK_RECURSIVE="no"
PKGMK_DOWNLOAD="no"
_______________________________________________
CRUX mailing list
CRUX@lists.crux.nu
http://lists.crux.nu/mailman/listinfo/crux
 

Thread Tools




All times are GMT. The time now is 10:05 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org