Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Jul 2001 23:37:54 +0200
From:      Alexander Langer <alex@big.endian.de>
To:        libh@FreeBSD.org
Subject:   packaging stuff
Message-ID:  <20010717233754.A948@zerogravity.kawo2.rwth-aachen.d>

next in thread | raw e-mail | index | archive | help

--SUOF0GtieIMvvwua
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi folks!

I created an initial part of package tools stuff for my own testing
purposes.  I want to share them, in case anyone is interested.
You have to run them with the statically linked tclh.  And you need
the latest CVS version, which is not yet in the ports tree.

Here is the documentation:

create_db.tcl:
	Creates an empty package database.

tclh.static create_db.tcl /tmp/libhdb
is what I use.

makepackage.sh:
	Create a package from a port.  Doesn't yet respect dependencies.
Well, I used this to create the also attached example package.
Heh, it's just *BASIC*!  You'll probably don't want to use it,
only if you want to test your own stuff.

pkg_install.tcl:
	Installs a package.

tclh.static pkg_install.tcl /tmp/libhdb xv-packagefile

You can get my xv-package from
http://people.FreeBSD.org/~alex/libh/packages/

This installs it (in /usr/local, which is actually wrong, because
it was build for /usr/X11R6, so you won't be able to use it.)
The nice thing is: If you re-install it, it considers it as an
upgrade installation and deinstalls the old copy first, respecting the
rules documented in sysinstall2.txt.
I *BELIEVE* it would also consider packages with a higher version
number as such upgrade packages, I just haven't build a real upgrade
package with a better version yet (soon to come).

file_owners.tcl:
	Lists all files and all owner-packages of files that are registered
	in the db.

tclh.static file_owners.tcl /tmp/libhdb

This is nice, because a) it demonstrates, what libh can actually do
already now, and b) you probably want to remove the files from
/usr/local again after testing, and I haven't written pkg_deinstall
yet ;-)

Oh, if you unzip the xv package, you find out how stuff works.
You can also manually set the installation prefix manually
in SYSINSTALL/structure.tcl.  Note that this won't work, because
create_db.tcl doesn't allow the safe interpreter to modify /usr/X11R6.
For some reason it doesn't respect additional dirs there, yet,
probably a bug.

Oh, part 2: the xv package doesn't have any dependencies yet, BUT:
libh's PackageCreator already stuff manpages and examples in so-called
subpackages (this once is the "documentation" subpackage), which is the
equivalent for NOPORTDOCS for example.
Once I've found out how to disable installation of those subpackages,
I'll add stuff to pkg_install.tcl (I just didn't care yet).
But yet alone the fact is nice to know :-)

Happy testing, I'm kinda impressed already now.  More to come.

Alex

--SUOF0GtieIMvvwua
Content-Type: application/x-tcl
Content-Disposition: attachment; filename="create_db.tcl"


set dbpath [lindex $argv 0]

if {$dbpath == ""} {
    puts stderr "Give path to db as argument"
    exit 1
}

set db [H::null]
if [catch {set db [Database $dbpath]} err] {
    if {![H::is_null $db]} {H::delete $db}
    set db [H::null]
    if {[catch {set db [Database::create $dbpath]} err]} {
	puts stderr "Error: $err"
    } else {
	puts "Database created in $dbpath"
	set allow [[DirectoriesAccess] allow]
	lappend allow {"$dbpath" "/usr/X11R6"} # XXX remove backslash at end of dir if any
	[DirectoriesAccess] allow $allow
	$db save_directories_access
	[Configuration] prefix "/usr/local"
    }
} else {
    puts stderr "Database $dbpath already exists.  Terminating."
    exit 1
}

exit 0

--SUOF0GtieIMvvwua
Content-Type: application/x-tcl
Content-Disposition: attachment; filename="file_owners.tcl"

set H_automatic_garbage_collection 0

# ----------------------------------------------------------------------

set dbpath [lindex $argv 0]

proc usage {} {
    puts stderr "Usage: file_owners.tcl dbpath filename"
}

if {$dbpath == ""} {
    usage
    exit 1
}

set db [H::null]
if [catch {set db [Database $dbpath]} err] {
	puts stderr "Can't open pkg db: $err"
	exit 1
    }

