Commit dcf6e50d authored by unknown's avatar unknown

New Windows source package automation for 3.23


VC++Files/InstallShield/3.23.XX-com/Component Definitions/.fgl:
  mvdir
VC++Files/InstallShield/3.23.XX-com/Component Definitions/Default.cdf:
  mvdir
VC++Files/InstallShield/3.23.XX-com/Component Definitions/Default.fgl:
  mvdir
VC++Files/InstallShield/3.23.XX-com/File Groups/Clients and Tools.fgl:
  mvdir
VC++Files/InstallShield/3.23.XX-com/File Groups/Default.fdf:
  mvdir
VC++Files/InstallShield/3.23.XX-com/File Groups/Default.fgl:
  mvdir
VC++Files/InstallShield/3.23.XX-com/File Groups/Development.fgl:
  mvdir
VC++Files/InstallShield/3.23.XX-com/File Groups/Documentation.fgl:
  mvdir
VC++Files/InstallShield/3.23.XX-com/File Groups/Grant Tables.fgl:
  mvdir
VC++Files/InstallShield/3.23.XX-com/File Groups/Servers.fgl:
  mvdir
VC++Files/InstallShield/3.23.XX-com/MySQL 3.23.com.ipr:
  mvdir
VC++Files/InstallShield/3.23.XX-com/Registry Entries/Default.rge:
  mvdir
VC++Files/InstallShield/3.23.XX-com/Script Files/Setup.dbg:
  mvdir
VC++Files/InstallShield/3.23.XX-com/Script Files/Setup.ino:
  mvdir
VC++Files/InstallShield/3.23.XX-com/Script Files/Setup.ins:
  mvdir
VC++Files/InstallShield/3.23.XX-com/Script Files/Setup.obs:
  mvdir
VC++Files/InstallShield/3.23.XX-com/Script Files/Setup.rul:
  mvdir
VC++Files/InstallShield/3.23.XX-com/Setup Files/Uncompressed Files/Language Independent/OS Independent/SETUP.BMP:
  mvdir
VC++Files/InstallShield/3.23.XX-com/Shell Objects/Default.shl:
  mvdir
VC++Files/InstallShield/3.23.XX-com/String Tables/Default.shl:
  mvdir
VC++Files/InstallShield/3.23.XX-com/Text Substitutions/Build.tsb:
  mvdir
VC++Files/InstallShield/3.23.XX-com/Text Substitutions/Setup.tsb:
  mvdir
VC++Files/InstallShield/3.23.XX-com/Setup Files/Compressed Files/Language Independent/OS Independent/infolist.txt:
  Add version placeholders for automation
VC++Files/InstallShield/3.23.XX-com/String Tables/0009-English/value.shl:
  Add version placeholders for automation
VC++Files/InstallShield/3.23.XX-gpl/Setup Files/Compressed Files/Language Independent/OS Independent/infolist.txt:
  Add version placeholders for automation
VC++Files/InstallShield/3.23.XX-gpl/String Tables/0009-English/value.shl:
  Add version placeholders for automation
scripts/Makefile.am:
  Build make_win_src_distribution script by default
BitKeeper/etc/logging_ok:
  Logging to logging@openlogging.org accepted
