Submitted by:   wbb4@
Reviewed by:    wbb4@
Approved by:
Obtained from:  wbb4-versionfoobage-1 branch, pguyot@, wbb4@

This is the merge of the Port Images branch (wbb4-versionfoobage-1) into HEAD.

git-svn-id: https://svn.macports.org/repository/macports/trunk/base@7620 d073be05-634f-4543-b044-5fe20cf6d1d6
This commit is contained in:
Will Barton
2004-07-01 17:21:18 +00:00
parent 7e24e3b16f
commit b70821793c
44 changed files with 4921 additions and 1695 deletions
+2
View File
@@ -19,3 +19,5 @@ distclean::
rm -f config.log config.status configure.lineno
rm -rf autom4te.cache
rm -f Makefile Mk/dports.autoconf.mk
test::
+2 -1
View File
@@ -4,12 +4,13 @@ srcdir = @srcdir@
VPATH = @srcdir@
CC = @CC@
CFLAGS = $(CFLAGS_DEBUG) $(CFLAGS_OPTIMIZE) $(CPPFLAGS)
CFLAGS = $(CFLAGS_QUICHEEATERS) $(CFLAGS_DEBUG) $(CFLAGS_OPTIMIZE) $(CPPFLAGS)
CPPFLAGS = @CPPFLAGS@ @DEFS@ @INCLUDES@ @TCL_INCLUDES@
TCL_DEFS = @TCL_DEFS@
SHLIB_CFLAGS = @SHLIB_CFLAGS@
CFLAGS_DEBUG = @CFLAGS_DEBUG@
CFLAGS_OPTIMIZE = @CFLAGS_OPTIMIZE@
CFLAGS_QUICHEEATERS = @CFLAGS_QUICHEEATERS@
TCL_CC = @TCL_CC@
SHLIB_LD = @SHLIB_LD@
+6
View File
@@ -14,6 +14,12 @@ clean distclean::
( cd $$subdir && $(MAKE) DIRPRFX=${DIRPRFX}$$subdir/ $@) || exit 1; \
done
test::
@for subdir in $(SUBDIR); do\
echo ===\> making $@ in ${DIRPRFX}$$subdir; \
( cd $$subdir && $(MAKE) DIRPRFX=${DIRPRFX}$$subdir/ $@) || exit 1; \
done
install::
@for subdir in $(SUBDIR); do\
echo ===\> making $@ in ${DIRPRFX}$$subdir; \
+1 -1
View File
@@ -11,7 +11,7 @@ clean::
distclean:: clean
install:: all
install:: all test
$(INSTALL) -d -o ${DSTUSR} -g ${DSTGRP} -m 775 ${INSTALLDIR}
$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 444 ${SHLIB_NAME} ${INSTALLDIR}
$(SILENT) $(TCLSH) ../pkg_mkindex.tcl ${INSTALLDIR}
Vendored
+2091 -1029
View File
File diff suppressed because it is too large Load Diff
+12 -1
View File
@@ -11,6 +11,12 @@ AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_LN_S
# Quiche eaters options.
if test x$GCC = xyes; then
CFLAGS_QUICHEEATERS='-W -Wall -pedantic'
fi
AC_SUBST(CFLAGS_QUICHEEATERS)
OD_PROG_MTREE
AC_SUBST(REPLACEMENT_PROGS)
@@ -40,7 +46,12 @@ INCLUDES="-I.. -I. $INCLUDES"
AC_FUNC_CLOSEDIR_VOID
AC_FUNC_FORK
AC_FUNC_STRERROR_R
AC_CHECK_FUNCS([bzero memset dup2 regcomp strdup strerror strtol fgetln lockf flock setmode])
AC_CHECK_FUNCS([bzero memset dup2 regcomp strdup strerror strtol fgetln lockf flock setmode strcasecmp strncasecmp])
# Check for md5 implementation
OD_LIB_MD5
# Check for X11 and paraphernalia
OD_CHECK_X11
# Check for md5 implementation
OD_LIB_MD5
+2
View File
@@ -8,6 +8,8 @@ all:
clean:
test:
distclean: clean
rm -f prefix.mtree ports.conf
+7
View File
@@ -7,5 +7,12 @@ portdbpath @localstatedir_expanded@/db/dports
# Set the directory in which to install ports
prefix @prefix_expanded@
# Type of storage to use for the port registry information, "flat" or "sqlite"
# NOTE: sqlite not yet supported.
portdbformat flat
# Type of installation to do for ports, "direct" or "image". See documentation.
portinstalltype image
# Directory containing the X11 installation.
x11prefix /usr/X11R6
+3 -1
View File
@@ -1,4 +1,4 @@
TCLPKG= darwinports1.0 port1.0 package1.0 pextlib1.0
TCLPKG= darwinports1.0 port1.0 package1.0 pextlib1.0 registry1.0
SUBDIR= ${TCLPKG} port programs
all::
@@ -6,4 +6,6 @@ all::
distclean::
rm -f config.h
test::
include ../Mk/dports.subdir.mk
+6
View File
@@ -80,6 +80,9 @@
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the `strcasecmp' function. */
#undef HAVE_STRCASECMP
/* Define to 1 if you have the `strdup' function. */
#undef HAVE_STRDUP
@@ -95,6 +98,9 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `strncasecmp' function. */
#undef HAVE_STRNCASECMP
/* Define to 1 if you have the `strtol' function. */
#undef HAVE_STRTOL
+2
View File
@@ -13,6 +13,8 @@ all::
clean::
test::
distclean:: clean
rm -f darwinports_autoconf.tcl;
+138 -199
View File
@@ -1,6 +1,7 @@
# darwinports.tcl
#
# Copyright (c) 2002 Apple Computer, Inc.
# Copyright (c) 2004 Paul Guyot, Darwinports Team.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -33,8 +34,8 @@ package require darwinports_index 1.0
namespace eval darwinports {
namespace export bootstrap_options portinterp_options open_dports
variable bootstrap_options "portdbpath libpath binpath master_site_local auto_path sources_conf prefix"
variable portinterp_options "portdbpath portpath auto_path prefix portsharepath registry.path"
variable bootstrap_options "portdbpath libpath auto_path sources_conf prefix portdbformat portinstalltype"
variable portinterp_options "portdbpath portpath auto_path prefix portsharepath registry.path registry.format registry.installtype"
variable open_dports {}
}
@@ -65,7 +66,7 @@ proc darwinports::ui_event {context message} {
}
proc dportinit {args} {
global auto_path env darwinports::portdbpath darwinports::bootstrap_options darwinports::portinterp_options darwinports::portconf darwinports::sources darwinports::sources_conf darwinports::portsharepath darwinports::registry.path darwinports::autoconf::dports_conf_path
global auto_path env darwinports::portdbpath darwinports::bootstrap_options darwinports::portinterp_options darwinports::portconf darwinports::sources darwinports::sources_conf darwinports::portsharepath darwinports::registry.path darwinports::autoconf::dports_conf_path darwinports::registry.format darwinports::registry.installtype
# first look at PORTSRC for testing/debugging
if {[llength [array names env PORTSRC]] > 0} {
@@ -142,7 +143,7 @@ proc dportinit {args} {
return -code error "$portdbpath is not a directory. Please create the directory $portdbpath and try again"
}
set registry.path [file join $portdbpath receipts]
set registry.path $portdbpath
if {![file isdirectory ${registry.path}]} {
if {![file exists ${registry.path}]} {
if {[catch {file mkdir ${registry.path}} result]} {
@@ -154,6 +155,23 @@ proc dportinit {args} {
return -code error "${darwinports::registry.path} is not a directory. Please create the directory $portdbpath and try again"
}
# Format for receipts, can currently be either "flat" or "sqlite"
if {[info exists portdbformat]} {
if { $portdbformat == "sqlite" } {
return -code error "SQLite is not yet supported for registry storage."
}
set registry.format receipt_${portdbformat}
} else {
set registry.format receipt_flat
}
# Installation type, whether to use port "images" or install "direct"
if {[info exists portinstalltype]} {
set registry.installtype $portinstalltype
} else {
set registry.installtype image
}
set portsharepath ${prefix}/share/darwinports
if {![file isdirectory $portsharepath]} {
return -code error "Data files directory '$portsharepath' must exist"
@@ -184,13 +202,23 @@ proc dportinit {args} {
# early, and after auto_path has been set. Or maybe Pextlib
# should ship with darwinports1.0 API?
package require Pextlib 1.0
package require registry 1.0
} else {
return -code error "Library directory '$libpath' must exist"
}
}
proc darwinports::worker_init {workername portpath options variations} {
global darwinports::portinterp_options auto_path
global darwinports::portinterp_options auto_path registry.installtype
# Tell the sub interpreter about all the Tcl packages we already
# know about so it won't glob for packages.
foreach pkgName [package names] {
foreach pkgVers [package versions $pkgName] {
set pkgLoadScript [package ifneeded $pkgName $pkgVers]
$workername eval "package ifneeded $pkgName $pkgVers {$pkgLoadScript}"
}
}
# Create package require abstraction procedure
$workername eval "proc PortSystem \{version\} \{ \n\
@@ -203,15 +231,19 @@ proc darwinports::worker_init {workername portpath options variations} {
# instantiate the UI call-back
$workername alias ui_event darwinports::ui_event $workername
# xxx: find a better home for this registry cruft--like six feet under.
$workername alias registry_new dportregistry::new $workername
$workername alias registry_store dportregistry::store
$workername alias registry_delete dportregistry::delete
$workername alias registry_exists dportregistry::exists
$workername alias registry_close dportregistry::close
$workername alias fileinfo_for_index dportregistry::fileinfo_for_index
$workername alias fileinfo_for_file dportregistry::fileinfo_for_file
$workername alias fileinfo_for_entry dportregistry::fileinfo_for_entry
# New Registry/Receipts stuff
$workername alias registry_new registry::new_entry
$workername alias registry_open registry::open_entry
$workername alias registry_write registry::write_entry
$workername alias registry_prop_store registry::property_store
$workername alias registry_prop_retr registry::property_retrieve
$workername alias registry_delete registry::delete_entry
$workername alias registry_exists registry::entry_exists
$workername alias registry_activate portimage::activate
$workername alias registry_deactivate portimage::deactivate
$workername alias registry_register_deps registry::register_dependencies
$workername alias registry_fileinfo_for_index registry::fileinfo_for_index
$workername alias registry_bulk_register_files registry::register_bulk_files
foreach opt $portinterp_options {
if {![info exists $opt]} {
@@ -231,6 +263,10 @@ proc darwinports::worker_init {workername portpath options variations} {
foreach {var val} $variations {
$workername eval set variations($var) $val
}
if { [info exists registry.installtype] } {
$workername eval set installtype ${registry.installtype}
}
}
proc darwinports::fetch_port {url} {
@@ -255,7 +291,6 @@ proc darwinports::fetch_port {url} {
if {[regexp {(.+).tgz} $fetchfile match portdir] != 1} {
return -code error "Can't decipher portdir from $fetchfile"
}
return [file join $fetchdir $portdir]
}
@@ -341,6 +376,48 @@ proc dportopen {porturl {options ""} {variations ""} {nocache ""}} {
return $dport
}
# Traverse a directory with ports, calling a function on the path of ports
# (at the second depth).
# I.e. the structure of dir shall be:
# category/port/
# with a Portfile file in category/port/
#
# func: function to call on every port directory (it is passed
# category/port/ as its parameter)
# root: the directory with all the categories directories.
proc dporttraverse {func {root .}} {
# Save the current directory
set pwd [pwd]
# Join the root.
set pathToRoot [file join $pwd $root]
# Go to root because some callers expects us to be there.
cd $pathToRoot
foreach category [readdir $root] {
set pathToCategory [file join $root $category]
if {[file isdirectory $pathToCategory]} {
# Iterate on port directories.
foreach port [readdir $pathToCategory] {
set pathToPort [file join $pathToCategory $port]
if {[file isdirectory $pathToPort] &&
[file exists [file join $pathToPort "Portfile"]]} {
# Call the function.
$func [file join $category $port]
# Restore the current directory because some
# functions changes it.
cd $pathToRoot
}
}
}
}
# Restore the current directory.
cd $pwd
}
### _dportsearchpath is private; subject to change without notice
proc _dportsearchpath {depregex search_path} {
@@ -363,7 +440,6 @@ proc _dportsearchpath {depregex search_path} {
}
}
}
return $found
}
@@ -454,8 +530,8 @@ proc _dportinstalled {dport} {
# Check for the presense of the port in the registry
set workername [ditem_key $dport workername]
set res [$workername eval registry_exists \${portname} \${portversion}]
if {$res != ""} {
ui_debug "Found Dependency: receipt: $res"
if {$res != 0} {
ui_debug "[ditem_key $dport provides] is installed"
return 1
} else {
return 0
@@ -473,8 +549,8 @@ proc _dportispresent {dport depspec} {
# Check for the presense of the port in the registry
set workername [ditem_key $dport workername]
set res [$workername eval registry_exists \${portname} \${portversion}]
if {$res != ""} {
ui_debug "Found Dependency: receipt: $res"
if {$res != 0} {
ui_debug "Found Dependency: receipt exists for [ditem_key $dport provides]"
return 1
} else {
# The receipt test failed, use one of the depspec regex mechanisms
@@ -509,7 +585,7 @@ proc _dportexec {target dport} {
# Execute the specified target of the given dport.
proc dportexec {dport target} {
global darwinports::portinterp_options
global darwinports::portinterp_options darwinports::registry.installtype
set workername [ditem_key $dport workername]
@@ -541,7 +617,13 @@ proc dportexec {dport target} {
dlist_delete dlist $dport
# install them
set result [dlist_eval $dlist _dportinstalled [list _dportexec "install"]]
# xxx: as with below, this is ugly. and deps need to be fixed to
# understand Port Images before this can get prettier
if { [string equal ${darwinports::registry.installtype} "image"] && [string equal $target "install"] } {
set result [dlist_eval $dlist _dportinstalled [list _dportexec "activate"]]
} else {
set result [dlist_eval $dlist _dportinstalled [list _dportexec "install"]]
}
if {$result != {}} {
set errstring "The following dependencies failed to build:"
@@ -551,11 +633,17 @@ proc dportexec {dport target} {
ui_error $errstring
return 1
}
# Close the dependencies, we're done installing them
foreach ditem $dlist {
dportclose $ditem
}
# Close the dependencies, we're done installing them.
foreach ditem $dlist {
dportclose $ditem
}
}
# If we're doing image installs, then we should activate after install
# xxx: This isn't pretty
if { [string equal ${darwinports::registry.installtype} "image"] && [string equal $target "install"] } {
set target activate
}
# Build this port with the specified target
@@ -594,7 +682,7 @@ proc dportsync {args} {
}
exec curl -L -s -S -o $indexfile $source/PortIndex
}
}
}
}
proc dportsearch {regexp} {
@@ -607,28 +695,28 @@ proc dportsearch {regexp} {
set res [darwinports::index::search $darwinports::portdbpath $source [array get attrs]]
eval lappend matches $res
} else {
if {[catch {set fd [open [darwinports::getindex $source] r]} result]} {
return -code error "Can't open index file for source $source. Have you synced your source indexes?"
}
while {[gets $fd line] >= 0} {
set name [lindex $line 0]
if {[regexp -- $regexp $name] == 1} {
gets $fd line
array set portinfo $line
if {[info exists portinfo(portarchive)]} {
lappend line porturl ${source}/$portinfo(portarchive)
} elseif {[info exists portinfo(portdir)]} {
lappend line porturl ${source}/$portinfo(portdir)
}
lappend matches $name
lappend matches $line
} else {
set len [lindex $line 1]
seek $fd $len current
}
}
close $fd
}
if {[catch {set fd [open [darwinports::getindex $source] r]} result]} {
return -code error "Can't open index file for source $source. Have you synced your source indexes?"
}
while {[gets $fd line] >= 0} {
set name [lindex $line 0]
if {[regexp -- $regexp $name] == 1} {
gets $fd line
array set portinfo $line
if {[info exists portinfo(portarchive)]} {
lappend line porturl ${source}/$portinfo(portarchive)
} elseif {[info exists portinfo(portdir)]} {
lappend line porturl ${source}/$portinfo(portdir)
}
lappend matches $name
lappend matches $line
} else {
set len [lindex $line 1]
seek $fd $len current
}
}
close $fd
}
}
return $matches
@@ -739,152 +827,3 @@ proc dportdepends {dport includeBuildDeps recurseDeps {accDeps {}}} {
return 0
}
# Snarfed from portregistry.tcl
# For now, just write stuff to a file for debugging.
namespace eval dportregistry {}
proc dportregistry::new {workername portname {portversion 1.0}} {
global _registry_name darwinports::registry.path
file mkdir ${darwinports::registry.path}
set _registry_name [file join ${darwinports::registry.path} $portname-$portversion]
system "rm -f ${_registry_name}.tmp"
set rhandle [open ${_registry_name}.tmp w 0644]
puts $rhandle "\# Format: var value ... {contents {filename uid gid mode size {md5}} ... }"
#interp share {} $rhandle $workername
return $rhandle
}
proc dportregistry::exists {portname {portversion 0}} {
global darwinports::registry.path
# regex match case
if {$portversion == 0} {
set x [glob -nocomplain [file join ${darwinports::registry.path} ${portname}-*]]
if {[string length $x]} {
set matchfile [lindex $x 0]
} else {
set matchfile ""
}
} else {
set matchfile [file join ${darwinports::registry.path} ${portname}-${portversion}]
}
# Might as well bail out early if no file to match
if {![string length $matchfile]} {
return ""
}
if {[file exists $matchfile]} {
return $matchfile
}
if {[file exists ${matchfile}.bz2]} {
return ${matchfile}.bz2
}
return ""
}
proc dportregistry::store {rhandle data} {
puts $rhandle $data
}
proc dportregistry::fetch {rhandle} {
return -1
}
proc dportregistry::traverse {func} {
return -1
}
proc dportregistry::close {rhandle} {
global _registry_name
global registry.nobzip
::close $rhandle
system "mv ${_registry_name}.tmp ${_registry_name}"
if {[file exists ${_registry_name}] && [file exists /usr/bin/bzip2] && ![info exists registry.nobzip]} {
system "/usr/bin/bzip2 -f ${_registry_name}"
}
}
proc dportregistry::delete {portname {portversion 0}} {
global darwinports::registry.path
# regex match case, as in exists
if {$portversion == 0} {
set x [glob -nocomplain [file join ${darwinports::registry.path} ${portname}-*]]
if {[string length $x]} {
exec rm -f [lindex $x 0]
}
} else {
# Remove the file (with or without .bz2 suffix)
set filename [file join ${darwinports::registry.path} ${portname}-${portversion}]
if { [file exists $filename] } {
exec rm -rf $filename
} elseif { [file exists ${filename}.bz2] } {
exec rm -rf ${filename}.bz2
}
}
}
proc dportregistry::fileinfo_for_file {fname} {
if {![catch {file stat $fname statvar}]} {
if {[file isfile $fname]} {
if {[catch {md5 file $fname} md5sum] == 0} {
# Create a line that matches md5(1)'s output
# for backwards compatibility
set line "MD5 ($fname) = $md5sum"
return [list $fname $statvar(uid) $statvar(gid) $statvar(mode) $statvar(size) $line]
}
} else {
return [list $fname $statvar(uid) $statvar(gid) $statvar(mode) $statvar(size) "MD5 ($fname) NONE"]
}
}
return {}
}
proc dportregistry::fileinfo_for_entry {rval dir entry} {
upvar $rval myrval
set path [file join $dir $entry]
lappend myrval [dportregistry::fileinfo_for_file $path]
return $myrval
}
proc dportregistry::fileinfo_for_index {flist} {
global prefix
set rval {}
foreach file $flist {
if {[string match /* $file]} {
set fname $file
set dir /
} else {
set fname [file join $prefix $file]
set dir $prefix
}
dportregistry::fileinfo_for_entry rval $dir $file
}
return $rval
}
proc dportregistry::listinstalled {args} {
global darwinports::registry.path
set receiptglob [glob -nocomplain ${darwinports::registry.path}/*]
if {$receiptglob == ""} {
puts "No ports installed."
} else {
puts "The following ports are installed:"
foreach receipt $receiptglob {
if {[file extension $receipt] == ".bz2"} {
puts "\t[file rootname [file tail $receipt]]"
} else {
puts "\t[file tail $receipt]"
}
}
}
}
+2
View File
@@ -11,6 +11,8 @@ clean::
distclean::
test::
install::
$(INSTALL) -d -o ${DSTUSR} -g ${DSTGRP} -m 775 ${DESTDIR}${datadir}/darwinports
$(INSTALL) -d -o ${DSTUSR} -g ${DSTGRP} -m 775 ${DESTDIR}${datadir}/darwinports/Tcl
+5 -1
View File
@@ -1,8 +1,12 @@
OBJS= Pextlib.o strsed.o fgetln.o md5cmd.o setmode.o xinstall.o \
find.o vercomp.o
find.o strcasecmp.o vercomp.o filemap.o
SHLIB_NAME= Pextlib${SHLIB_SUFFIX}
INSTALLDIR= ${DESTDIR}${datadir}/darwinports/Tcl/pextlib1.0
include ../../Mk/dports.autoconf.mk
include ../../Mk/dports.tea.mk
.PHONY: test
test:: ${SHLIB_NAME}
${TCLSH} tests/filemap.tcl ${SHLIB_NAME}
+29 -1
View File
@@ -1,7 +1,9 @@
/*
* Pextlib.c
* $Id: Pextlib.c,v 1.65 2004/07/01 17:21:12 wbb4 Exp $
*
* Copyright (c) 2002 - 2003 Apple Computer, Inc.
* Copyright (c) 2004 Paul Guyot, Darwinports Team.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -93,6 +95,7 @@
#include "md5cmd.h"
#include "find.h"
#include "filemap.h"
#include "xinstall.h"
#include "vercomp.h"
@@ -187,6 +190,7 @@ struct linebuf {
int SystemCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
{
#pragma unused (clientData)
char *buf;
struct linebuf circbuf[CBUFSIZ];
size_t linelen;
@@ -349,6 +353,7 @@ int SystemCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONS
int FlockCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
{
#pragma unused (clientData)
static const char errorstr[] = "use one of \"-shared\", \"-exclusive\", or \"-unlock\", and optionally \"-noblock\"";
int operation = 0, fd, i, ret;
int errnoval = 0;
@@ -484,8 +489,16 @@ int FlockCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST
return TCL_OK;
}
/**
*
* Return the list of elements in a directory.
* Since 1.60.4.2, the list doesn't include . and ..
*
* Synopsis: readdir directory
*/
int ReaddirCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
{
#pragma unused (clientData)
DIR *dirp;
struct dirent *dp;
Tcl_Obj *tcl_result;
@@ -504,7 +517,13 @@ int ReaddirCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CON
}
tcl_result = Tcl_NewListObj(0, NULL);
while ((dp = readdir(dirp))) {
Tcl_ListObjAppendElement(interp, tcl_result, Tcl_NewStringObj(dp->d_name, -1));
/* Skip . and .. */
if ((dp->d_name[0] != '.') ||
((dp->d_name[1] != 0) /* "." */
&&
((dp->d_name[1] != '.') || (dp->d_name[2] != 0)))) /* ".." */ {
Tcl_ListObjAppendElement(interp, tcl_result, Tcl_NewStringObj(dp->d_name, -1));
}
}
closedir(dirp);
Tcl_SetObjResult(interp, tcl_result);
@@ -514,6 +533,7 @@ int ReaddirCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CON
int StrsedCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
{
#pragma unused (clientData)
char *pattern, *string, *res;
int range[2];
extern char *strsed(char *str, char *pat, int *range);
@@ -539,6 +559,7 @@ int StrsedCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONS
int MktempCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
{
#pragma unused (clientData)
char *template, *sp;
Tcl_Obj *tcl_result;
@@ -560,11 +581,13 @@ int MktempCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONS
tcl_result = Tcl_NewStringObj(sp, -1);
Tcl_SetObjResult(interp, tcl_result);
free(sp);
free(template);
return TCL_OK;
}
int MkstempCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
{
#pragma unused (clientData)
Tcl_Channel channel;
char *template, *channelname;
int fd;
@@ -594,6 +617,7 @@ int MkstempCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CON
int ExistsuserCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
{
#pragma unused (clientData)
Tcl_Obj *tcl_result;
struct passwd *pwent;
char *user;
@@ -621,6 +645,7 @@ int ExistsuserCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *
int ExistsgroupCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
{
#pragma unused (clientData)
Tcl_Obj *tcl_result;
struct group *grent;
char *group;
@@ -648,6 +673,7 @@ int ExistsgroupCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj
int NextuidCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
{
#pragma unused (clientData, objc, objv)
Tcl_Obj *tcl_result;
struct passwd *pwent;
int max;
@@ -665,6 +691,7 @@ int NextuidCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CON
int NextgidCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
{
#pragma unused (clientData, objc, objv)
Tcl_Obj *tcl_result;
struct group *grent;
int max;
@@ -697,6 +724,7 @@ int Pextlib_Init(Tcl_Interp *interp)
Tcl_CreateObjCommand(interp, "md5", MD5Cmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "xinstall", InstallCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "find", FindCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "filemap", FilemapCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "rpm-vercomp", RPMVercompCmd, NULL, NULL);
if(Tcl_PkgProvide(interp, "Pextlib", "1.0") != TCL_OK)
return TCL_ERROR;
+2
View File
@@ -38,6 +38,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
@@ -62,6 +63,7 @@ static int do_find(Tcl_Interp *interp, int depth, char *dir, char *match, char *
int
FindCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
{
#pragma unused (clientData)
char *startdir;
char *match, *action;
char *def_match = "expr 1";
+1
View File
@@ -116,6 +116,7 @@ char *MD5Data(const unsigned char *data, unsigned int len, char *buf)
int MD5Cmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
{
#pragma unused (clientData)
char *file, *action;
char buf[33];
const char usage_message[] = "Usage: md5 file ?file?";
+17 -11
View File
@@ -211,6 +211,20 @@ static struct {
#define EMPTY_REGISTER ((regoff_t) 0)
#endif
/* ------------------------------------------------------------------------- **
* Prototypes
* ------------------------------------------------------------------------- */
static char *mem();
static void mem_init();
static void mem_free();
static char *build_map();
static char nextch();
static void mem_save();
static int mem_find();
/* ------------------------------------------------------------------------- **
* strsed
* ------------------------------------------------------------------------- */
char *
strsed(string, pattern, range)
register char *string;
@@ -232,9 +246,6 @@ int *range;
#endif
char *backslash_eliminate();
static char *mem();
static void mem_init();
static void mem_free();
char *from;
char *new_str;
@@ -678,7 +689,6 @@ int *range;
*/
if (*(tmp + 2) == '{'){
/* A transliteration table. Build the map. */
static char *build_map();
if (!(tmp = build_map(tmp + 2, map))){
RETURN(0);
}
@@ -799,7 +809,6 @@ int who;
*
*/
static char *mem();
char *new_str;
int extra = 100;
int seenlb = 0;
@@ -1099,14 +1108,14 @@ char *map;
char *str;
char *tmp;
char c;
static char *mem();
static char nextch();
int i = 0;
int range_count = 0;
int seenbs = 0;
static char *last = 0;
static int last_len;
out = 0;
if (!s){
return 0;
}
@@ -1212,7 +1221,7 @@ char *map;
*/
while ((c = nextch((char *)0, 0))){
map[c] = nextch((char *)0, 1);
map[(int) c] = nextch((char *)0, 1);
}
return tmp;
@@ -1354,8 +1363,6 @@ int size;
* not too clear. Seems to works fine though.
*/
static void mem_save();
if (who < 0 || who >= MEM_SLOTS){
return 0;
}
@@ -1391,7 +1398,6 @@ int size;
mem_save(who);
}
else{
static int mem_find();
int x = mem_find(size);
if (x != -1){
mem_slots[who].s = mem_slots[x].s;
+169
View File
@@ -0,0 +1,169 @@
# Test file for Pextlib's filemap.
# Requires r/w access to /tmp/
# Syntax:
# tclsh filemap.tcl <Pextlib name>
proc main {pextlibname} {
load $pextlibname
file delete -force "/tmp/darwinports-pextlib-testmap"
filemap open testmap "/tmp/darwinports-pextlib-testmap"
if {[filemap exists testmap "/foo/bar"]} {
puts {[filemap exists testmap "/foo/bar"]}
exit 1
}
filemap set testmap "/foo/bar" "foobar"
if {![filemap exists testmap "/foo/bar"]} {
puts {![filemap exists testmap "/foo/bar"]}
exit 1
}
if {[filemap get testmap "/foo/bar"] != "foobar"} {
puts {[filemap get testmap "/foo/bar"] != "foobar"}
exit 1
}
filemap unset testmap "/foo/bar"
if {[filemap exists testmap "/foo/bar"]} {
puts {[filemap exists testmap "/foo/bar"] (2)}
exit 1
}
filemap set testmap "/foo/bar" "foobar-1"
filemap set testmap "/foo/foo" "foobar-2"
filemap set testmap "/bar/foo" "foobar-3"
filemap set testmap "/foobar" "foobar-4"
if {[filemap get testmap "/foo/foo"] != "foobar-2"} {
puts {[filemap get testmap "/foo/foo"] != "foobar-2"}
puts [filemap get testmap "/foo/foo"]
exit 1
}
filemap save testmap
filemap set testmap "/foo/bar-1" "somevalue"
filemap set testmap "/foo/bar-2" "somevalue"
filemap set testmap "/bar/bar-3" "somevalue"
set theList [filemap list testmap "somevalue"]
if {[llength $theList] != 3} {
puts {[llength $theList] != 3}
exit 1
}
if {[lindex $theList 0] != "/bar/bar-3"} {
puts {[lindex $theList 2] != "/bar/bar-3"}
exit 1
}
if {[lindex $theList 1] != "/foo/bar-1"} {
puts {[lindex $theList 0] != "/foo/bar-1"}
exit 1
}
if {[lindex $theList 2] != "/foo/bar-2"} {
puts {[lindex $theList 1] != "/foo/bar-2"}
exit 1
}
filemap set testmap "/a/b/c/d/e/f/g/foo.h" "foo"
filemap set testmap "/a/b/c/d/e/f/g/foo/bar" "foo"
# add 1000 subnodes.
for {set index 0} {$index < 1000} {incr index} {
filemap set testmap "/many/foo-$index" "foo-$index"
}
# add another 1000 subnodes, lexicographically before.
for {set index 0} {$index < 1000} {incr index} {
filemap set testmap "/many/bar-$index" "foo-$index"
}
# save again
filemap save testmap
# add some value that won't be saved.
filemap set testmap "/unsaved" "unsaved"
# revert the map.
filemap revert testmap
filemap close testmap
filemap open testmap2 "/tmp/darwinports-pextlib-testmap"
if {[filemap exists testmap2 "/foo/foobar"]} {
puts {[filemap exists testmap2 "/foo/foobar"]}
exit 1
}
if {![filemap exists testmap2 "/foo/bar"]} {
puts {![filemap exists testmap2 "/foo/bar"]}
exit 1
}
if {[filemap get testmap2 "/foo/bar"] != "foobar-1"} {
puts {[filemap get testmap2 "/foo/bar"] != "foobar-1"}
puts [filemap get testmap2 "/foo/bar"]
exit 1
}
if {[filemap get testmap2 "/foo/foo"] != "foobar-2"} {
puts {[filemap get testmap2 "/foo/foo"] != "foobar-2"}
puts [filemap get testmap2 "/foo/foo"]
exit 1
}
if {[filemap get testmap2 "/bar/foo"] != "foobar-3"} {
puts {[filemap get testmap2 "/bar/foo"] != "foobar-3"}
puts [filemap get testmap2 "/bar/foo"]
exit 1
}
if {[filemap get testmap2 "/foobar"] != "foobar-4"} {
puts {[filemap get testmap2 "/foobar"] != "foobar-4"}
puts [filemap get testmap2 "/foobar"]
exit 1
}
if {[filemap get testmap2 "/bar/bar-3"] != "somevalue"} {
puts {[filemap get testmap2 "/bar/bar-3"] != "somevalue"}
puts [filemap get testmap2 "/bar/bar-3"]
exit 1
}
set theList [filemap list testmap2 "somevalue"]
if {[llength $theList] != 3} {
puts {[llength $theList] != 3}
exit 1
}
if {[lindex $theList 0] != "/bar/bar-3"} {
puts {[lindex $theList 2] != "/bar/bar-3"}
exit 1
}
if {[lindex $theList 1] != "/foo/bar-1"} {
puts {[lindex $theList 0] != "/foo/bar-1"}
exit 1
}
if {[lindex $theList 2] != "/foo/bar-2"} {
puts {[lindex $theList 1] != "/foo/bar-2"}
exit 1
}
# check the 1000 subnodes.
for {set index 0} {$index < 1000} {incr index} {
if {[filemap get testmap2 "/many/foo-$index"] != "foo-$index"} {
puts {[filemap get testmap2 "/many/foo-$index"] != "foo-$index"}
puts $index
puts [filemap get testmap2 "/many/foo-$index"]
exit 1
}
if {[filemap get testmap2 "/many/bar-$index"] != "foo-$index"} {
puts {[filemap get testmap2 "/many/bar-$index"] != "foo-$index"}
puts $index
puts [filemap get testmap2 "/many/bar-$index"]
exit 1
}
}
if {[filemap exists testmap2 "/unsaved"]} {
puts {[filemap exists testmap2 "/unsaved"]}
exit 1
}
filemap close testmap2
file delete "/tmp/darwinports-pextlib-testmap"
}
main $argv
+1
View File
@@ -161,6 +161,7 @@ static int rpm_vercomp (const char *versionA, const char *versionB) {
int RPMVercompCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
{
#pragma unused (clientData)
Tcl_Obj *tcl_result;
const char *versionA, *versionB;
int rval;

Some files were not shown because too many files have changed in this diff Show More