set files [$db all_files]
foreach file $files {
    set packages [$db packages_owning [$file pathname]]
    puts stderr "[$file pathname] [$file length] [H::string_time_t [$file mtime]]"
    foreach package $packages {
	puts stderr "\t[$package name]"
    }
}

exit 0

# ----------------------------------------------------------------------

--SUOF0GtieIMvvwua
Content-Type: application/x-sh
Content-Disposition: attachment; filename="makepackage.sh"

#!/bin/sh

if [ -z $2 ]; then echo "
# Simple package creating tool, contains too many hacks
# and doesn't respect @exec and stuff
# Usage: $0 /path/to/port /path/to/pkg-output-dir/
"
exit 1
fi

PORTDIR=$1
PKGDIR=$2
TMP=`mktemp -d /tmp/pkgXXXXXXXXX`
SCRIPT=`mktemp /tmp/scriptXXXXXXXX`

echo "This is the libh package creator."
echo ""

# Setup tree
echo "Installing port."
(cd $PORTDIR && make install)

echo "Files in package:"
PREFIX=`cd $PORTDIR && make -V PREFIX`
PLIST=`cd $PORTDIR && make -V TMPPLIST`
FILELIST=`cat $PLIST | sed -e 's|^@dirrm ||g' -e 's|^@.*||' | sort | uniq -u`
# depends: make package-depends package-depends | ${GREP} -v -E ${PKG_IGNORE_DEPENDS} | sort -u`"

echo "Adding files to $TMP"
(cd $PREFIX && tar -cpf - $FILELIST) | (cd $TMP && tar -xvpf -)

# Some VERSIONING
PKGNAME=`cd $PORTDIR && make -V PKGNAME`
PORTNAME=`cd $PORTDIR && make -V PORTNAME`
PORTVERSION=`cd $PORTDIR && make -V PORTVERSION`
PORTREVISION=`cd $PORTDIR && make -V PORTREVISION`

SUMMARY=`cat $PORTDIR/pkg-comment`
DESCRIPTION=`cat $PORTDIR/pkg-descr`
AUTHOR=`cd $PORTDIR && make -V MAINTAINER`

if [ ! -e $PKGDIR ]; then mkdir $PKGDIR; fi

mkdir $TMP/SYSINSTALL

# XXX add dependencies into requires

cat > $TMP/SYSINSTALL/features.tcl <<EOF
proc provides {} {
    return [list [Feature "$PORTNAME" "$PORTVERSION"]]
}

# This is the system feature followed by the dependencies
proc requires {} {
    return [list [Feature "i386" "3.0"]]
}
EOF

cat > $SCRIPT << EOF
set creator [PackageCreator::PackageCreator "$PKGNAME" "$PKGDIR" "$TMP"]
\$creator generate
\$creator write_package_file
EOF

../../bin/tclh/tclh.static $SCRIPT

rm -f $SCRIPT
rm -rf $TMP

--SUOF0GtieIMvvwua
Content-Type: application/x-tcl
Content-Disposition: attachment; filename="pkg_install.tcl"


set dbpath [lindex $argv 0]
set filename [lindex $argv 1]

proc usage {} {
    puts stderr "Usage: pkg_install.tcl dbpath filename"
}

if {$dbpath == "" || $filename == ""} {
    usage
    exit 1
}

set db [H::null]
if [catch {set db [Database $dbpath]} err] {
	puts stderr "Can't open pkg db: $err"
	exit 1
    }

if [catch {set stream [Archive::open $filename]} err ] {
    puts stderr "Can't open $filename: $err"
    exit 1
}

set package_stream [PackageStream::open $stream slave]
puts "Package: [$package_stream name]"
puts "Summary: [[$package_stream description] summary]"
puts "Description:"
puts [[$package_stream description] description]
puts "Author: [[$package_stream description] author]"

proc view_log {} {
    puts [[Log] text]
}

proc package_action {package_stream action} {
    # No set objects_references [H::objects_references]

    global db
    set old_log_type [Log::gettype]
    Log::type "string"
    if [catch {$package_stream $action $db} err] {
	puts stderr "Can't $action pkg: $err"
	exit 1
    } else {
	puts "Package [$package_stream name] ${action}ed, log:"
	view_log
    }
    $db flush
    [Log] clear
    Log::type $old_log_type
}

# XXX Add upgrade vs. install hooks

package_action $package_stream install

exit 0

--SUOF0GtieIMvvwua--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-libh" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010717233754.A948>