Date: Sun, 06 Nov 2005 07:34:00 -0800 (PST) From: "Michael C. Shultz" <ringworm01@gmail.com> To: FreeBSD-gnats-submit@FreeBSD.org Subject: ports/88551: [PORT AUTHOR UPDATE] update sysutils/portmanager to 0.3.2_1 Message-ID: <20051106153400.41924130C22@ringworm.mechee.com> Resent-Message-ID: <200511061550.jA6FoIlH083130@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 88551 >Category: ports >Synopsis: [PORT AUTHOR UPDATE] update sysutils/portmanager to 0.3.2_1 >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Sun Nov 06 15:50:18 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Michael C. Shultz >Release: FreeBSD 5.4-STABLE i386 >Organization: >Environment: System: FreeBSD ringworm.mechee.com 5.4-STABLE FreeBSD 5.4-STABLE #0: Fri Nov 4 06:35:37 PST 2005 root@ringworm.mechee.com:/usr5/obj/usr5/src/sys/RINGWORM5 i386 >Description: update sysutils/portmanager to 0.3.2_1 adds ability to recalculate a port's dependencies if they are changed during an update by the dreaded blue screen thingy >How-To-Repeat: rm -r /usr/db/ports/* then run portmanager -u, result isn't pretty so don't really do this until after this patch is applied >Fix: --- portmanager-0.3.2_1.diff begins here --- diff -ruN portmanager/Makefile portmanager-0.3.2_1/Makefile --- portmanager/Makefile Sat Nov 5 05:49:10 2005 +++ portmanager-0.3.2_1/Makefile Sun Nov 6 06:15:42 2005 @@ -7,6 +7,7 @@ PORTNAME= portmanager PORTVERSION= 0.3.2 +PORTREVISION= 1 CATEGORIES= sysutils MASTER_SITES= http://portmanager.sunsite.dk/distfiles/ \ ${MASTER_SITE_SOURCEFORGE} @@ -45,11 +46,17 @@ CONFIGURE_ARGS+= --with-debug=yes .endif -post-patch: +# +# note to comitter: this is post-configure for a specific reason +# please do not change to post-patch +# also externVars.h is intentional, please do not change to +# externVars.h.in, thank you -Mike Shultz +# +post-configure: .if ${PORTREVISION} != 0 @${REINPLACE_CMD} -e \ 's|PACKAGE_VERSION "${PORTVERSION}"|PACKAGE_VERSION "${PORTVERSION}_${PORTREVISION}"|g' \ - ${WRKSRC}/externVars.h.in + ${WRKSRC}/externVars.h .endif post-install: diff -ruN portmanager/files/patch-0.3.2_1 portmanager-0.3.2_1/files/patch-0.3.2_1 --- portmanager/files/patch-0.3.2_1 Wed Dec 31 16:00:00 1969 +++ portmanager-0.3.2_1/files/patch-0.3.2_1 Sun Nov 6 06:15:42 2005 @@ -0,0 +1,1569 @@ +diff -ruN ../0.3.2/libMG/src/MGrFileSize.c ./libMG/src/MGrFileSize.c +--- ../0.3.2/libMG/src/MGrFileSize.c Fri Nov 4 06:39:26 2005 ++++ ./libMG/src/MGrFileSize.c Sun Nov 6 05:43:09 2005 +@@ -37,8 +37,11 @@ + errorCode = stat( fileName, &status); + if( errorCode == -1 ) + { ++/* + fprintf( stderr, "%s error: stat of %s returned an error\n", id, fileName ); + perror( "system message" ); ++*/ ++ + return( 0 ); + } + fileSize = status.st_size; +diff -ruN ../0.3.2/libMG/src/MGrFileTime.c ./libMG/src/MGrFileTime.c +--- ../0.3.2/libMG/src/MGrFileTime.c Fri Nov 4 06:39:26 2005 ++++ ./libMG/src/MGrFileTime.c Sun Nov 6 05:45:02 2005 +@@ -24,7 +24,7 @@ + + unsigned long int MGrFileTime( char* fileName ) + { +- char id[] = "MGrFileSize"; ++ char id[] = "MGrFileTime"; + unsigned long int fileTime = 0; + signed int errorCode = 0; + struct stat status; +@@ -32,8 +32,10 @@ + errorCode = stat( fileName, &status); + if( errorCode == -1 ) + { ++/* + fprintf( stderr, "%s error: stat of %s returned an error\n", id, fileName ); + perror( "system message" ); ++*/ + return( 0 ); + } + fileTime = status.st_mtime; +diff -ruN ../0.3.2/libMGPM/src/MGPMrCommandLine.c ./libMGPM/src/MGPMrCommandLine.c +--- ../0.3.2/libMGPM/src/MGPMrCommandLine.c Fri Nov 4 08:53:17 2005 ++++ ./libMGPM/src/MGPMrCommandLine.c Sat Nov 5 20:12:57 2005 +@@ -54,14 +54,15 @@ + /* + * set default values here + */ +- property.autoConflicts = 0; /* 1 = yes to all */ +- property.autoMoved = 0; /* if 1 then remove moved ports is Y */ +- property.backUp = 0; /* 0 = no packages 1 = build backup packages */ +- property.forced = 0; +- property.interactive = 0; +- property.log = 0; +- property.pmMode = 0; /* 0 = multiple port updates/1 = single */ +- property.resume = 0; /* 1 = portmanager updated itself, don't rebuild databases in -u -f mode */ ++ property.autoConflicts = 0; /* 1 = yes to all */ ++ property.autoMoved = 0; /* if 1 then remove moved ports is Y */ ++ property.backUp = 0; /* 0 = no packages 1 = build backup packages */ ++ property.forced = 0; ++ property.interactive = 0; ++ property.log = 0; ++ property.optionsChanged = 0; /* set by MGPMrUpdate for example to indicate a ports's options just changed */ ++ property.pmMode = 0; /* 0 = multiple port updates/1 = single */ ++ property.resume = 0; /* 1 = portmanager updated itself, don't rebuild databases in -u -f mode */ + + /* + * Make /usr/ports/packages of it is missing +@@ -327,6 +328,8 @@ + if( dirStream == 0 ) /* bad dir */ + { + fprintf( stderr, "%s %s error: %s is not a valid port directory\n", id, PACKAGE_VERSION, path ); ++ fprintf( stdout, "%s %s info:either you have used an invalid command line switch as the first option or you are trying to update a non existent port path, see man portmanager(1) \n", ++ id, PACKAGE_VERSION ); + free( path ); + return( 1 ); + } +@@ -345,6 +348,8 @@ + if( ( errorCode = MGPMrController( property, path ) ) ) + { + fprintf( stdout, "%s %s error: %s returned errorCode %d\n", id, PACKAGE_VERSION, "MGPMrControler", errorCode ); ++ fprintf( stdout, "%s %s info:either you have used an invalid command line switch as the first option or you are trying to update a non existent port path, see man portmanager(1) \n", ++ id, PACKAGE_VERSION ); + free( path ); + return( 1 ); + } +diff -ruN ../0.3.2/libMGPM/src/MGPMrSinglePortCreateStatusDb.c ./libMGPM/src/MGPMrSinglePortCreateStatusDb.c +--- ../0.3.2/libMGPM/src/MGPMrSinglePortCreateStatusDb.c Fri Nov 4 21:46:56 2005 ++++ ./libMGPM/src/MGPMrSinglePortCreateStatusDb.c Sat Nov 5 21:12:54 2005 +@@ -37,7 +37,8 @@ + + int MGPMrSinglePortCreateStatusDb( structProperty* property, char* portDir ) + { +- FILE* dependencyDbStream = NULL; ++ FILE* dependencyDbStream = NULL; ++ char exact[] = "exact"; + char id[] = "MGPMrSinglePortCreateStatusDb"; + char* availablePortDir = NULL; + char* availablePortName = NULL; +@@ -69,34 +70,37 @@ + while( fflush( stdout ) ); + strcpy( availablePortDir, portDir ); + +- property->availablePortsDb = MGdbCreate( +- property->availablePortsDbFileName, +- property->fieldAvailablePortsDbPortName, +- property->fieldAvailablePortsDbPortDir, +- property->fieldAvailablePortsDbFlag, +- NULL); +- +- dependencyDbStream = fopen( property->availableDependenciesDbFileName, "w" ); +- if( dependencyDbStream == 0 ) ++ if( property->optionsChanged == 0 ) /* set by MGPMrUpdate for example to indicate a ports's options just changed */ + { +- fprintf( stdout, "%s %s error: could not open %s\n", id, PACKAGE_VERSION, property->availableDependenciesDbFileName ); +- perror( "system message" ); +- return( 1 ); +- } ++ property->availablePortsDb = MGdbCreate( ++ property->availablePortsDbFileName, ++ property->fieldAvailablePortsDbPortName, ++ property->fieldAvailablePortsDbPortDir, ++ property->fieldAvailablePortsDbFlag, ++ NULL); + +- /* +- * creates dependencyDb with header record, same as MGdbCreate. In this case records will be added by +- * fprint'ing to dependencyDbStream instead of using MGdbAdd because speed is important here so we don't +- * want a dependencyDb object yet. +- */ +- fprintf( dependencyDbStream, "%s%c%s%c%s%c%s%c%s%c%c", "fieldAvailableDependenciesDbPortDir", 0, "fieldAvailableDependenciesDbPortName", 0, +- "fieldAvailableDependenciesDbDependencyDir", 0, "fieldAvailableDependenciesDbDependencyName", 0, +- "fieldAvailableDependenciesDbDependType", 0, LINEFEED ); +- while( fflush( stdout ) ); +- fclose( dependencyDbStream ); ++ dependencyDbStream = fopen( property->availableDependenciesDbFileName, "w" ); ++ if( dependencyDbStream == 0 ) ++ { ++ fprintf( stdout, "%s %s error: could not open %s\n", id, PACKAGE_VERSION, property->availableDependenciesDbFileName ); ++ perror( "system message" ); ++ return( 1 ); ++ } + +- property->availableDependenciesDb = MGdbOpen( property->availableDependenciesDbFileName ); +- property->configDb = MGdbOpen( property->configDbFileName ); ++ /* ++ * creates dependencyDb with header record, same as MGdbCreate. In this case records will be added by ++ * fprint'ing to dependencyDbStream instead of using MGdbAdd because speed is important here so we don't ++ * want a dependencyDb object yet. ++ */ ++ fprintf( dependencyDbStream, "%s%c%s%c%s%c%s%c%s%c%c", "fieldAvailableDependenciesDbPortDir", 0, "fieldAvailableDependenciesDbPortName", 0, ++ "fieldAvailableDependenciesDbDependencyDir", 0, "fieldAvailableDependenciesDbDependencyName", 0, ++ "fieldAvailableDependenciesDbDependType", 0, LINEFEED ); ++ while( fflush( stdout ) ); ++ fclose( dependencyDbStream ); ++ ++ property->availableDependenciesDb = MGdbOpen( property->availableDependenciesDbFileName ); ++ property->configDb = MGdbOpen( property->configDbFileName ); ++ } + + if( ( errorCode = rGetPortName( property, availablePortDir, availablePortName ) ) ) + { +@@ -104,7 +108,20 @@ + return( 1 ); + } + +- MGdbAdd( property->availablePortsDb, availablePortName, availablePortDir, "0", NULL); ++ MGdbGoTop( property->availablePortsDb ); ++ if( MGdbSeek( property->availablePortsDb, ++ property->fieldAvailablePortsDbPortDir, ++ availablePortDir, ++ property->fieldAvailablePortsDbPortDir, ++ exact ) ) ++ { ++ } ++ else ++ { ++ MGdbAdd( property->availablePortsDb, availablePortName, availablePortDir, "0", NULL); ++ ++ } ++ + if( ( errorCode = rFillDependencies( property, availablePortName, availablePortDir, counterPtr ) ) ) + { + fprintf( stdout, "%s %s error: %s returned errorCode %d\n", id, PACKAGE_VERSION, "rFillDependencies", errorCode ); +@@ -129,9 +146,12 @@ + } + idx++; + } +- MGdbDestroy( property->availablePortsDb ); +- MGdbDestroy( property->availableDependenciesDb ); +- MGdbDestroy( property->configDb ); ++ if( property->optionsChanged == 0 ) /* set by MGPMrUpdate for example to indicate a ports's options just changed */ ++ { ++ MGdbDestroy( property->availablePortsDb ); ++ MGdbDestroy( property->availableDependenciesDb ); ++ MGdbDestroy( property->configDb ); ++ } + free( availablePortDir ); + free( availablePortName ); + return( 0 ); +@@ -364,21 +384,38 @@ + /* + * add dependency to availableDependenciesDb may contain dupes + */ +- fprintf( dependencyDbStream, "%s%c%s%c%s%c%s%c%s%c%c", availablePortDir, 0, availablePortName, 0, dependencyPortDir, +- 0, dependencyPortName, 0, dependType, 0, LINEFEED ); +- MGdbGoTop( property->configDb ); +- optionsPtr = MGdbSeek( property->configDb, property->fieldConfigDbKey, dependencyPortDir, property->fieldConfigDbValue, exact ); +-/* +- if( optionsPtr ) ++ if( property->optionsChanged ) + { +- fprintf( stdout, "\t%s %s %s\n", dependencyPortName, dependencyPortDir, optionsPtr ); ++ MGdbAdd( property->availableDependenciesDb, ++ availablePortDir, ++ availablePortName, ++ dependencyPortDir, ++ dependencyPortName, ++ dependType, ++ NULL ); ++ ++ MGdbGoTop( property->configDb ); ++ optionsPtr = MGdbSeek( property->configDb, ++ property->fieldConfigDbKey, ++ dependencyPortDir, ++ property->fieldConfigDbValue, ++ exact ); ++ if( optionsPtr ) ++ { ++ fprintf( stdout, "\t%s %s %s\n", dependencyPortName, dependencyPortDir, optionsPtr ); ++ } ++ else ++ { ++ fprintf( stdout, "\t%s %s\n", dependencyPortName, dependencyPortDir ); ++ } ++ while( fflush( stdout ) ); ++ + } + else + { +- fprintf( stdout, "\t%s %s\n", dependencyPortName, dependencyPortDir ); ++ fprintf( dependencyDbStream, "%s%c%s%c%s%c%s%c%s%c%c", availablePortDir, 0, availablePortName, 0, dependencyPortDir, ++ 0, dependencyPortName, 0, dependType, 0, LINEFEED ); + } +- while( fflush( stdout ) ); +-*/ + /* + * if dependency not in availablePortsDb add it + */ +diff -ruN ../0.3.2/libMGPM/src/MGPMrSinglePortStatus.c ./libMGPM/src/MGPMrSinglePortStatus.c +--- ../0.3.2/libMGPM/src/MGPMrSinglePortStatus.c Fri Nov 4 13:02:23 2005 ++++ ./libMGPM/src/MGPMrSinglePortStatus.c Sat Nov 5 09:07:12 2005 +@@ -203,6 +203,7 @@ + */ + else + { ++ counterPtr[0]++; + strcpy( installedPortsDbPortDir, availablePortsDbPortDirPtr ); + MGdbGoTop( property->installedPortsDb ); + +diff -ruN ../0.3.2/libMGPM/src/MGPMrUpdate.c ./libMGPM/src/MGPMrUpdate.c +--- ../0.3.2/libMGPM/src/MGPMrUpdate.c Fri Nov 4 08:47:41 2005 ++++ ./libMGPM/src/MGPMrUpdate.c Sun Nov 6 05:17:31 2005 +@@ -31,33 +31,54 @@ + #define OK 0 + #include <libMGPM.h> + ++typedef struct ++{ ++ char* afterOptionsFileSize; ++ char* afterOptionsFileTime; ++ char* beforeOptionsFileSize; ++ char* beforeOptionsFileTime; ++ char* buffer; ++ char* command; ++ char* commandRestart; ++ char* newPortDir; ++ char* newPortName; ++ char* optionsCheck; ++ char* optionsDir; ++ char* workDir; ++} structLocalProperty; ++ + int rCleanDir( char* portDir, char* workDir ); +-int rCleanUp( structProperty* property, char* buffer, char* command, char* newPortDir, char* newPortName, char* workDir ); ++int rCleanUp( structProperty* property, structLocalProperty* localProperty ); + int rPortBrokeCheck( structProperty* property, char* options, char* oldPortDir, char* oldPortName, char* brokeCheckType ); + int MGPMrUpdate( structProperty* property, char* oldPortDir, char* oldPortName ) + { ++ FILE* fileStream = NULL; + FILE* pHandle = NULL; ++ char BROKEN[] = "BROKEN"; ++ char FORBIDDEN[] = "FORBIDDEN"; ++ char IGNORE[] = "IGNORE"; ++ char backUp[] = "--back-up"; ++ char bu[] = "-bu"; + char exact[] = "exact"; + char id[] = "MGPMrUpdate"; ++ char ip[] = "-ip"; ++ char l[] = "-l"; ++ char log[] = "--log"; + char strike[] = "0"; ++ char y[] = "-y"; ++ char yes[] = "--yes"; + char* availableDependenciesDbDependencyDirPtr = NULL; + char* availableDependenciesDbDependencyNamePtr = NULL; + char* availablePortsFlagPtr = NULL; +- char* buffer = NULL; + char* bufferBase = NULL; +- char* command = NULL; +- char* commandRestart = NULL; + char* dependencyDbDependencyPortDirPtr = NULL; + char* dependencyDbDependencyPortNamePtr = NULL; + char* installedPortsDbPortNamePtr = NULL; + char* ipPtr = NULL; +- char* newPortDir = NULL; +- char* newPortName = NULL; + char* oldPortDirPtr = NULL; + char* options = NULL; + char* stinker = NULL; + char* strikePtr = NULL; +- char* workDir = NULL; + int availableDependenciesDbIDX = 0; + int availableDependenciesDbQTY = 0; + int availablePortsDbIDX = 0; +@@ -69,49 +90,98 @@ + int installedPortsDbIDX = 0; + int installedPortsDbQTY = 0; + int kkey = 1; +- +- buffer = (char*)calloc( bufferSize, 1 ); +- command = (char*)calloc( bufferSize, 1 ); +- commandRestart = (char*)calloc( bufferSize, 1 ); +- newPortDir = (char*)calloc( 255, 1 ); +- newPortName = (char*)calloc( 255, 1 ); +- workDir = (char*)calloc( bufferSize, 1 ); +- +- property->commandLineDb = MGdbOpen( property->commandLineDbFileName ); +- property->configDb = MGdbOpen( property->configDbFileName ); +- property->ignoreDb = MGdbOpen( property->ignoreDbFileName ); +- property->installedPortsDb = MGdbOpen( property->installedPortsDbFileName ); +- property->strikesDb = MGdbOpen( property->strikesDbFileName ); +- +- if( property->pmMode || property->forced ) +- { +- property->availablePortsDb = MGdbOpen( property->availablePortsDbFileName ); +- property->availableDependenciesDb = MGdbOpen( property->availableDependenciesDbFileName ); +- } +- else ++ ++ structLocalProperty localProperty; ++ ++ property->optionsChanged = 0; ++ ++ localProperty.afterOptionsFileSize = (char*)calloc( 511, 1 ); ++ localProperty.afterOptionsFileTime = (char*)calloc( 511, 1 ); ++ localProperty.beforeOptionsFileSize = (char*)calloc( 511, 1 ); ++ localProperty.beforeOptionsFileTime = (char*)calloc( 511, 1 ); ++ localProperty.buffer = (char*)calloc( bufferSize, 1 ); ++ localProperty.command = (char*)calloc( bufferSize, 1 ); ++ localProperty.commandRestart = (char*)calloc( bufferSize, 1 ); ++ localProperty.newPortDir = (char*)calloc( 511, 1 ); ++ localProperty.newPortName = (char*)calloc( 511, 1 ); ++ localProperty.optionsCheck = (char*)calloc( 511, 1 ); ++ localProperty.optionsDir = (char*)calloc( 511, 1 ); ++ localProperty.workDir = (char*)calloc( 511, 1 ); ++ ++ property->availableDependenciesDb = MGdbOpen( property->availableDependenciesDbFileName ); ++ property->availablePortsDb = MGdbOpen( property->availablePortsDbFileName ); ++ property->commandLineDb = MGdbOpen( property->commandLineDbFileName ); ++ property->configDb = MGdbOpen( property->configDbFileName ); ++ property->dependencyPortsDb = MGdbOpen( property->dependencyPortsDbFileName ); ++ property->ignoreDb = MGdbOpen( property->ignoreDbFileName ); ++ property->installedPortsDb = MGdbOpen( property->installedPortsDbFileName ); ++ property->strikesDb = MGdbOpen( property->strikesDbFileName ); ++ ++ /* ++ * store work directoy base ++ */ ++ strcpy( localProperty.workDir, "cd " ); ++ strcat( localProperty.workDir, PORTSDIR ); ++ strcat( localProperty.workDir, oldPortDir ); ++ strcat( localProperty.workDir, "; make -V WRKDIRPREFIX" ); ++ localProperty.buffer[0] = 0; ++ pHandle = popen( localProperty.workDir, "r" ); ++ fread( localProperty.buffer, 255, 1, pHandle ); ++ pclose( pHandle ); ++ idx = 0; ++ while( idx < 255 ) + { +- property->dependencyPortsDb = MGdbOpen( property->dependencyPortsDbFileName ); ++ if( localProperty.buffer[idx] == LINEFEED || localProperty.buffer[idx] == TAB || localProperty.buffer[idx] == SPACE ) ++ { ++ localProperty.buffer[idx] = 0; ++ break; ++ } ++ idx++; + } ++ strcpy( localProperty.workDir, localProperty.buffer ); + +- strcpy( workDir, "cd " ); +- strcat( workDir, PORTSDIR ); +- strcat( workDir, oldPortDir ); +- strcat( workDir, "; make -V WRKDIRPREFIX" ); +- buffer[0] = 0; +- pHandle = popen( workDir, "r" ); +- fread( buffer, 255, 1, pHandle ); ++ /* ++ * store localProperty.optionsDir ++ */ ++ strcpy( localProperty.optionsDir, "cd " ); ++ strcat( localProperty.optionsDir, PORTSDIR ); ++ strcat( localProperty.optionsDir, oldPortDir ); ++ strcat( localProperty.optionsDir, "; make -V OPTIONSFILE" ); ++ localProperty.buffer[0] = 0; ++ pHandle = popen( localProperty.optionsDir, "r" ); ++ fread( localProperty.buffer, 255, 1, pHandle ); + pclose( pHandle ); + idx = 0; + while( idx < 255 ) + { +- if( buffer[idx] == LINEFEED || buffer[idx] == TAB || buffer[idx] == SPACE ) ++ if( localProperty.buffer[idx] == LINEFEED || localProperty.buffer[idx] == TAB || localProperty.buffer[idx] == SPACE ) + { +- buffer[idx] = 0; ++ localProperty.buffer[idx] = 0; + break; + } + idx++; + } +- strcpy( workDir, buffer ); ++ strcpy( localProperty.optionsDir, localProperty.buffer ); ++ ++ /* ++ * BEFORE check for /var/db/ports/{oldPortDir} less sub dir ++ * if it exists get size/time of options file for later comparison ++ * ++ * ++ */ ++ ++ fileStream = fopen( localProperty.optionsDir, "r" ); ++ if( fileStream == NULL ) /* no file */ ++ { ++ localProperty.beforeOptionsFileTime[0] = 0; ++ localProperty.beforeOptionsFileSize[0] = 0; ++ } ++ else ++ { ++ fclose( fileStream ); ++ } ++ strcpy( localProperty.beforeOptionsFileTime, MGrIntToString( (int)MGrFileTime( localProperty.optionsDir ) ) ); ++ strcpy( localProperty.beforeOptionsFileSize, MGrIntToString( MGrFileSize( localProperty.optionsDir ) ) ); + + if( property->interactive ) + { +@@ -152,7 +222,7 @@ + fprintf( stdout, "\nAdding %s %s to ignore list\n", oldPortName, oldPortDir ); + MGdbAdd( property->ignoreDb, oldPortDir, "inteactivly skipped", NULL ); + kkey = getc(stdin); +- rCleanUp( property, buffer, command, newPortDir, newPortName, workDir ); ++ rCleanUp( property, &localProperty ); + return(0); + } + case KEY_n: +@@ -160,7 +230,7 @@ + fprintf( stdout, "\nAdding %s %s to ignore list\n", oldPortName, oldPortDir ); + MGdbAdd( property->ignoreDb, oldPortDir, "inteactivly skipped", NULL ); + kkey = getc(stdin); +- rCleanUp( property, buffer, command, newPortDir, newPortName, workDir ); ++ rCleanUp( property, &localProperty ); + return(0); + } + default: +@@ -185,15 +255,15 @@ + MGdbAdd( property->ignoreDb, oldPortDir, "looping, 3rd attempt at make", NULL ); + if( property->log ) + { +- strcpy( command, "echo \"make Strike 3 " ); +- strcat( command, oldPortName ); +- strcat( command, " " ); +- strcat( command, oldPortDir ); +- strcat( command, " marking port as ignore/looping " ); +- strcat( command, " \">> /var/log/portmanager.log" ); +- system( command ); ++ strcpy( localProperty.command, "echo \"make Strike 3 " ); ++ strcat( localProperty.command, oldPortName ); ++ strcat( localProperty.command, " " ); ++ strcat( localProperty.command, oldPortDir ); ++ strcat( localProperty.command, " marking port as ignore/looping " ); ++ strcat( localProperty.command, " \">> /var/log/portmanager.log" ); ++ system( localProperty.command ); + } +- rCleanUp( property, buffer, command, newPortDir, newPortName, workDir ); ++ rCleanUp( property, &localProperty ); + return( 0 ); + } + if( strike[0] == '1' ) +@@ -207,17 +277,18 @@ + { + fprintf( stdout, "%s %s error: %s returned errorCode %d\n", id, PACKAGE_VERSION, "MGdbDelete", errorCode ); + while( fflush( stdout ) ); ++ rCleanUp( property, &localProperty ); + return( 1 ); + } + MGdbAdd( property->strikesDb, oldPortDir, "2", NULL ); + if( property->log ) + { +- strcpy( command, "echo \"make Strike 2 " ); +- strcat( command, oldPortName ); +- strcat( command, " " ); +- strcat( command, oldPortDir ); +- strcat( command, " \">> /var/log/portmanager.log" ); +- system( command ); ++ strcpy( localProperty.command, "echo \"make Strike 2 " ); ++ strcat( localProperty.command, oldPortName ); ++ strcat( localProperty.command, " " ); ++ strcat( localProperty.command, oldPortDir ); ++ strcat( localProperty.command, " \">> /var/log/portmanager.log" ); ++ system( localProperty.command ); + } + /* + dualOriginCheck( property, oldPortName ); +@@ -237,36 +308,36 @@ + /************************************************************************/ + if( options ) + { +- strcpy( command, "cd " ); +- strcat( command, PORTSDIR ); +- strcat( command, oldPortDir ); +- strcat( command, "; make check-conflicts " ); +- strcat( command, options ); ++ strcpy( localProperty.command, "cd " ); ++ strcat( localProperty.command, PORTSDIR ); ++ strcat( localProperty.command, oldPortDir ); ++ strcat( localProperty.command, "; make check-conflicts " ); ++ strcat( localProperty.command, options ); + } + else + { +- strcpy( command, "cd " ); +- strcat( command, PORTSDIR ); +- strcat( command, oldPortDir ); +- strcat( command, "; make check-conflicts " ); ++ strcpy( localProperty.command, "cd " ); ++ strcat( localProperty.command, PORTSDIR ); ++ strcat( localProperty.command, oldPortDir ); ++ strcat( localProperty.command, "; make check-conflicts " ); + } + fprintf( stdout, "%s\n", SINGLE_LINES ); + fprintf( stdout, "checking for conflicts before building %s\n", oldPortName ); +- fprintf( stdout, "%s %s command: #1 of 8 %s\n", id, PACKAGE_VERSION, command ); ++ fprintf( stdout, "%s %s command: #1 of 8 %s\n", id, PACKAGE_VERSION, localProperty.command ); + fprintf( stdout, "%s\n", SINGLE_LINES ); + while( fflush( stdout ) ); +- if( ( errorCode = system(command) ) ) ++ if( ( errorCode = system(localProperty.command) ) ) + { + /* + * We have a conflicting port installed, pkg_delete -f'ing the stinker + * + */ +- buffer[0] = 0; +- pHandle = popen( command, "r" ); +- fread( buffer, bufferSize, 1, pHandle ); ++ localProperty.buffer[0] = 0; ++ pHandle = popen( localProperty.command, "r" ); ++ fread( localProperty.buffer, bufferSize, 1, pHandle ); + if( feof( pHandle ) && !ferror( pHandle ) ) + { +- bufferBase = strstr( buffer, "conflicts with installed package" ); ++ bufferBase = strstr( localProperty.buffer, "conflicts with installed package" ); + if( bufferBase ) + { + /* +@@ -278,7 +349,7 @@ + * linux_base-rh-9 + * + */ +- bufferBase = buffer ++ bufferBase = localProperty.buffer + + strlen(oldPortName) + + strlen( "===> conflicts with installed package" ); + +@@ -339,7 +410,7 @@ + while( fflush( stdout ) ); + MGdbAdd( property->ignoreDb, oldPortDir, "conflicts with another port", NULL ); + kkey = getc(stdin); +- rCleanUp( property, buffer, command, newPortDir, newPortName, workDir ); ++ rCleanUp( property, &localProperty ); + return(0); + } + case KEY_n: +@@ -348,7 +419,7 @@ + while( fflush( stdout ) ); + MGdbAdd( property->ignoreDb, oldPortDir, "conflicts with another port", NULL ); + kkey = getc(stdin); +- rCleanUp( property, buffer, command, newPortDir, newPortName, workDir ); ++ rCleanUp( property, &localProperty ); + return(0); + } + default: +@@ -359,19 +430,19 @@ + } + } + } +- strcpy( command, "pkg_delete -f " ); +- strcat( command, installedPortsDbPortNamePtr ); +- fprintf( stdout, "executing: %s\n", command ); ++ strcpy( localProperty.command, "pkg_delete -f " ); ++ strcat( localProperty.command, installedPortsDbPortNamePtr ); ++ fprintf( stdout, "executing: %s\n", localProperty.command ); + while( fflush( stdout ) ); +- errorCode = system( command ); ++ errorCode = system( localProperty.command ); + if( property->log ) + { +- strcpy( command, "echo \"removed conflicting port " ); +- strcat( command, oldPortName ); +- strcat( command, " " ); +- strcat( command, oldPortDir ); +- strcat( command, " \">> /var/log/portmanager.log" ); +- system( command ); ++ strcpy( localProperty.command, "echo \"removed conflicting port " ); ++ strcat( localProperty.command, oldPortName ); ++ strcat( localProperty.command, " " ); ++ strcat( localProperty.command, oldPortDir ); ++ strcat( localProperty.command, " \">> /var/log/portmanager.log" ); ++ system( localProperty.command ); + } + } + installedPortsDbIDX++; +@@ -412,32 +483,32 @@ + while( fflush( stderr ) ); + if( property->log ) + { +- strcpy( command, "echo \" " ); +- strcat( command, oldPortName ); +- strcat( command, " " ); +- strcat( command, oldPortDir ); +- strcat( command, " conflicts with another installed port so marked ignore\" >> /var/log/portmanager.log" ); +- system( command ); ++ strcpy( localProperty.command, "echo \" " ); ++ strcat( localProperty.command, oldPortName ); ++ strcat( localProperty.command, " " ); ++ strcat( localProperty.command, oldPortDir ); ++ strcat( localProperty.command, " conflicts with another installed port so marked ignore\" >> /var/log/portmanager.log" ); ++ system( localProperty.command ); + } + MGdbAdd( property->ignoreDb, oldPortDir, "conflicts with another installed port", NULL ); +- rCleanUp( property, buffer, command, newPortDir, newPortName, workDir ); ++ rCleanUp( property, &localProperty ); + return( 0 ); + } + /************************************************************************/ + /* Command "1.1" " make -V FORBIDDEN " */ + /************************************************************************/ +- if( ( errorCode = rPortBrokeCheck( property, options, oldPortDir, oldPortName, "FORBIDDEN" ) ) ) ++ if( ( errorCode = rPortBrokeCheck( property, options, oldPortDir, oldPortName, FORBIDDEN ) ) ) + { + switch( errorCode ) + { + case CRASH: + { +- rCleanUp( property, buffer, command, newPortDir, newPortName, workDir ); ++ rCleanUp( property, &localProperty ); + return( CRASH ); + } + case SKIP: + { +- rCleanUp( property, buffer, command, newPortDir, newPortName, workDir ); ++ rCleanUp( property, &localProperty ); + return( OK ); + } + } +@@ -446,18 +517,18 @@ + /************************************************************************/ + /* Command "1.2" " make -V BROKEN " */ + /************************************************************************/ +- if( ( errorCode = rPortBrokeCheck( property, options, oldPortDir, oldPortName, "BROKEN" ) ) ) ++ if( ( errorCode = rPortBrokeCheck( property, options, oldPortDir, oldPortName, BROKEN ) ) ) + { + switch( errorCode ) + { + case CRASH: + { +- rCleanUp( property, buffer, command, newPortDir, newPortName, workDir ); ++ rCleanUp( property, &localProperty ); + return( CRASH ); + } + case SKIP: + { +- rCleanUp( property, buffer, command, newPortDir, newPortName, workDir ); ++ rCleanUp( property, &localProperty ); + return( OK ); + } + } +@@ -466,18 +537,18 @@ + /************************************************************************/ + /* Command "1.3" " make -V IGNORE " */ + /************************************************************************/ +- if( ( errorCode = rPortBrokeCheck( property, options, oldPortDir, oldPortName, "IGNORE" ) ) ) ++ if( ( errorCode = rPortBrokeCheck( property, options, oldPortDir, oldPortName, IGNORE ) ) ) + { + switch( errorCode ) + { + case CRASH: + { +- rCleanUp( property, buffer, command, newPortDir, newPortName, workDir ); ++ rCleanUp( property, &localProperty ); + return( CRASH ); + } + case SKIP: + { +- rCleanUp( property, buffer, command, newPortDir, newPortName, workDir ); ++ rCleanUp( property, &localProperty ); + return( OK ); + } + } +@@ -514,7 +585,7 @@ + + while( oldPortDirPtr && availableDependenciesDbIDX < availableDependenciesDbQTY && strcmp( oldPortDir, oldPortDirPtr ) == 0 ) + { +- rCleanDir( availableDependenciesDbDependencyDirPtr, workDir ); ++ rCleanDir( availableDependenciesDbDependencyDirPtr, localProperty.workDir ); + + oldPortDirPtr = MGdbGet( property->availableDependenciesDb, + availableDependenciesDbIDX, +@@ -527,7 +598,7 @@ + property->fieldAvailableDependenciesDbDependencyName ); + availableDependenciesDbIDX++; + } +- rCleanDir( oldPortDir, workDir ); ++ rCleanDir( oldPortDir, localProperty.workDir ); + } + else + { +@@ -553,7 +624,7 @@ + + while( oldPortDirPtr && dependencyPortsDbIDX < dependencyPortsDbQTY && strcmp( oldPortDir, oldPortDirPtr ) == 0 ) + { +- rCleanDir( dependencyDbDependencyPortDirPtr, workDir ); ++ rCleanDir( dependencyDbDependencyPortDirPtr, localProperty.workDir ); + + oldPortDirPtr = MGdbSeek( property->dependencyPortsDb, + property->fieldDependencyDbPortDir, +@@ -571,80 +642,215 @@ + + dependencyPortsDbIDX++; + } +- rCleanDir( oldPortDir, workDir ); ++ rCleanDir( oldPortDir, localProperty.workDir ); + } + + /************************************************************************/ + /* Command "3.1" " make fetch" */ + /************************************************************************/ +- strcpy( command, "cd " ); +- strcat( command, PORTSDIR ); +- strcat( command, oldPortDir ); +- strcat( command, "; make fetch " ); ++ strcpy( localProperty.command, "cd " ); ++ strcat( localProperty.command, PORTSDIR ); ++ strcat( localProperty.command, oldPortDir ); ++ strcat( localProperty.command, "; make fetch " ); + if( options ) + { +- strcat( command, options ); ++ strcat( localProperty.command, options ); + } + fprintf( stdout, "%s\n", SINGLE_LINES ); + fprintf( stdout, "fetch %s \n", oldPortName ); +- fprintf( stdout, "%s %s command: #3.1 of 8 %s\n", id, PACKAGE_VERSION, command ); ++ fprintf( stdout, "%s %s command: #3.1 of 8 %s\n", id, PACKAGE_VERSION, localProperty.command ); + fprintf( stdout, "%s\n", SINGLE_LINES ); + while( fflush( stdout ) ); +- if( ( errorCode = system(command) ) ) ++ if( ( errorCode = system(localProperty.command) ) ) + { + if( property->log ) + { +- strcpy( command, "echo \" " ); +- strcat( command, oldPortName ); +- strcat( command, " " ); +- strcat( command, oldPortDir ); +- strcat( command, " failed to fetch\" >> /var/log/portmanager.log" ); +- system( command ); ++ strcpy( localProperty.command, "echo \" " ); ++ strcat( localProperty.command, oldPortName ); ++ strcat( localProperty.command, " " ); ++ strcat( localProperty.command, oldPortDir ); ++ strcat( localProperty.command, " failed to fetch\" >> /var/log/portmanager.log" ); ++ system( localProperty.command ); + } + fprintf( stdout, "%s %s error: make fetch returned an error, adding %s to ignore.db\n", id, PACKAGE_VERSION, oldPortDir ); + while( fflush( stdout ) ); + MGdbAdd( property->ignoreDb, oldPortDir, "failed during make fetch", NULL ); +- rCleanUp( property, buffer, command, newPortDir, newPortName, workDir ); ++ rCleanUp( property, &localProperty ); + return(0); + } ++ ++ + /************************************************************************/ +- /* Command "3.2" " make " */ ++ /* Command "3.2" " make -V OPTIONS" */ ++ /************************************************************************/ ++ ++ /* ++ * If no /var/db/ports/{package name}/options file exists ++ * yet make -V OPTIONS shows OPTIONS as being defined ++ * make is going to bluescreen, we need to handle that here ++ */ ++ ++ strcpy( localProperty.optionsCheck, "cd " ); ++ strcat( localProperty.optionsCheck, PORTSDIR ); ++ strcat( localProperty.optionsCheck, oldPortDir ); ++ strcat( localProperty.optionsCheck, "; make -V OPTIONS" ); ++ ++ fprintf( stdout, "%s\n", SINGLE_LINES ); ++ fprintf( stdout, "%s %s command: #3.2 of 8 %s\n", id, PACKAGE_VERSION, localProperty.optionsCheck ); ++ fprintf( stdout, "%s\n", SINGLE_LINES ); ++ while( fflush( stdout ) ); ++ ++ pHandle = popen( localProperty.optionsCheck, "r" ); ++ localProperty.buffer[0] = 0; ++ fread( localProperty.buffer, bufferSize, 1, pHandle ); ++ pclose( pHandle ); ++ /************************************************************************/ ++ /* Command "3.3" " make conf" */ ++ /************************************************************************/ ++ if( strlen( localProperty.buffer ) > 4 ) ++ { ++ /* ++ * If here we know OPTIONS is defined, now need to know if ++ * /var/db/ports/{package name}/options exists ++ */ ++ fileStream = fopen( localProperty.optionsDir, "r" ); ++ if( fileStream == NULL ) /* no file */ ++ { ++ if( options ) ++ { ++ strcpy( localProperty.command, "cd " ); ++ strcat( localProperty.command, PORTSDIR ); ++ strcat( localProperty.command, oldPortDir ); ++ strcat( localProperty.command, "; make config " ); ++ strcat( localProperty.command, options ); ++ } ++ else ++ { ++ strcpy( localProperty.command, "cd " ); ++ strcat( localProperty.command, PORTSDIR ); ++ strcat( localProperty.command, oldPortDir ); ++ strcat( localProperty.command, "; make config " ); ++ } ++ fprintf( stdout, "%s\n", SINGLE_LINES ); ++ fprintf( stdout, "update %s \n", oldPortName ); ++ fprintf( stdout, "%s %s command: #3.3 of 8 %s\n", id, PACKAGE_VERSION, localProperty.command ); ++ fprintf( stdout, "%s\n", SINGLE_LINES ); ++ while( fflush( stdout ) ); ++ system(localProperty.command); ++ } ++ else ++ { ++ fclose( fileStream ); ++ } ++ strcpy( localProperty.afterOptionsFileTime, MGrIntToString( (int)MGrFileTime( localProperty.optionsDir ) ) ); ++ strcpy( localProperty.afterOptionsFileSize, MGrIntToString( MGrFileSize( localProperty.optionsDir ) ) ); ++ ++ /* ++ * test to see if any options changed ++ */ ++ if( strlen( localProperty.beforeOptionsFileTime ) != strlen( localProperty.afterOptionsFileTime ) || ++ strlen( localProperty.beforeOptionsFileSize ) != strlen( localProperty.afterOptionsFileSize ) || ++ strcmp( localProperty.beforeOptionsFileTime, localProperty.afterOptionsFileTime ) || ++ strcmp( localProperty.beforeOptionsFileSize, localProperty.afterOptionsFileSize ) ) ++ { ++fprintf( stdout, "%s debug 01: beforeOptionsFileTime-=>%s afterOptionsFileTime-=>%s beforeOptionsFileSize-=>%s afterOptionsFileSize-=>%s\n", ++ id, ++ localProperty.beforeOptionsFileTime, ++ localProperty.afterOptionsFileTime, ++ localProperty.beforeOptionsFileSize, ++ localProperty.afterOptionsFileSize ); ++while( fflush( stdout ) ); ++ ++ /* ++ * options changed so need to purge oldPortDir's records ++ * from availablePortsDb and availableDependenciesDb ++ */ ++ property->optionsChanged = 1; ++ MGdbGoTop( property->availablePortsDb ); ++ while( MGdbSeek( property->availablePortsDb, ++ property->fieldAvailablePortsDbPortDir, ++ oldPortDir, ++ property->fieldAvailablePortsDbPortDir, ++ exact ) ) ++ { ++ fprintf( stdout, "%s info: purging availablePortsDb of old %s record\n", ++ id, ++ MGdbGet( property->availablePortsDb, ++ MGdbGetRecno( property->availablePortsDb ) - 1, ++ property->fieldAvailablePortsDbPortName ) ); ++ while( fflush( stdout ) ); ++ MGdbDelete( property->availablePortsDb, MGdbGetRecno( property->availablePortsDb ) - 1 ); ++ MGdbGoTop( property->availablePortsDb ); ++ } ++ ++ MGdbGoTop( property->availableDependenciesDb ); ++ while( MGdbSeek( property->availableDependenciesDb, ++ property->fieldAvailableDependenciesDbPortDir, ++ oldPortDir, ++ property->fieldAvailableDependenciesDbPortDir, ++ exact ) ) ++ { ++ fprintf( stdout, "%s info: purging availableDependenciesDb of old %s dependency records %s\n", ++ id, ++ MGdbGet( property->availableDependenciesDb, ++ MGdbGetRecno( property->availableDependenciesDb ) - 1, ++ property->fieldAvailableDependenciesDbPortName ), ++ MGdbGet( property->availableDependenciesDb, ++ MGdbGetRecno( property->availableDependenciesDb ) - 1, ++ property->fieldAvailableDependenciesDbDependencyName ) ); ++ while( fflush( stdout ) ); ++ MGdbDelete( property->availableDependenciesDb, MGdbGetRecno( property->availableDependenciesDb ) - 1 ); ++ MGdbGoTop( property->availableDependenciesDb ); ++ } ++ /* ++ * add oldPortDir's new records back into availablePortsDb ++ * and availableDependenciesDb ++ */ ++ fprintf( stdout, "%s info: adding new/modified %s records\n", id, oldPortDir ); ++ MGPMrSinglePortCreateStatusDb( property, oldPortDir ); ++ rCleanUp( property, &localProperty ); ++ return( 0 ); ++ } ++ } ++ ++ /************************************************************************/ ++ /* Command "3.4" " make" */ + /************************************************************************/ + if( options ) + { +- strcpy( command, "cd " ); +- strcat( command, PORTSDIR ); +- strcat( command, oldPortDir ); +- strcat( command, "; make " ); +- strcat( command, options ); ++ strcpy( localProperty.command, "cd " ); ++ strcat( localProperty.command, PORTSDIR ); ++ strcat( localProperty.command, oldPortDir ); ++ strcat( localProperty.command, "; make " ); ++ strcat( localProperty.command, options ); + } + else + { +- strcpy( command, "cd " ); +- strcat( command, PORTSDIR ); +- strcat( command, oldPortDir ); +- strcat( command, "; make " ); ++ strcpy( localProperty.command, "cd " ); ++ strcat( localProperty.command, PORTSDIR ); ++ strcat( localProperty.command, oldPortDir ); ++ strcat( localProperty.command, "; make " ); + } + fprintf( stdout, "%s\n", SINGLE_LINES ); + fprintf( stdout, "update %s \n", oldPortName ); +- fprintf( stdout, "%s %s command: #3.2 of 8 %s\n", id, PACKAGE_VERSION, command ); ++ fprintf( stdout, "%s %s command: #3.4 of 8 %s\n", id, PACKAGE_VERSION, localProperty.command ); + fprintf( stdout, "%s\n", SINGLE_LINES ); + while( fflush( stdout ) ); +- if( ( errorCode = system(command) ) ) ++ if( ( errorCode = system(localProperty.command) ) ) + { + if( property->log ) + { +- strcpy( command, "echo \" " ); +- strcat( command, oldPortName ); +- strcat( command, " " ); +- strcat( command, oldPortDir ); +- strcat( command, " failed during make\" >> /var/log/portmanager.log" ); +- system( command ); ++ strcpy( localProperty.command, "echo \" " ); ++ strcat( localProperty.command, oldPortName ); ++ strcat( localProperty.command, " " ); ++ strcat( localProperty.command, oldPortDir ); ++ strcat( localProperty.command, " failed during make\" >> /var/log/portmanager.log" ); ++ system( localProperty.command ); + } + fprintf( stdout, "%s %s error: make returned an error, adding %s to ignore.db\n", id, PACKAGE_VERSION, oldPortDir ); + while( fflush( stdout ) ); + MGdbAdd( property->ignoreDb, oldPortDir, "failed during make", NULL ); +- rCleanUp( property, buffer, command, newPortDir, newPortName, workDir ); ++ rCleanUp( property, &localProperty ); + return(0); + } + /************************************************************************/ +@@ -660,17 +866,17 @@ + } + else + { +- strcpy( command, "cd " ); +- strcat( command, TEMPDIR ); +- strcat( command, "; pkg_create -b " ); +- strcat( command, oldPortName ); ++ strcpy( localProperty.command, "cd " ); ++ strcat( localProperty.command, TEMPDIR ); ++ strcat( localProperty.command, "; pkg_create -b " ); ++ strcat( localProperty.command, oldPortName ); + + fprintf( stdout, "%s\n", SINGLE_LINES ); + fprintf( stdout, "backing up installed %s before removing it \n", oldPortName ); +- fprintf( stdout, "%s %s command: #4 of 8 %s\n", id, PACKAGE_VERSION, command ); ++ fprintf( stdout, "%s %s command: #4 of 8 %s\n", id, PACKAGE_VERSION, localProperty.command ); + fprintf( stdout, "%s\n", SINGLE_LINES ); + while( fflush( stdout ) ); +- system(command); ++ system(localProperty.command); + } + /************************************************************************/ + /* Command "5" " make deinstall " */ +@@ -681,30 +887,30 @@ + if( ( strcmp( oldPortDir, "/sysutils/portmanager" ) == 0 || strcmp( oldPortDir, "/local/sysutils/portmanager" ) == 0 ) && + property->pmMode == SINGLE ) + { +- strcpy( command, "cd " ); +- strcat( command, PORTSDIR ); +- strcat( command, "/sysutils/portmanager; " ); +- strcat( command, "make -V PKG_DBDIR" ); +- pHandle = popen( command, "r" ); +- buffer[0] = 0; +- fread( buffer, 255, 1, pHandle ); ++ strcpy( localProperty.command, "cd " ); ++ strcat( localProperty.command, PORTSDIR ); ++ strcat( localProperty.command, "/sysutils/portmanager; " ); ++ strcat( localProperty.command, "make -V PKG_DBDIR" ); ++ pHandle = popen( localProperty.command, "r" ); ++ localProperty.buffer[0] = 0; ++ fread( localProperty.buffer, 255, 1, pHandle ); + pclose( pHandle ); + idx = 0; + while( idx < 255 ) + { +- if( buffer[idx] == LINEFEED || buffer[idx] == TAB || buffer[idx] == SPACE ) ++ if( localProperty.buffer[idx] == LINEFEED || localProperty.buffer[idx] == TAB || localProperty.buffer[idx] == SPACE ) + { +- buffer[idx] = 0; ++ localProperty.buffer[idx] = 0; + break; + } + idx++; + } +- strcpy( command, "rm -r " ); +- strcat( command, buffer ); +- strcat( command, "/portmanager*" ); +- fprintf( stdout, "executing: %s\n", command ); ++ strcpy( localProperty.command, "rm -r " ); ++ strcat( localProperty.command, localProperty.buffer ); ++ strcat( localProperty.command, "/portmanager*" ); ++ fprintf( stdout, "executing: %s\n", localProperty.command ); + while( fflush( stdout ) ); +- system( command ); ++ system( localProperty.command ); + } + else + { +@@ -717,13 +923,13 @@ + /* + * have to do this here before db's are wacked + */ +- strcpy( commandRestart, "portmanager -u" ); ++ strcpy( localProperty.commandRestart, "portmanager -u" ); + MGdbGoTop( property->commandLineDb ); +- while( ( ipPtr = MGdbSeek( property->commandLineDb, property->fieldCommandLineDbKey, "-ip", property->fieldCommandLineDbValue, exact ) ) ) ++ while( ( ipPtr = MGdbSeek( property->commandLineDb, property->fieldCommandLineDbKey, ip, property->fieldCommandLineDbValue, exact ) ) ) + { +- strcat( commandRestart, " " ); +- strcat( commandRestart, " -ip " ); +- strcat( commandRestart, ipPtr ); ++ strcat( localProperty.commandRestart, " " ); ++ strcat( localProperty.commandRestart, " -ip " ); ++ strcat( localProperty.commandRestart, ipPtr ); + } + } + if( strcmp( oldPortName, "not installed" ) == 0 ) +@@ -736,27 +942,27 @@ + } + else + { +- strcpy( command, "pkg_delete -f "); +- strcat( command, oldPortName); ++ strcpy( localProperty.command, "pkg_delete -f "); ++ strcat( localProperty.command, oldPortName); + fprintf( stdout, "%s\n", SINGLE_LINES ); + fprintf( stdout, "removing old %s \n", oldPortName ); +- fprintf( stdout, "%s %s command: #5 of 8 %s\n", id, PACKAGE_VERSION, command ); ++ fprintf( stdout, "%s %s command: #5 of 8 %s\n", id, PACKAGE_VERSION, localProperty.command ); + fprintf( stdout, "%s\n", SINGLE_LINES ); + while( fflush( stdout ) ); +- if( ( system(command) ) ) ++ if( ( system(localProperty.command) ) ) + { +- command[0] = 0; +- strcpy( command, "cd " ); +- strcat( command, PORTSDIR ); +- strcat( command, oldPortDir ); +- strcat( command, "; make deinstall " ); ++ localProperty.command[0] = 0; ++ strcpy( localProperty.command, "cd " ); ++ strcat( localProperty.command, PORTSDIR ); ++ strcat( localProperty.command, oldPortDir ); ++ strcat( localProperty.command, "; make deinstall " ); + + fprintf( stdout, "%s\n", SINGLE_LINES ); + fprintf( stdout, "trying one more way to remove %s...\n", oldPortName ); +- fprintf( stdout, "%s %s command: #5 of 8 %s\n", id, PACKAGE_VERSION, command ); ++ fprintf( stdout, "%s %s command: #5 of 8 %s\n", id, PACKAGE_VERSION, localProperty.command ); + fprintf( stdout, "%s\n", SINGLE_LINES ); + while( fflush( stdout ) ); +- system(command); ++ system(localProperty.command); + } + } + } +@@ -765,73 +971,73 @@ + /************************************************************************/ + if( options ) + { +- strcpy( command, "cd " ); +- strcat( command, PORTSDIR ); +- strcat( command, oldPortDir ); +- strcat( command, "; make reinstall " ); +- strcat( command, options ); ++ strcpy( localProperty.command, "cd " ); ++ strcat( localProperty.command, PORTSDIR ); ++ strcat( localProperty.command, oldPortDir ); ++ strcat( localProperty.command, "; make reinstall " ); ++ strcat( localProperty.command, options ); + } + else + { +- strcpy( command, "cd " ); +- strcat( command, PORTSDIR ); +- strcat( command, oldPortDir ); +- strcat( command, "; make reinstall " ); ++ strcpy( localProperty.command, "cd " ); ++ strcat( localProperty.command, PORTSDIR ); ++ strcat( localProperty.command, oldPortDir ); ++ strcat( localProperty.command, "; make reinstall " ); + } + fprintf( stdout, "%s\n", SINGLE_LINES ); + fprintf( stdout, "installing updated %s \n", oldPortDir ); +- fprintf( stdout, "%s %s command: #6 of 8 %s\n", id, PACKAGE_VERSION, command ); ++ fprintf( stdout, "%s %s command: #6 of 8 %s\n", id, PACKAGE_VERSION, localProperty.command ); + fprintf( stdout, "%s\n", SINGLE_LINES ); + while( fflush( stdout ) ); +- if( ( errorCode = system( command ) ) ) ++ if( ( errorCode = system( localProperty.command ) ) ) + { + if( property->log ) + { +- strcpy( command, "echo \" " ); +- strcat( command, oldPortName ); +- strcat( command, " " ); +- strcat( command, oldPortDir ); +- strcat( command, " restoring original port from backup\" >> /var/log/portmanager.log" ); +- system( command ); ++ strcpy( localProperty.command, "echo \" " ); ++ strcat( localProperty.command, oldPortName ); ++ strcat( localProperty.command, " " ); ++ strcat( localProperty.command, oldPortDir ); ++ strcat( localProperty.command, " restoring original port from backup\" >> /var/log/portmanager.log" ); ++ system( localProperty.command ); + } + + +- strcpy(command, "pkg_add "); +- strcat(command, TEMPDIR); +- strcat(command, "/"); +- strcat(command, oldPortName); +- strcat(command, ".tgz"); ++ strcpy(localProperty.command, "pkg_add "); ++ strcat(localProperty.command, TEMPDIR); ++ strcat(localProperty.command, "/"); ++ strcat(localProperty.command, oldPortName); ++ strcat(localProperty.command, ".tgz"); + fprintf( stdout, "%s\n", SINGLE_LINES ); + fprintf( stderr, "restoring original port from backup \n" ); +- fprintf( stderr, "%s %s command: #6!! ***Emergancy restore*** %s\n", id, PACKAGE_VERSION, command ); ++ fprintf( stderr, "%s %s command: #6!! ***Emergancy restore*** %s\n", id, PACKAGE_VERSION, localProperty.command ); + fprintf( stdout, "%s\n", SINGLE_LINES ); + while( fflush( stdout ) ); +- if( ( errorCode = system( command ) ) ) ++ if( ( errorCode = system( localProperty.command ) ) ) + { + if( property->log ) + { +- strcpy( command, "echo \" " ); +- strcat( command, oldPortName ); +- strcat( command, " " ); +- strcat( command, oldPortDir ); +- strcat( command, " failed to restore from backup\" >> /var/log/portmanager.log" ); +- system( command ); ++ strcpy( localProperty.command, "echo \" " ); ++ strcat( localProperty.command, oldPortName ); ++ strcat( localProperty.command, " " ); ++ strcat( localProperty.command, oldPortDir ); ++ strcat( localProperty.command, " failed to restore from backup\" >> /var/log/portmanager.log" ); ++ system( localProperty.command ); + } + fprintf( stdout, "%s %s error: FAILED TO RESTORE BACKUP COPY, really sorry ! \n", id, PACKAGE_VERSION ); + fprintf( stdout, "%s %s info: adding %s to ignore.db\n", id, PACKAGE_VERSION, oldPortDir ); + while( fflush( stdout ) ); + MGdbAdd( property->ignoreDb, oldPortDir, "failed during (6) emergancy restore", NULL ); +- rCleanUp( property, buffer, command, newPortDir, newPortName, workDir ); ++ rCleanUp( property, &localProperty ); + return(0); + } + if( property->log ) + { +- strcpy( command, "echo \" " ); +- strcat( command, oldPortName ); +- strcat( command, " " ); +- strcat( command, oldPortDir ); +- strcat( command, " restored from backup and marked ignore\" >> /var/log/portmanager.log" ); +- system( command ); ++ strcpy( localProperty.command, "echo \" " ); ++ strcat( localProperty.command, oldPortName ); ++ strcat( localProperty.command, " " ); ++ strcat( localProperty.command, oldPortDir ); ++ strcat( localProperty.command, " restored from backup and marked ignore\" >> /var/log/portmanager.log" ); ++ system( localProperty.command ); + } + fprintf( stdout, "%s\n", SINGLE_LINES ); + fprintf( stdout, "%s %s error: RESTORED BACKUP COPY\n", id, PACKAGE_VERSION ); +@@ -839,24 +1045,24 @@ + MGdbAdd( property->ignoreDb, oldPortDir, "performed (6) emergancy restore", NULL ); + fprintf( stdout, "%s\n", SINGLE_LINES ); + while( fflush( stdout ) ); +- rCleanUp( property, buffer, command, newPortDir, newPortName, workDir ); ++ rCleanUp( property, &localProperty ); + return(0); + } + else + { + if( strcmp( oldPortName, "not installed" ) ) + { +- strcpy( command, "cd " ); +- strcat( command, TEMPDIR); +- strcat( command, "; rm -f "); +- strcat( command, oldPortName); +- strcat( command, ".tgz" ); ++ strcpy( localProperty.command, "cd " ); ++ strcat( localProperty.command, TEMPDIR); ++ strcat( localProperty.command, "; rm -f "); ++ strcat( localProperty.command, oldPortName); ++ strcat( localProperty.command, ".tgz" ); + fprintf( stdout, "%s\n", SINGLE_LINES ); + fprintf( stderr, "deleting backup copy, installation of updated %s successful\n", oldPortDir ); +- fprintf( stdout, "%s %s command: #6 of 8 %s\n", id, PACKAGE_VERSION, command ); ++ fprintf( stdout, "%s %s command: #6 of 8 %s\n", id, PACKAGE_VERSION, localProperty.command ); + fprintf( stdout, "%s\n", SINGLE_LINES ); + while( fflush( stdout ) ); +- system( command ); ++ system( localProperty.command ); + } + } + /************************************************************************/ +@@ -866,25 +1072,25 @@ + { + if( options ) + { +- strcpy( command, "cd " ); +- strcat( command, PORTSDIR ); +- strcat( command, oldPortDir ); +- strcat( command, "; make package " ); +- strcat( command, options ); ++ strcpy( localProperty.command, "cd " ); ++ strcat( localProperty.command, PORTSDIR ); ++ strcat( localProperty.command, oldPortDir ); ++ strcat( localProperty.command, "; make package " ); ++ strcat( localProperty.command, options ); + } + else + { +- strcpy( command, "cd " ); +- strcat( command, PORTSDIR ); +- strcat( command, oldPortDir ); +- strcat( command, "; make package " ); ++ strcpy( localProperty.command, "cd " ); ++ strcat( localProperty.command, PORTSDIR ); ++ strcat( localProperty.command, oldPortDir ); ++ strcat( localProperty.command, "; make package " ); + } + fprintf( stdout, "%s\n", SINGLE_LINES ); + fprintf( stderr, "making package of updated %s \n", oldPortDir ); +- fprintf( stdout, "%s %s command: #7 of 8 %s\n", id, PACKAGE_VERSION, command ); ++ fprintf( stdout, "%s %s command: #7 of 8 %s\n", id, PACKAGE_VERSION, localProperty.command ); + fprintf( stdout, "%s\n", SINGLE_LINES ); + while( fflush( stdout ) ); +- system(command); ++ system(localProperty.command); + } + else + { +@@ -908,7 +1114,7 @@ + if( ( strcmp( oldPortDir, "/sysutils/portmanager" ) == 0 || strcmp( oldPortDir, "/local/sysutils/portmanager" ) == 0 ) && + property->pmMode == MULTI ) + { +- rCleanDir( oldPortDir, workDir ); ++ rCleanDir( oldPortDir, localProperty.workDir ); + } + else + { +@@ -934,7 +1140,7 @@ + + while( oldPortDirPtr && availableDependenciesDbIDX < availableDependenciesDbQTY && strcmp( oldPortDir, oldPortDirPtr ) == 0 ) + { +- rCleanDir( availableDependenciesDbDependencyDirPtr, workDir ); ++ rCleanDir( availableDependenciesDbDependencyDirPtr, localProperty.workDir ); + + oldPortDirPtr = MGdbGet( property->availableDependenciesDb, + availableDependenciesDbIDX, +@@ -947,7 +1153,7 @@ + property->fieldAvailableDependenciesDbDependencyName ); + availableDependenciesDbIDX++; + } +- rCleanDir( oldPortDir, workDir ); ++ rCleanDir( oldPortDir, localProperty.workDir ); + } + else + { +@@ -973,7 +1179,7 @@ + + while( oldPortDirPtr && dependencyPortsDbIDX < dependencyPortsDbQTY && strcmp( oldPortDir, oldPortDirPtr ) == 0 ) + { +- rCleanDir( dependencyDbDependencyPortDirPtr, workDir ); ++ rCleanDir( dependencyDbDependencyPortDirPtr, localProperty.workDir ); + + oldPortDirPtr = MGdbSeek( property->dependencyPortsDb, + property->fieldDependencyDbPortDir, +@@ -991,7 +1197,7 @@ + + dependencyPortsDbIDX++; + } +- rCleanDir( oldPortDir, workDir ); ++ rCleanDir( oldPortDir, localProperty.workDir ); + } + } + +@@ -1005,47 +1211,47 @@ + * reconstruct the command line + */ + MGdbGoTop( property->commandLineDb ); +- if( ( ipPtr = MGdbSeek( property->commandLineDb, property->fieldCommandLineDbKey, "-l", property->fieldCommandLineDbValue, exact ) ) ) ++ if( ( ipPtr = MGdbSeek( property->commandLineDb, property->fieldCommandLineDbKey, l, property->fieldCommandLineDbValue, exact ) ) ) + { +- strcat( commandRestart, " " ); +- strcat( commandRestart, "-l" ); ++ strcat( localProperty.commandRestart, " " ); ++ strcat( localProperty.commandRestart, "-l" ); + } + MGdbGoTop( property->commandLineDb ); +- if( ( ipPtr = MGdbSeek( property->commandLineDb, property->fieldCommandLineDbKey, "--log", property->fieldCommandLineDbValue, exact ) ) ) ++ if( ( ipPtr = MGdbSeek( property->commandLineDb, property->fieldCommandLineDbKey, log, property->fieldCommandLineDbValue, exact ) ) ) + { +- strcat( commandRestart, " " ); +- strcat( commandRestart, "-l" ); ++ strcat( localProperty.commandRestart, " " ); ++ strcat( localProperty.commandRestart, "-l" ); + } + MGdbGoTop( property->commandLineDb ); +- if( ( ipPtr = MGdbSeek( property->commandLineDb, property->fieldCommandLineDbKey, "-bu", property->fieldCommandLineDbValue, exact ) ) ) ++ if( ( ipPtr = MGdbSeek( property->commandLineDb, property->fieldCommandLineDbKey, bu, property->fieldCommandLineDbValue, exact ) ) ) + { +- strcat( commandRestart, " " ); +- strcat( commandRestart, "-bu" ); ++ strcat( localProperty.commandRestart, " " ); ++ strcat( localProperty.commandRestart, "-bu" ); + } + MGdbGoTop( property->commandLineDb ); +- if( ( ipPtr = MGdbSeek( property->commandLineDb, property->fieldCommandLineDbKey, "--back-up", property->fieldCommandLineDbValue, exact ) ) ) ++ if( ( ipPtr = MGdbSeek( property->commandLineDb, property->fieldCommandLineDbKey, backUp, property->fieldCommandLineDbValue, exact ) ) ) + { +- strcat( commandRestart, " " ); +- strcat( commandRestart, "-bu" ); ++ strcat( localProperty.commandRestart, " " ); ++ strcat( localProperty.commandRestart, "-bu" ); + } + MGdbGoTop( property->commandLineDb ); +- if( ( ipPtr = MGdbSeek( property->commandLineDb, property->fieldCommandLineDbKey, "-y", property->fieldCommandLineDbValue, exact ) ) ) ++ if( ( ipPtr = MGdbSeek( property->commandLineDb, property->fieldCommandLineDbKey, y, property->fieldCommandLineDbValue, exact ) ) ) + { +- strcat( commandRestart, " " ); +- strcat( commandRestart, "-y" ); ++ strcat( localProperty.commandRestart, " " ); ++ strcat( localProperty.commandRestart, "-y" ); + } + MGdbGoTop( property->commandLineDb ); +- if( ( ipPtr = MGdbSeek( property->commandLineDb, property->fieldCommandLineDbKey, "--yes", property->fieldCommandLineDbValue, exact ) ) ) ++ if( ( ipPtr = MGdbSeek( property->commandLineDb, property->fieldCommandLineDbKey, yes, property->fieldCommandLineDbValue, exact ) ) ) + { +- strcat( commandRestart, " " ); +- strcat( commandRestart, "--yes" ); ++ strcat( localProperty.commandRestart, " " ); ++ strcat( localProperty.commandRestart, "--yes" ); + } +- strcat( commandRestart, " --resume" ); ++ strcat( localProperty.commandRestart, " --resume" ); + fprintf(stdout, "%s\n", SINGLE_LINES); +- fprintf(stdout, "portmanager just updated itself, executing:\n\t%s\n", commandRestart ); ++ fprintf(stdout, "portmanager just updated itself, executing:\n\t%s\n", localProperty.commandRestart ); + fprintf(stdout, "%s\n", SINGLE_LINES); + while( fflush( stdout ) ); +- system( commandRestart ); ++ system( localProperty.commandRestart ); + exit( 0 ); + + } +@@ -1061,44 +1267,47 @@ + if( availablePortsFlagPtr && strncmp( availablePortsFlagPtr, "2", 1 ) ) + { + availablePortsDbIDX = MGdbGetRecno( property->availablePortsDb ) - 1; +- strcpy( newPortName, MGdbGet( property->availablePortsDb, availablePortsDbIDX, property->fieldAvailablePortsDbPortName ) ); +- strcpy( newPortDir, MGdbGet( property->availablePortsDb, availablePortsDbIDX, property->fieldAvailablePortsDbPortDir ) ); ++ strcpy( localProperty.newPortName, MGdbGet( property->availablePortsDb, availablePortsDbIDX, property->fieldAvailablePortsDbPortName ) ); ++ strcpy( localProperty.newPortDir, MGdbGet( property->availablePortsDb, availablePortsDbIDX, property->fieldAvailablePortsDbPortDir ) ); + if( ( errorCode = MGdbDelete( property->availablePortsDb, availablePortsDbIDX ) ) ) + { + fprintf( stdout, "%s %s error: %s returned errorCode %d\n", id, PACKAGE_VERSION, "MGdbDelete", errorCode ); ++ rCleanUp( property, &localProperty ); + return( 1 ); + } +- MGdbAdd( property->availablePortsDb, newPortName, newPortDir, "2", NULL ); ++ MGdbAdd( property->availablePortsDb, localProperty.newPortName, localProperty.newPortDir, "2", NULL ); + } + } +- free( commandRestart ); +- rCleanUp( property, buffer, command, newPortDir, newPortName, workDir ); ++ rCleanUp( property, &localProperty ); + return( 0 ); + } + /****************************************/ + /****************************************/ + /****************************************/ +-int rCleanUp( structProperty* property, char* buffer, char* command, char* newPortDir, char* newPortName, char* workDir ) ++int rCleanUp( structProperty* property, structLocalProperty* localProperty ) + { ++ MGdbDestroy( property->availableDependenciesDb ); ++ MGdbDestroy( property->availablePortsDb ); + MGdbDestroy( property->commandLineDb ); + MGdbDestroy( property->configDb ); ++ MGdbDestroy( property->dependencyPortsDb ); + MGdbDestroy( property->ignoreDb ); + MGdbDestroy( property->installedPortsDb ); + MGdbDestroy( property->strikesDb ); +- free( buffer ); +- free( command ); +- free( newPortDir ); +- free( newPortName ); +- free( workDir ); +- if( property->pmMode || property->forced ) +- { +- MGdbDestroy( property->availablePortsDb ); +- MGdbDestroy( property->availableDependenciesDb ); +- } +- else +- { +- MGdbDestroy( property->dependencyPortsDb ); +- } ++ ++ free( localProperty->afterOptionsFileSize ); ++ free( localProperty->afterOptionsFileTime ); ++ free( localProperty->beforeOptionsFileSize ); ++ free( localProperty->beforeOptionsFileTime ); ++ free( localProperty->buffer ); ++ free( localProperty->command ); ++ free( localProperty->commandRestart ); ++ free( localProperty->newPortDir ); ++ free( localProperty->newPortName ); ++ free( localProperty->optionsCheck ); ++ free( localProperty->optionsDir ); ++ free( localProperty->workDir ); ++ + return(0); + } + /****************************************/ +diff -ruN ../0.3.2/libMGPM/src/libMGPM.h ./libMGPM/src/libMGPM.h +--- ../0.3.2/libMGPM/src/libMGPM.h Fri Nov 4 08:42:49 2005 ++++ ./libMGPM/src/libMGPM.h Sun Nov 6 04:06:31 2005 +@@ -91,16 +91,17 @@ + /* + * default flags + */ ++ int autoConflicts; /* if 1 then conflicts Y/N default is Y */ ++ int autoMoved; /* if 1 then remove moved ports is Y */ ++ int backUp; /* if 1 then make packages for updatyed ports */ + int forced; /* 1 = forced updates 0 = normal */ + int interactive; /* 0 = non, 1 = interactive */ ++ int log; /* if 1 then enable logging */ + int objIdx; ++ int optionsChanged; /* set by MGPMrUpdate for example to indicate a ports's options just changed */ + int pmMode; /* singlePort Upgrade = 1 multiple upgrade = 0 */ + int resume; /* 0=normal 1=don't create databases*/ + int verbose; +- int log; /* if 1 then enable logging */ +- int backUp; /* if 1 then make packages for updatyed ports */ +- int autoConflicts; /* if 1 then conflicts Y/N default is Y */ +- int autoMoved; /* if 1 then remove moved ports is Y */ + + /* + * misc +@@ -176,7 +177,6 @@ + classDb* strikesDb; + classDir* dir; + classPort* portTree; +- + + } structProperty; + +diff -ruN ../0.3.2/portmanager/portmanager.1 ./portmanager/portmanager.1 +--- ../0.3.2/portmanager/portmanager.1 Fri Nov 4 06:39:26 2005 ++++ ./portmanager/portmanager.1 Sat Nov 5 07:30:34 2005 +@@ -80,7 +80,7 @@ + .sp + .It + \fB\&-ui\fR or \fB\&--upgrade-interactive\fR +- upgrade interactively ++ upgrade in interactive mode asks (y/n/a) before updating each port + .sp + .It + \fB\&-v\fR or \fB\&--version\fR +@@ -104,7 +104,7 @@ + + portmanager x11/gnome2 --log + +-to add/update/repair a single port with logging by forcing all ++to add/update/repair a single port with logging and forcing all + of it's dependencies to be rebuilt + + portmanager x11/gnome2 --log --fix +Binary files ../0.3.2/portmanager-0.3.2.tar.gz and ./portmanager-0.3.2.tar.gz differ +Binary files ../0.3.2/portmanager-0.3.3.tar.gz and ./portmanager-0.3.3.tar.gz differ +diff -ruN ../0.3.2/programmer-notes.txt ./programmer-notes.txt +--- ../0.3.2/programmer-notes.txt Fri Nov 4 08:47:05 2005 ++++ ./programmer-notes.txt Sat Nov 5 09:19:08 2005 +@@ -2,17 +2,13 @@ + + Must do before releasing + +- (yes/no/auto yes to all) [y/n/a] [y] +- a) moved ports +- b) ui +- c) conflicts +- + auto stop/start of programs? + dual origin + move database files to /var/db/portmanager + test in 6.0 +- update web site ++ use signal to shutdown with <ctl> c + valgrind clean ++c/w (yes/no/auto yes to all) [y/n/a] [y] + c/w --resume option for forced modes + c/w -sl + c/w -slid +@@ -29,6 +25,7 @@ + c/w test moved ports + c/w three strikes + c/w update man pages ++c/w update web site + + portmanager.c - passes argv, arc to MGPMrCommandLine.c + --- portmanager-0.3.2_1.diff ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20051106153400.41924130C22>