parent 8cc642d7
......@@ -6,6 +6,7 @@ bar@bar.udmsearch.izhnet.ru
bell@sanja.is.com.ua
bk@admin.bk
greg@gcw.ath.cx
greg@mysql.com
guilhem@mysql.com
heikki@donna.mysql.fi
heikki@hundin.mysql.fi
......
This is a release of MySQL 3.23.56 for Win32.
This is a release of MySQL @VERSION@ for Win32.
NOTE: If you install MySQL in a folder other than
C:\MYSQL or you intend to start MySQL on NT/Win2000
......
[Data]
TITLE_MAIN=MySQL Commercial Servers and Clients 3.23.56
TITLE_MAIN=MySQL Commercial Servers and Clients @VERSION@
ERROR_COMPONENT=Component:
COMPANY_NAME=MySQL AB
COMPANY_NAME16=Company
ERROR_FILEGROUP=File Group:
ERROR_MOVEDATA=An error occurred during the move data process: %d
PRODUCT_VERSION=3.23.56
UNINST_KEY=MySQL Commercial Servers and Clients 3.23.56
TITLE_CAPTIONBAR=MySQL Commercial Servers and Clients 3.23.56 Setup
PRODUCT_VERSION=@VERSION@
UNINST_KEY=MySQL Commercial Servers and Clients @VERSION@
TITLE_CAPTIONBAR=MySQL Commercial Servers and Clients @VERSION@ Setup
PRODUCT_NAME16=Product
ERROR_FILE=File:
ERROR_VGARESOLUTION=This program requires VGA or better resolution.
PRODUCT_KEY=yourapp.Exe
UNINST_DISPLAY_NAME=MySQL Commercial Servers and Clients 3.23.56
UNINST_DISPLAY_NAME=MySQL Commercial Servers and Clients @VERSION@
ERROR_UNINSTSETUP=unInstaller setup failed to initialize. You may not be able to uninstall this product.
PRODUCT_NAME=MySQL Commercial Servers and Clients 3.23.56
PRODUCT_NAME=MySQL Commercial Servers and Clients @VERSION@
[General]
Language=0009
......
This is a release of MySQL 3.23.56 for Win32.
This is a release of MySQL @VERSION@ for Win32.
NOTE: If you install MySQL in a folder other than
C:\MYSQL or you intend to start MySQL on NT/Win2000
......
[Data]
TITLE_MAIN=MySQL Servers and Clients 3.23.56
TITLE_MAIN=MySQL Servers and Clients @VERSION@
COMPANY_NAME=MySQL AB
ERROR_COMPONENT=Component:
COMPANY_NAME16=Company
PRODUCT_VERSION=3.23.56
PRODUCT_VERSION=@VERSION@
ERROR_MOVEDATA=An error occurred during the move data process: %d
ERROR_FILEGROUP=File Group:
UNINST_KEY=MySQL Servers and Clients 3.23.56
TITLE_CAPTIONBAR=MySQL Servers and Clients 3.23.56 Setup
UNINST_KEY=MySQL Servers and Clients @VERSION@
TITLE_CAPTIONBAR=MySQL Servers and Clients @VERSION@ Setup
PRODUCT_NAME16=Product
ERROR_VGARESOLUTION=This program requires VGA or better resolution.
ERROR_FILE=File:
UNINST_DISPLAY_NAME=MySQL Servers and Clients 3.23.56
UNINST_DISPLAY_NAME=MySQL Servers and Clients @VERSION@
PRODUCT_KEY=yourapp.Exe
PRODUCT_NAME=MySQL Servers and Clients 3.23.56
PRODUCT_NAME=MySQL Servers and Clients @VERSION@
ERROR_UNINSTSETUP=unInstaller setup failed to initialize. You may not be able to uninstall this product.
[General]
......
LIBRARY LIBMYSQL
DESCRIPTION 'MySQL 3.23 Client Library'
VERSION 2.5
EXPORTS
mysql_affected_rows
mysql_close
mysql_connect
mysql_create_db
mysql_data_seek
mysql_debug
mysql_drop_db
mysql_dump_debug_info
mysql_eof
mysql_errno
mysql_error
mysql_escape_string
mysql_fetch_field
mysql_fetch_field_direct
mysql_fetch_fields
mysql_fetch_lengths
mysql_fetch_row
mysql_field_count
mysql_field_seek
mysql_field_tell
mysql_free_result
mysql_get_client_info
mysql_get_host_info
mysql_get_proto_info
mysql_get_server_info
mysql_info
mysql_init
mysql_insert_id
mysql_kill
mysql_list_dbs
mysql_list_fields
mysql_list_processes
mysql_list_tables
mysql_num_fields
mysql_num_rows
mysql_odbc_escape_string
mysql_options
mysql_ping
mysql_query
mysql_real_connect
mysql_real_query
mysql_refresh
mysql_row_seek
mysql_row_tell
mysql_select_db
mysql_shutdown
mysql_stat
mysql_store_result
mysql_thread_id
mysql_use_result
bmove_upp
delete_dynamic
_dig_vec
init_dynamic_array
insert_dynamic
int2str
is_prefix
list_add
list_delete
max_allowed_packet
my_casecmp
my_init
my_end
my_strdup
my_malloc
my_memdup
my_no_flags_free
my_realloc
my_thread_end
my_thread_init
net_buffer_length
set_dynamic
strcend
strdup_root
strfill
strinstr
strmake
strmov
strxmov
myodbc_remove_escape
mysql_thread_safe
mysql_character_set_name
mysql_change_user
mysql_send_query
mysql_read_query_result
mysql_real_escape_string
load_defaults
free_defaults
/*C4*/
/****************************************************************/
/* Author: Jethro Wright, III TS : 3/ 4/1998 9:15 */
/* Date: 02/18/1998 */
/* mytest.c : do some testing of the libmySQL.DLL.... */
/* */
/* History: */
/* 02/18/1998 jw3 also sprach zarathustra.... */
/****************************************************************/
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <mysql.h>
#define DEFALT_SQL_STMT "SELECT * FROM db"
#ifndef offsetof
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif
/********************************************************
**
** main :-
**
********************************************************/
int
main( int argc, char * argv[] )
{
char szSQL[ 200 ], aszFlds[ 25 ][ 25 ], * pszT, szDB[ 50 ] ;
int i, j, k, l, x ;
MYSQL * myData ;
MYSQL_RES * res ;
MYSQL_FIELD * fd ;
MYSQL_ROW row ;
//....just curious....
printf( "sizeof( MYSQL ) == %d\n", sizeof( MYSQL ) ) ;
if ( argc == 2 )
{
strcpy( szDB, argv[ 1 ] ) ;
strcpy( szSQL, DEFALT_SQL_STMT ) ;
if (!strcmp(szDB,"--debug"))
{
strcpy( szDB, "mysql" ) ;
printf("Some mysql struct information (size and offset):\n");
printf("net:\t%3d %3d\n",sizeof(myData->net),offsetof(MYSQL,net));
printf("host:\t%3d %3d\n",sizeof(myData->host),offsetof(MYSQL,host));
printf("port:\t%3d %3d\n",sizeof(myData->port),offsetof(MYSQL,port));
printf("protocol_version:\t%3d %3d\n",sizeof(myData->protocol_version),
offsetof(MYSQL,protocol_version));
printf("thread_id:\t%3d %3d\n",sizeof(myData->thread_id),
offsetof(MYSQL,thread_id));
printf("affected_rows:\t%3d %3d\n",sizeof(myData->affected_rows),
offsetof(MYSQL,affected_rows));
printf("packet_length:\t%3d %3d\n",sizeof(myData->packet_length),
offsetof(MYSQL,packet_length));
printf("status:\t%3d %3d\n",sizeof(myData->status),
offsetof(MYSQL,status));
printf("fields:\t%3d %3d\n",sizeof(myData->fields),
offsetof(MYSQL,fields));
printf("field_alloc:\t%3d %3d\n",sizeof(myData->field_alloc),
offsetof(MYSQL,field_alloc));
printf("free_me:\t%3d %3d\n",sizeof(myData->free_me),
offsetof(MYSQL,free_me));
printf("options:\t%3d %3d\n",sizeof(myData->options),
offsetof(MYSQL,options));
puts("");
}
}
else if ( argc > 2 ) {
strcpy( szDB, argv[ 1 ] ) ;
strcpy( szSQL, argv[ 2 ] ) ;
}
else {
strcpy( szDB, "mysql" ) ;
strcpy( szSQL, DEFALT_SQL_STMT ) ;
}
//....
if ( (myData = mysql_init((MYSQL*) 0)) &&
mysql_real_connect( myData, NULL, NULL, NULL, NULL, MYSQL_PORT,
NULL, 0 ) )
{
if ( mysql_select_db( myData, szDB ) < 0 ) {
printf( "Can't select the %s database !\n", szDB ) ;
mysql_close( myData ) ;
return 2 ;
}
}
else {
printf( "Can't connect to the mysql server on port %d !\n",
MYSQL_PORT ) ;
mysql_close( myData ) ;
return 1 ;
}
//....
if ( ! mysql_query( myData, szSQL ) ) {
res = mysql_store_result( myData ) ;
i = (int) mysql_num_rows( res ) ; l = 1 ;
printf( "Query: %s\nNumber of records found: %ld\n", szSQL, i ) ;
//....we can get the field-specific characteristics here....
for ( x = 0 ; fd = mysql_fetch_field( res ) ; x++ )
strcpy( aszFlds[ x ], fd->name ) ;
//....
while ( row = mysql_fetch_row( res ) ) {
j = mysql_num_fields( res ) ;
printf( "Record #%ld:-\n", l++ ) ;
for ( k = 0 ; k < j ; k++ )
printf( " Fld #%d (%s): %s\n", k + 1, aszFlds[ k ],
(((row[k]==NULL)||(!strlen(row[k])))?"NULL":row[k])) ;
puts( "==============================\n" ) ;
}
mysql_free_result( res ) ;
}
else printf( "Couldn't execute %s on the server !\n", szSQL ) ;
//....
puts( "==== Diagnostic info ====" ) ;
pszT = mysql_get_client_info() ;
printf( "Client info: %s\n", pszT ) ;
//....
pszT = mysql_get_host_info( myData ) ;
printf( "Host info: %s\n", pszT ) ;
//....
pszT = mysql_get_server_info( myData ) ;
printf( "Server info: %s\n", pszT ) ;
//....
res = mysql_list_processes( myData ) ; l = 1 ;
if (res)
{
for ( x = 0 ; fd = mysql_fetch_field( res ) ; x++ )
strcpy( aszFlds[ x ], fd->name ) ;
while ( row = mysql_fetch_row( res ) ) {
j = mysql_num_fields( res ) ;
printf( "Process #%ld:-\n", l++ ) ;
for ( k = 0 ; k < j ; k++ )
printf( " Fld #%d (%s): %s\n", k + 1, aszFlds[ k ],
(((row[k]==NULL)||(!strlen(row[k])))?"NULL":row[k])) ;
puts( "==============================\n" ) ;
}
}
else
{
printf("Got error %s when retreiving processlist\n",mysql_error(myData));
}
//....
res = mysql_list_tables( myData, "%" ) ; l = 1 ;
for ( x = 0 ; fd = mysql_fetch_field( res ) ; x++ )
strcpy( aszFlds[ x ], fd->name ) ;
while ( row = mysql_fetch_row( res ) ) {
j = mysql_num_fields( res ) ;
printf( "Table #%ld:-\n", l++ ) ;
for ( k = 0 ; k < j ; k++ )
printf( " Fld #%d (%s): %s\n", k + 1, aszFlds[ k ],
(((row[k]==NULL)||(!strlen(row[k])))?"NULL":row[k])) ;
puts( "==============================\n" ) ;
}
//....
pszT = mysql_stat( myData ) ;
puts( pszT ) ;
//....
mysql_close( myData ) ;
return 0 ;
}
/****************************************************************************
MySqlShutdown - shutdown MySQL on system shutdown (Win95/98)
----------------------------------------------------------------------------
Revision History :
Version Author Date Description
001.00 Irena 21-12-99
*****************************************************************************/
#include <windows.h>
//-----------------------------------------------------------------------
// Local data
//-----------------------------------------------------------------------
static char szAppName[] = "MySqlShutdown";
static HINSTANCE hInstance;
#define MYWM_NOTIFYICON (WM_APP+100)
//-----------------------------------------------------------------------
// Exported functions
//-----------------------------------------------------------------------
LRESULT CALLBACK MainWindowProc (HWND, UINT, WPARAM, LPARAM);
//-----------------------------------------------------------------------
// Local functions
//-----------------------------------------------------------------------
static BOOL InitAppClass (HINSTANCE hInstance);
BOOL TrayMessageAdd(HWND hWnd, DWORD dwMessage)
{
BOOL res;
HICON hIcon =LoadIcon (hInstance, "MySql");
char *szTip="MySql Shutdown";
NOTIFYICONDATA tnd;
tnd.cbSize = sizeof(NOTIFYICONDATA);
tnd.hWnd = hWnd;
tnd.uID = 101;
tnd.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP;
tnd.uCallbackMessage = MYWM_NOTIFYICON;
tnd.hIcon = hIcon;
strcpy(tnd.szTip, szTip);
res = Shell_NotifyIcon(dwMessage, &tnd);
if (hIcon) DestroyIcon(hIcon);
return res;
}
//-----------------------------------------------------------------------
// Name: WinMain
// Purpose: Main application entry point
//-----------------------------------------------------------------------
int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
{ HWND hWnd;
MSG Msg;
hInstance=hInst;
// Register application class if needed
if (InitAppClass (hInstance) == FALSE) return (0);
hWnd = CreateWindow (szAppName, "MySql",
WS_OVERLAPPEDWINDOW|WS_MINIMIZE,
0, 0,
GetSystemMetrics(SM_CXSCREEN)/4,
GetSystemMetrics(SM_CYSCREEN)/4,
0, 0, hInstance, NULL);
if(!hWnd)
{
return (0);
}
ShowWindow (hWnd, SW_HIDE);
UpdateWindow (hWnd);
while (GetMessage (&Msg, 0, 0, 0))
{ TranslateMessage (&Msg);
DispatchMessage (&Msg);
}
return ((int) (Msg.wParam));
}
//-----------------------------------------------------------------------
// Name: InitAppClass
// Purpose: Register the main application window class
//-----------------------------------------------------------------------
static BOOL InitAppClass (HINSTANCE hInstance)
{
WNDCLASS cls;
if (GetClassInfo (hInstance, szAppName, &cls) == 0)
{
cls.style = CS_HREDRAW | CS_VREDRAW ;;
cls.lpfnWndProc = (WNDPROC) MainWindowProc;
cls.cbClsExtra = 0;
cls.cbWndExtra = sizeof(HWND);
cls.hInstance = hInstance;
cls.hIcon = LoadIcon (hInstance, "MySql");
cls.hCursor = LoadCursor (NULL, IDC_ARROW);
cls.hbrBackground = GetStockObject (WHITE_BRUSH) ;
cls.lpszMenuName = 0; //szAppName;
cls.lpszClassName = szAppName;
return RegisterClass (&cls);
}
return (TRUE);
}
//-----------------------------------------------------------------------
// Name: MainWindowProc
// Purpose: Window procedure for main application window.
//-----------------------------------------------------------------------
LRESULT CALLBACK MainWindowProc (HWND hWnd, UINT Msg,WPARAM wParam, LPARAM lParam)
{
static RECT rect ;
HDC hdc ;
PAINTSTRUCT ps ;
static BOOL bShutdown=FALSE;
switch (Msg)
{
case WM_CREATE:
TrayMessageAdd(hWnd, NIM_ADD);
return TRUE;
/***************
case WM_SYSCOMMAND:
if(wParam==SC_CLOSE)
{ HANDLE hEventShutdown;
bShutdown=TRUE;
InvalidateRect(hWnd,NULL,TRUE);
ShowWindow (hWnd, SW_NORMAL);
UpdateWindow(hWnd);
hEventShutdown=OpenEvent(EVENT_MODIFY_STATE, 0, "MySqlShutdown");
if(hEventShutdown)
{
SetEvent(hEventShutdown);
CloseHandle(hEventShutdown);
Sleep(1000);
MessageBox(hWnd,"Shutdown", "MySql", MB_OK);
}
TrayMessageAdd(hWnd, NIM_DELETE);
}
break;
**************/
case WM_DESTROY:
TrayMessageAdd(hWnd, NIM_DELETE);
PostQuitMessage (0);
return 0;
case WM_SIZE:
GetClientRect (hWnd, &rect) ;
return 0 ;
case WM_PAINT:
hdc = BeginPaint (hWnd, &ps) ;
if(bShutdown)
DrawText (hdc, "MySql shutdown in progress...",
-1, &rect, DT_WORDBREAK) ;
EndPaint (hWnd, &ps) ;
return 0 ;
case WM_QUERYENDSESSION: //Shutdown MySql
{ HANDLE hEventShutdown;
bShutdown=TRUE;
InvalidateRect(hWnd,NULL,TRUE);
ShowWindow (hWnd, SW_NORMAL);
UpdateWindow(hWnd);
hEventShutdown=OpenEvent(EVENT_MODIFY_STATE, 0, "MySqlShutdown");
if(hEventShutdown)
{
SetEvent(hEventShutdown);
CloseHandle(hEventShutdown);
Sleep(1000);
MessageBox(hWnd,"Shutdown", "MySql", MB_OK);
}
}
return 1;
case MYWM_NOTIFYICON:
switch (lParam)
{
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
ShowWindow(hWnd, SW_SHOWNORMAL);
SetForegroundWindow(hWnd); // make us come to the front
break;
default:
break;
}
break;
}
return DefWindowProc (hWnd, Msg, wParam, lParam);
}
// ----------------------- The end ------------------------------------------
MySql ICON DISCARDABLE "MYSQL.ICO"
/****************************************************************************
MySqlWatch - WinNT service program MySQL
- Re-start MySql server in case of failure
*****************************************************************************/
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <process.h>
#include <tchar.h>
// name of the executable
#define SZAPPNAME "mysqlwatch"
// internal name of the service
#define SZSERVICENAME "MySqlWatch"
// displayed name of the service
#define SZSERVICEDISPLAYNAME "MySqlWatch"
// list of service dependencies - "dep1\0dep2\0\0"
#define SZDEPENDENCIES ""
VOID ServiceStart(DWORD dwArgc, LPTSTR *lpszArgv);
VOID ServiceStop(void);
BOOL ReportStatusToSCMgr(DWORD dwCurrentState, DWORD dwWin32ExitCode, DWORD dwWaitHint);
void AddToMessageLog(LPTSTR lpszMsg);
// internal variables
SERVICE_STATUS ssStatus; // current status of the service
SERVICE_STATUS_HANDLE sshStatusHandle;
DWORD dwErr = 0;
BOOL bDebug = FALSE;
TCHAR szErr[256];
// internal function prototypes
void WINAPI service_ctrl(DWORD dwCtrlCode);
void WINAPI service_main(DWORD dwArgc, LPTSTR *lpszArgv);
void CmdInstallService(void);
void CmdRemoveService(void);
void CmdDebugService(int argc, char **argv);
BOOL WINAPI ControlHandler ( DWORD dwCtrlType );
LPTSTR GetLastErrorText( LPTSTR lpszBuf, DWORD dwSize );
//
// FUNCTION: main
//
// PURPOSE: entrypoint for service
//
// PARAMETERS:
// argc - number of command line arguments
// argv - array of command line arguments
//
// RETURN VALUE:
// none
//
// COMMENTS:
// main() either performs the command line task, or
// call StartServiceCtrlDispatcher to register the
// main service thread. When the this call returns,
// the service has stopped, so exit.
//
void main(int argc, char **argv)
{
SERVICE_TABLE_ENTRY dispatchTable[] =
{
{ TEXT(SZSERVICENAME), (LPSERVICE_MAIN_FUNCTION)service_main },
{ NULL, NULL }
};
if ( (argc > 1) &&
((*argv[1] == '-') || (*argv[1] == '/')) )
{
if ( stricmp( "install", argv[1]+1 ) == 0 )
{
CmdInstallService();
}
else if ( stricmp( "remove", argv[1]+1 ) == 0 )
{
CmdRemoveService();
}
else if ( stricmp( "debug", argv[1]+1 ) == 0 )
{
bDebug = TRUE;
CmdDebugService(argc, argv);
}
else
{
goto dispatch;
}
exit(0);
}
// if it doesn't match any of the above parameters
// the service control manager may be starting the service
// so we must call StartServiceCtrlDispatcher
dispatch:
// this is just to be friendly
printf( "%s -install to install the service\n", SZAPPNAME );
printf( "%s -remove to remove the service\n", SZAPPNAME );
printf( "%s -debug <params> to run as a console app for debugging\n", SZAPPNAME );
printf( "\nStartServiceCtrlDispatcher being called.\n" );
printf( "This may take several seconds. Please wait.\n" );
if (!StartServiceCtrlDispatcher(dispatchTable))
AddToMessageLog(TEXT("StartServiceCtrlDispatcher failed."));
}
//
// FUNCTION: service_main
//
// PURPOSE: To perform actual initialization of the service
//
// PARAMETERS:
// dwArgc - number of command line arguments
// lpszArgv - array of command line arguments
//
// RETURN VALUE:
// none
//
// COMMENTS:
// This routine performs the service initialization and then calls
// the user defined ServiceStart() routine to perform majority
// of the work.
//
void WINAPI service_main(DWORD dwArgc, LPTSTR *lpszArgv)
{
// register our service control handler:
//
sshStatusHandle = RegisterServiceCtrlHandler( TEXT(SZSERVICENAME), service_ctrl);
if (!sshStatusHandle)
goto cleanup;
// SERVICE_STATUS members that don't change in example
//
ssStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
ssStatus.dwServiceSpecificExitCode = 0;
// report the status to the service control manager.
//
if (!ReportStatusToSCMgr(
SERVICE_START_PENDING, // service state
NO_ERROR, // exit code
3000)) // wait hint
goto cleanup;
ServiceStart( dwArgc, lpszArgv );
cleanup:
// try to report the stopped status to the service control manager.
//
if (sshStatusHandle)
ReportStatusToSCMgr(
SERVICE_STOPPED,
dwErr,
0);
return;
}
//
// FUNCTION: service_ctrl
//
// PURPOSE: This function is called by the SCM whenever
// ControlService() is called on this service.
//
// PARAMETERS:
// dwCtrlCode - type of control requested
//
// RETURN VALUE:
// none
//
// COMMENTS:
//
void WINAPI service_ctrl(DWORD dwCtrlCode)
{
// Handle the requested control code.
//
switch(dwCtrlCode)
{
// Stop the service.
//
case SERVICE_CONTROL_STOP:
ssStatus.dwCurrentState = SERVICE_STOP_PENDING;
ServiceStop();
break;
// Update the service status.
//
case SERVICE_CONTROL_INTERROGATE:
break;
// invalid control code
//
default:
break;
}
ReportStatusToSCMgr(ssStatus.dwCurrentState, NO_ERROR, 0);
}
//
// FUNCTION: ReportStatusToSCMgr()
//
// PURPOSE: Sets the current status of the service and
// reports it to the Service Control Manager
//
// PARAMETERS:
// dwCurrentState - the state of the service
// dwWin32ExitCode - error code to report
// dwWaitHint - worst case estimate to next checkpoint
//
// RETURN VALUE:
// TRUE - success
// FALSE - failure
//
// COMMENTS:
//
BOOL ReportStatusToSCMgr(DWORD dwCurrentState,
DWORD dwWin32ExitCode,
DWORD dwWaitHint)
{
static DWORD dwCheckPoint = 1;
BOOL fResult = TRUE;
if ( !bDebug ) // when debugging we don't report to the SCM
{
if (dwCurrentState == SERVICE_START_PENDING)
ssStatus.dwControlsAccepted = 0;
else
ssStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
ssStatus.dwCurrentState = dwCurrentState;
ssStatus.dwWin32ExitCode = dwWin32ExitCode;
ssStatus.dwWaitHint = dwWaitHint;
if ( ( dwCurrentState == SERVICE_RUNNING ) ||
( dwCurrentState == SERVICE_STOPPED ) )
ssStatus.dwCheckPoint = 0;
else
ssStatus.dwCheckPoint = dwCheckPoint++;
// Report the status of the service to the service control manager.
//
if (!(fResult = SetServiceStatus( sshStatusHandle, &ssStatus))) {
AddToMessageLog(TEXT("SetServiceStatus"));
}
}
return fResult;
}
//
// FUNCTION: AddToMessageLog(LPTSTR lpszMsg)
//
// PURPOSE: Allows any thread to log an error message
//
// PARAMETERS:
// lpszMsg - text for message
//
// RETURN VALUE:
// none
//
// COMMENTS:
//
void AddToMessageLog(LPTSTR lpszMsg)
{
TCHAR szMsg[256];
HANDLE hEventSource;
LPTSTR lpszStrings[2];
if ( !bDebug )
{
dwErr = GetLastError();
// Use event logging to log the error.
//
hEventSource = RegisterEventSource(NULL, TEXT(SZSERVICENAME));
_stprintf(szMsg, TEXT("%s error: %d"), TEXT(SZSERVICENAME), dwErr);
lpszStrings[0] = szMsg;
lpszStrings[1] = lpszMsg;
if (hEventSource != NULL) {
ReportEvent(hEventSource, // handle of event source
EVENTLOG_ERROR_TYPE, // event type
0, // event category
0, // event ID
NULL, // current user's SID
2, // strings in lpszStrings
0, // no bytes of raw data
lpszStrings, // array of error strings
NULL); // no raw data
DeregisterEventSource(hEventSource);
}
}
}
///////////////////////////////////////////////////////////////////
//
// The following code handles service installation and removal
//
//
// FUNCTION: CmdInstallService()
//
// PURPOSE: Installs the service
//
// PARAMETERS:
// none
//
// RETURN VALUE:
// none
//
// COMMENTS:
//
void CmdInstallService()
{
SC_HANDLE schService;
SC_HANDLE schSCManager;
TCHAR szPath[512];
if ( GetModuleFileName( NULL, szPath, 512 ) == 0 )
{
_tprintf(TEXT("Unable to install %s - %s\n"), TEXT(SZSERVICEDISPLAYNAME), GetLastErrorText(szErr, 256));
return;
}
schSCManager = OpenSCManager(
NULL, // machine (NULL == local)
NULL, // database (NULL == default)
SC_MANAGER_ALL_ACCESS // access required
);
if ( schSCManager )
{
schService = CreateService(
schSCManager, // SCManager database
TEXT(SZSERVICENAME), // name of service
TEXT(SZSERVICEDISPLAYNAME), // name to display
SERVICE_ALL_ACCESS, // desired access
SERVICE_WIN32_OWN_PROCESS, // service type
SERVICE_DEMAND_START, // start type
SERVICE_ERROR_NORMAL, // error control type
szPath, // service's binary
NULL, // no load ordering group
NULL, // no tag identifier
TEXT(SZDEPENDENCIES), // dependencies
NULL, // LocalSystem account
NULL); // no password
if ( schService )
{
_tprintf(TEXT("%s installed.\n"), TEXT(SZSERVICEDISPLAYNAME) );
CloseServiceHandle(schService);
}
else
{
_tprintf(TEXT("CreateService failed - %s\n"), GetLastErrorText(szErr, 256));
}
CloseServiceHandle(schSCManager);
}
else
_tprintf(TEXT("OpenSCManager failed - %s\n"), GetLastErrorText(szErr,256));
}
//
// FUNCTION: CmdRemoveService()
//
// PURPOSE: Stops and removes the service
//
// PARAMETERS:
// none
//
// RETURN VALUE:
// none
//
// COMMENTS:
//
void CmdRemoveService()
{
SC_HANDLE schService;
SC_HANDLE schSCManager;
schSCManager = OpenSCManager(
NULL, // machine (NULL == local)
NULL, // database (NULL == default)
SC_MANAGER_ALL_ACCESS // access required
);
if ( schSCManager )
{
schService = OpenService(schSCManager, TEXT(SZSERVICENAME), SERVICE_ALL_ACCESS);
if (schService)
{
// try to stop the service
if ( ControlService( schService, SERVICE_CONTROL_STOP, &ssStatus ) )
{
_tprintf(TEXT("Stopping %s."), TEXT(SZSERVICEDISPLAYNAME));
Sleep( 1000 );
while( QueryServiceStatus( schService, &ssStatus ) )
{
if ( ssStatus.dwCurrentState == SERVICE_STOP_PENDING )
{
_tprintf(TEXT("."));
Sleep( 1000 );
}
else
break;
}
if ( ssStatus.dwCurrentState == SERVICE_STOPPED )
_tprintf(TEXT("\n%s stopped.\n"), TEXT(SZSERVICEDISPLAYNAME) );
else
_tprintf(TEXT("\n%s failed to stop.\n"), TEXT(SZSERVICEDISPLAYNAME) );
}
// now remove the service
if( DeleteService(schService) )
_tprintf(TEXT("%s removed.\n"), TEXT(SZSERVICEDISPLAYNAME) );
else
_tprintf(TEXT("DeleteService failed - %s\n"), GetLastErrorText(szErr,256));
CloseServiceHandle(schService);
}
else
_tprintf(TEXT("OpenService failed - %s\n"), GetLastErrorText(szErr,256));
CloseServiceHandle(schSCManager);
}
else
_tprintf(TEXT("OpenSCManager failed - %s\n"), GetLastErrorText(szErr,256));
}
//
// FUNCTION: CmdRestartService()
//
// PURPOSE: Stops and removes the service
//
// PARAMETERS:
// none
//
// RETURN VALUE:
// none
//
// COMMENTS:
//
void CmdRestartService(char *szServiceName)
{
SC_HANDLE schService;
SC_HANDLE schSCManager;
schSCManager = OpenSCManager(
NULL, // machine (NULL == local)
NULL, // database (NULL == default)
SC_MANAGER_ALL_ACCESS // access required
);
if ( schSCManager )
{
schService = OpenService(schSCManager, TEXT(szServiceName), SERVICE_ALL_ACCESS);
if (schService)
{
if(! ControlService( schService, SERVICE_CONTROL_INTERROGATE, &ssStatus ) )
//if(QueryServiceStatus( schService, &ssStatus )==0)
{
if(GetLastError()==ERROR_SERVICE_NOT_ACTIVE)
{
//AddToMessageLog(TEXT("Start service..."));
StartService( schService, 0,NULL);
}
else
{ ;
//AddToMessageLog(TEXT("QueryService..."));
//AddToMessageLog(TEXT(GetLastErrorText(szErr,256)));
}
}
CloseServiceHandle(schService);
}
else
{ _tprintf(TEXT("OpenService failed - %s\n"), GetLastErrorText(szErr,256));
AddToMessageLog(TEXT("OpenService..."));
AddToMessageLog(TEXT(GetLastErrorText(szErr,256)));
}
CloseServiceHandle(schSCManager);
}
else
{ _tprintf(TEXT("OpenSCManager failed - %s\n"), GetLastErrorText(szErr,256));
AddToMessageLog(TEXT("OpenSCMManager.."));
}
}
///////////////////////////////////////////////////////////////////
//
// The following code is for running the service as a console app
//
//
// FUNCTION: CmdDebugService(int argc, char ** argv)
//
// PURPOSE: Runs the service as a console application
//
// PARAMETERS:
// argc - number of command line arguments
// argv - array of command line arguments
//
// RETURN VALUE:
// none
//
// COMMENTS:
//
void CmdDebugService(int argc, char ** argv)
{
DWORD dwArgc;
LPTSTR *lpszArgv;
#ifdef UNICODE
lpszArgv = CommandLineToArgvW(GetCommandLineW(), &(dwArgc) );
#else
dwArgc = (DWORD) argc;
lpszArgv = argv;
#endif
_tprintf(TEXT("Debugging %s.\n"), TEXT(SZSERVICEDISPLAYNAME));
SetConsoleCtrlHandler( ControlHandler, TRUE );
ServiceStart( dwArgc, lpszArgv );
}
//
// FUNCTION: ControlHandler ( DWORD dwCtrlType )
//
// PURPOSE: Handled console control events
//
// PARAMETERS:
// dwCtrlType - type of control event
//
// RETURN VALUE:
// True - handled
// False - unhandled
//
// COMMENTS:
//
BOOL WINAPI ControlHandler ( DWORD dwCtrlType )
{
switch( dwCtrlType )
{
case CTRL_BREAK_EVENT: // use Ctrl+C or Ctrl+Break to simulate
case CTRL_C_EVENT: // SERVICE_CONTROL_STOP in debug mode
_tprintf(TEXT("Stopping %s.\n"), TEXT(SZSERVICEDISPLAYNAME));
ServiceStop();
return TRUE;
break;
}
return FALSE;
}
//
// FUNCTION: GetLastErrorText
//
// PURPOSE: copies error message text to string
//
// PARAMETERS:
// lpszBuf - destination buffer
// dwSize - size of buffer
//
// RETURN VALUE:
// destination buffer
//
// COMMENTS:
//
LPTSTR GetLastErrorText( LPTSTR lpszBuf, DWORD dwSize )
{
DWORD dwRet;
LPTSTR lpszTemp = NULL;
dwRet = FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |FORMAT_MESSAGE_ARGUMENT_ARRAY,
NULL,
GetLastError(),
LANG_NEUTRAL,
(LPTSTR)&lpszTemp,
0,
NULL );
// supplied buffer is not long enough
if ( !dwRet || ( (long)dwSize < (long)dwRet+14 ) )
lpszBuf[0] = TEXT('\0');
else
{
lpszTemp[lstrlen(lpszTemp)-2] = TEXT('\0'); //remove cr and newline character
_stprintf( lpszBuf, TEXT("%s (0x%x)"), lpszTemp, GetLastError() );
}
if ( lpszTemp )
LocalFree((HLOCAL) lpszTemp );
return lpszBuf;
}
//-------------------------------------------------
// this event is signalled when the
// service should end
//-------------------------------------------------
HANDLE hServerStopEvent = NULL;
//-------------------------------------------------
// FUNCTION: ServiceStart
//
// PURPOSE: Actual code of the service
// that does the work.
//-------------------------------------------------
void ServiceStart (DWORD dwArgc, LPTSTR *lpszArgv)
{
DWORD dwWait,dwTimeout=1000*60*1;
if (!ReportStatusToSCMgr(
SERVICE_START_PENDING, // service state
NO_ERROR, // exit code
3000)) // wait hint
goto cleanup;
// create the event object. The control handler function signals
// this event when it receives the "stop" control code.
//
hServerStopEvent = CreateEvent(
NULL, // no security attributes
TRUE, // manual reset event
FALSE, // not-signalled
NULL); // no name
if ( hServerStopEvent == NULL) goto cleanup;
// report the status to the service control manager.
//
if (!ReportStatusToSCMgr(
SERVICE_START_PENDING, // service state
NO_ERROR, // exit code
3000)) // wait hint
goto cleanup;
// report the status to the service control manager.
//
if (!ReportStatusToSCMgr(
SERVICE_START_PENDING, // service state
NO_ERROR, // exit code
3000)) // wait hint
goto cleanup;
// report the status to the service control manager.
//
if (!ReportStatusToSCMgr(
SERVICE_RUNNING, // service state
NO_ERROR, // exit code
0)) // wait hint
goto cleanup;
//
// End of initialization
// Service is now running, perform work until shutdown
//
while ( 1 )
{
dwWait = WaitForSingleObject( hServerStopEvent, dwTimeout);
if(dwWait==WAIT_FAILED)
{
AddToMessageLog(TEXT("Error in WaitForSingleObject"));
break;
}
else if(dwWait==WAIT_TIMEOUT)
{
CmdRestartService("MySql");
}
else
{ break; //shutdown
}
}
cleanup:
if (hServerStopEvent)
CloseHandle(hServerStopEvent);
}
//-------------------------------------------------
// FUNCTION: ServiceStop
//
// PURPOSE: Stops the service
//-------------------------------------------------
void ServiceStop()
{
if ( hServerStopEvent )
SetEvent(hServerStopEvent);
}
//-the end ----------------------------------------
/* Testing of thread creation to find memory allocation bug
** This is coded to use as few extern functions as possible!
**
** The program must be compiled to be multithreaded !
**
** The problem is that when this program is run it will allocate more and more
** memory, so there is a memory leak in the thread handling. The problem is how
** to avoid is !
**
** It looks like the bug is that the std library doesn't free thread
** specific variables if one uses a thread variable.
** If one compiles this program with -DREMOVE_BUG
** there is no memory leaks anymore!
**
** This program is tested with Microsofts VC++ 5.0, but BC5.2 is also
** reported to have this bug.
*/
#include <windows.h>
#include <process.h>
#include <stdio.h>
#define TEST_COUNT 100000
/*****************************************************************************
** The following is to emulate the posix thread interface
*****************************************************************************/
typedef HANDLE pthread_t;
typedef struct thread_attr {
DWORD dwStackSize ;
DWORD dwCreatingFlag ;
int priority ;
} pthread_attr_t ;
typedef struct { int dummy; } pthread_condattr_t;
typedef struct {
unsigned int msg;
pthread_t thread;
DWORD thread_id;
} pthread_cond_t;
typedef CRITICAL_SECTION pthread_mutex_t;
#define pthread_mutex_init(A,B) InitializeCriticalSection(A)
#define pthread_mutex_lock(A) (EnterCriticalSection(A),0)
#define pthread_mutex_unlock(A) LeaveCriticalSection(A)
#define pthread_mutex_destroy(A) DeleteCriticalSection(A)
#define pthread_handler_decl(A,B) unsigned __cdecl A(void *B)
typedef unsigned (__cdecl *pthread_handler)(void *);
#define pthread_self() GetCurrentThread()
static unsigned int thread_count;
static pthread_cond_t COND_thread_count;
static pthread_mutex_t LOCK_thread_count;
pthread_mutex_t THR_LOCK_malloc,THR_LOCK_open,THR_LOCK_keycache,
THR_LOCK_lock,THR_LOCK_isam;
/*
** We have tried to use '_beginthreadex' instead of '_beginthread' here
** but in this case the program leaks about 512 characters for each
** created thread !
*/
int pthread_create(pthread_t *thread_id, pthread_attr_t *attr,
pthread_handler func, void *param)
{
HANDLE hThread;
hThread=(HANDLE)_beginthread(func,
attr->dwStackSize ? attr->dwStackSize :
65535,param);
if ((long) hThread == -1L)
{
return(errno ? errno : -1);
}
*thread_id=hThread;
return(0);
}
void pthread_exit(unsigned A)
{
_endthread();
}
/*
** The following simple implementation of conds works as long as
** only one thread uses pthread_cond_wait at a time.
** This is coded very carefully to work with thr_lock.
*/
static unsigned int WIN32_WAIT_SIGNAL= 30000; /* Start message to use */
int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
{
cond->msg=WIN32_WAIT_SIGNAL++;
cond->thread=(pthread_t) pthread_self(); /* For global conds */
//IRENA
cond->thread_id=GetCurrentThreadId();
return 0;
}
int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
{
MSG msg ;
unsigned int msgCode=cond->msg;
cond->thread=(pthread_t) pthread_self();
//IRENA
//??? cond->thread_id=GetCurrentThreadId();
//VOID(ReleaseMutex(*mutex));
LeaveCriticalSection(mutex);
do
{
WaitMessage() ;
if (!PeekMessage(&msg, NULL, 1, 65534,PM_REMOVE))
{
return errno=GetLastError() ;
}
} while (msg.message != msgCode) ;
EnterCriticalSection(mutex);
return 0 ;
}
int pthread_cond_signal(pthread_cond_t *cond)
{
if (!PostThreadMessage(cond->thread_id, cond->msg, 0,0))
{
return errno=GetLastError() ;
}
return 0 ;
}
int pthread_attr_init(pthread_attr_t *connect_att)
{
connect_att->dwStackSize = 0;
connect_att->dwCreatingFlag = 0;
connect_att->priority = 0;
return 0;
}
int pthread_attr_setstacksize(pthread_attr_t *connect_att,DWORD stack)
{
connect_att->dwStackSize=stack;
return 0;
}
int pthread_attr_setprio(pthread_attr_t *connect_att,int priority)
{
connect_att->priority=priority;
return 0;
}
int pthread_attr_destroy(pthread_attr_t *connect_att)
{
return 0;
}
/* from my_pthread.c */
#ifndef REMOVE_BUG
__declspec(thread) int THR_KEY_my_errno;
int _my_errno(void)
{
return THR_KEY_my_errno;
}
#endif
/*****************************************************************************
** The test program
*****************************************************************************/
pthread_handler_decl(test_thread,arg)
{
pthread_mutex_lock(&LOCK_thread_count);
thread_count--;
pthread_cond_signal(&COND_thread_count); /* Tell main we are ready */
pthread_mutex_unlock(&LOCK_thread_count);
pthread_exit(0);
return 0;
}
int main(int argc,char **argv)
{
pthread_t tid;
pthread_attr_t thr_attr;
int i,error;
if ((error=pthread_cond_init(&COND_thread_count,NULL)))
{
fprintf(stderr,"Got error: %d from pthread_cond_init (errno: %d)",
error,errno);
exit(1);
}
pthread_mutex_init(&LOCK_thread_count,NULL);
if ((error=pthread_attr_init(&thr_attr)))
{
fprintf(stderr,"Got error: %d from pthread_attr_init (errno: %d)",
error,errno);
exit(1);
}
if ((error=pthread_attr_setstacksize(&thr_attr,65536L)))
{
fprintf(stderr,"Got error: %d from pthread_attr_setstacksize (errno: %d)",
error,errno);
exit(1);
}
printf("Init ok. Creating %d threads\n",TEST_COUNT);
for (i=1 ; i <= TEST_COUNT ; i++)
{
int *param= &i;
if ((i % 100) == 0)
{
printf("%8d",i);
fflush(stdout);
}
if ((error=pthread_mutex_lock(&LOCK_thread_count)))
{
fprintf(stderr,"\nGot error: %d from pthread_mutex_lock (errno: %d)",
error,errno);
exit(1);
}
if ((error=pthread_create(&tid,&thr_attr,test_thread,(void*) param)))
{
fprintf(stderr,"\nGot error: %d from pthread_create (errno: %d)\n",
error,errno);
pthread_mutex_unlock(&LOCK_thread_count);
exit(1);
}
thread_count++;
pthread_mutex_unlock(&LOCK_thread_count);
if ((error=pthread_mutex_lock(&LOCK_thread_count)))
fprintf(stderr,"\nGot error: %d from pthread_mutex_lock\n",error);
while (thread_count)
{
if ((error=pthread_cond_wait(&COND_thread_count,&LOCK_thread_count)))
fprintf(stderr,"\nGot error: %d from pthread_cond_wait\n",error);
}
pthread_mutex_unlock(&LOCK_thread_count);
}
pthread_attr_destroy(&thr_attr);
printf("\nend\n");
return 0;
}
......@@ -28,7 +28,8 @@ bin_SCRIPTS = @server_scripts@ \
mysql_find_rows \
mysqlhotcopy \
mysqldumpslow \
mysqld_multi
mysqld_multi \
make_win_src_distribution
EXTRA_SCRIPTS = make_binary_distribution.sh \
msql2mysql.sh \
......@@ -66,7 +67,8 @@ CLEANFILES = @server_scripts@ \
mysql_find_rows \
mysqlhotcopy \
mysqldumpslow \
mysqld_multi
mysqld_multi \
make_win_src_distribution
SUPERCLEANFILES = mysqlbug
......
#!/bin/sh
#
# Script to create a Windows src package
#
version=@VERSION@
export version
SOURCE=`pwd`
CP="cp -p"
DEBUG=0
SILENT=0
SUFFIX=""
DIRNAME=""
OUTTAR="0"
OUTZIP="0"
#
# This script must run from MySQL top directory
#
if [ ! -f scripts/make_win_src_distribution ]; then
echo "ERROR : You must run this script from the MySQL top-level directory"
exit 1
fi
#
# Check for source compilation/configuration
#
if [ ! -f sql/sql_yacc.cc ]; then
echo "ERROR : Sorry, you must run this script after the complete build,"
echo " hope you know what you are trying to do !!"
exit 1
fi
#
# Debug print of the status
#
print_debug()
{
for statement
do
if [ "$DEBUG" = "1" ] ; then
echo $statement
fi
done
}
#
# Usage of the script
#
show_usage()
{
echo "MySQL utility script to create a Windows src package, and it takes"
echo "the following arguments:"
echo ""
echo " --debug Debug, without creating the package"
echo " --tmp Specify the temporary location"
echo " --suffix Suffix name for the package"
echo " --dirname Directory name to copy files (intermediate)"
echo " --silent Do not list verbosely files processed"
echo " --tar Create tar.gz package"
echo " --zip Create zip package"
echo " --help Show this help message"
exit 0
}
#
# Parse the input arguments
#
parse_arguments() {
for arg do
case "$arg" in
--add-tar) ADDTAR=1 ;;
--debug) DEBUG=1;;
--tmp=*) TMP=`echo "$arg" | sed -e "s;--tmp=;;"` ;;
--suffix=*) SUFFIX=`echo "$arg" | sed -e "s;--suffix=;;"` ;;
--dirname=*) DIRNAME=`echo "$arg" | sed -e "s;--dirname=;;"` ;;
--silent) SILENT=1 ;;
--tar) OUTTAR=1 ;;
--zip) OUTZIP=1 ;;
--help) show_usage ;;
*)
echo "Unknown argument '$arg'"
exit 1
;;
esac
done
}
parse_arguments "$@"
#
# Assign the tmp directory if it was set from the environment variables
#
for i in $TMP $TMPDIR $TEMPDIR $TEMP /tmp
do
if [ "$i" ]; then
print_debug "Setting TMP to '$i'"
TMP=$i
break
fi
done
#
# Convert argument file from unix to DOS text
#
unix_to_dos()
{
for arg do
print_debug "Replacing LF -> CRLF from '$arg'"
cat $arg | awk '{sub(/$/,"\r");print}' > $arg.tmp
rm -f $arg
mv $arg.tmp $arg
done
}
#
# Create a tmp dest directory to copy files
#
BASE=$TMP/my_win_dist$SUFFIX
if [ -d $BASE ] ; then
print_debug "Destination directory '$BASE' already exists, deleting it"
rm -r -f $BASE
fi
$CP -r $SOURCE/VC++Files $BASE
(
find $BASE \( -name "*.dsp" -o -name "*.dsw" \) -and -not -path \*SCCS\* -print
)|(
while read v
do
unix_to_dos $v
done
)
#
# Process version tags in InstallShield files
#
vreplace()
{
for arg do
unix_to_dos $arg
cat $arg | sed -e 's!@''VERSION''@!3.23.58!' > $arg.tmp
rm -f $arg
mv $arg.tmp $arg
done
}
for d in 3.23.XX-gpl 3.23.XX-com
do
cd $BASE/InstallShield/$d/String\ Tables/0009-English
vreplace value.shl
cd ../../Setup\ Files/Compressed\ Files/Language\ Independent/OS\ Independent
vreplace infolist.txt
done
#
# Move all error message files to root directory
#
$CP -r $SOURCE/sql/share $BASE/
rm -r -f "$BASE/share/Makefile"
rm -r -f "$BASE/share/Makefile.in"
rm -r -f "$BASE/share/Makefile.am"
#
# Clean up if we did this from a bk tree
#
if [ -d $BASE/SCCS ]
then
find $BASE/ -type d -name SCCS -printf " \"%p\"" | xargs rm -r -f
fi
mkdir $BASE/Docs $BASE/extra $BASE/include
#
# Copy directory files
#
copy_dir_files()
{
for arg do
print_debug "Copying files from directory '$arg'"
cd $SOURCE/$arg
if [ ! -d $BASE/$arg ]; then
print_debug "Creating directory '$arg'"
mkdir $BASE/$arg
fi
for i in *.c *.cpp *.h *.ih *.i *.ic *.asm *.def \
README INSTALL* LICENSE *.yy
do
if [ -f $i ]
then
$CP $SOURCE/$arg/$i $BASE/$arg/$i
fi
done
for i in *.cc
do
if [ -f $i ]
then
i=`echo $i | sed 's/.cc$//g'`
$CP $SOURCE/$arg/$i.cc $BASE/$arg/$i.cpp
fi
done
done
}
#
# Copy directory contents recursively
#
copy_dir_dirs() {
for arg do
cd $SOURCE
(
find $arg -type d \
-and -not -path \*SCCS\* \
-and -not -path \*.deps\* \
-and -not -path \*autom4te.cache -print
)|(
while read v
do
copy_dir_files $v
done
)
done
}
#
# Input directories to be copied
#
for i in client dbug div extra heap include isam \
libmysql libmysqld merge myisam \
myisammrg mysys readline regex sql strings \
tools vio zlib
do
copy_dir_files $i
done
#
# Input directories to be copied recursively
#
for i in bdb innobase
do
copy_dir_dirs $i
done
#
# Directories to be copied complete
#
for i in mysql-test repl-tests support-files
do
$CP -R $SOURCE/$i $BASE/$i
done
#
# Create dummy innobase configure header
#
if [ -f $BASE/innobase/ib_config.h ]; then
rm -f $BASE/innobase/ib_config.h
fi
touch $BASE/innobase/ib_config.h
#
# Copy miscellaneous files
#
cd $SOURCE
for i in COPYING COPYING.LIB ChangeLog README \
INSTALL-SOURCE INSTALL-WIN \
INSTALL-WIN-SOURCE \
Docs/manual_toc.html Docs/manual.html \
Docs/manual.txt Docs/mysqld_error.txt \
Docs/INSTALL-BINARY
do
print_debug "Copying file '$i'"
if [ -f $i ]
then
$CP $i $BASE/$i
fi
done
#
# Raw dirs from source tree
#
for i in Docs/Flags scripts sql-bench SSL \
tests
do
print_debug "Copying directory '$i'"
if [ -d $i ]
then
$CP -R $i $BASE/$i
fi
done
#
# Fix some windows files
#
./extra/replace std:: "" -- $BASE/sql/sql_yacc.cpp
unix_to_dos $BASE/README
mv $BASE/README $BASE/README.txt
#
# Initialize the initial data directory
#
if [ -f scripts/mysql_install_db ]; then
print_debug "Initializing the 'data' directory"
mkdir $BASE/data
scripts/mysql_install_db --no-defaults --datadir=$BASE/data
fi
#
# Specify the distribution package name and copy it
#
if test -z $DIRNAME
then
NEW_DIR_NAME=mysql@MYSQL_SERVER_SUFFIX@-$version$SUFFIX
else
NEW_DIR_NAME=$DIRNAME
fi
NEW_NAME=$NEW_DIR_NAME-win-src
BASE2=$TMP/$NEW_DIR_NAME
rm -r -f $BASE2
mv $BASE $BASE2
BASE=$BASE2
#
# If debugging, don't create a zip/tar/gz
#
if [ "$DEBUG" = "1" ] ; then
echo "Please check the distribution files from $BASE"
echo "Exiting (without creating the package).."
exit
fi
#
# This is needed to prefere gnu tar instead of tar because tar can't
# always handle long filenames
#
PATH_DIRS=`echo $PATH | sed -e 's/^:/. /' -e 's/:$/ ./' -e 's/::/ . /g' -e 's/:/ /g' `
which_1 ()
{
for cmd
do
for d in $PATH_DIRS
do
for file in $d/$cmd
do
if test -x $file -a ! -d $file
then
echo $file
exit 0
fi
done
done
done
exit 1
}
#
# Create the result zip/tar file
#
if [ "$OUTTAR" = "0" ]; then
if [ "$OUTZIP" = "0" ]; then
OUTZIP=1
fi
fi
set_tarzip_options()
{
for arg
do
if [ "$arg" = "tar" ]; then
ZIPFILE1=gnutar
ZIPFILE2=gtar
OPT=cvf
EXT=".tar"
NEED_COMPRESS=1
if [ "$SILENT" = "1" ] ; then
OPT=cf
fi
else
ZIPFILE1=zip
ZIPFILE2=""
OPT="-r"
EXT=".zip"
NEED_COMPRESS=0
if [ "$SILENT" = "1" ] ; then
OPT="$OPT -q"
fi
fi
done
}
#
# Create the archive
#
create_archive()
{
print_debug "Using $tar to create archive"
cd $TMP
rm -f $SOURCE/$NEW_NAME$EXT
$tar $OPT $SOURCE/$NEW_NAME$EXT $NEW_DIR_NAME
cd $SOURCE
if [ "$NEED_COMPRESS" = "1" ]
then
print_debug "Compressing archive"
gzip -9 $NEW_NAME$EXT
EXT="$EXT.gz"
fi
if [ "$SILENT" = "0" ] ; then
echo "$NEW_NAME$EXT created successfully !!"
fi
}
if [ "$OUTTAR" = "1" ]; then
set_tarzip_options 'tar'
tar=`which_1 $ZIPFILE1 $ZIPFILE2`
if test "$?" = "1" -o "$tar" = ""
then
print_debug "Search failed for '$ZIPFILE1', '$ZIPFILE2', using default 'tar'"
tar=tar
set_tarzip_options 'tar'
fi
create_archive
fi
if [ "$OUTZIP" = "1" ]; then
set_tarzip_options 'zip'
tar=`which_1 $ZIPFILE1 $ZIPFILE2`
if test "$?" = "1" -o "$tar" = ""
then
echo "Search failed for '$ZIPFILE1', '$ZIPFILE2', cannot create zip!"
fi
create_archive
fi
print_debug "Removing temporary directory"
rm -r -f $BASE
# End of script
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment