From f7184297e3a7a937cac17a50928e34cda8afaef4 Mon Sep 17 00:00:00 2001 From: Robert Nelson Date: Fri, 1 Dec 2006 11:33:49 +0000 Subject: [PATCH] Add new files associated with previous commit. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3721 91ce42f0-d328-0410-95d8-f526ca767f89 --- .../win32/cats/create_sqlite3_database.cmd | 6 + .../src/win32/cats/drop_sqlite3_database.cmd | 7 + bacula/src/win32/cats/drop_sqlite3_tables.cmd | 8 + .../win32/cats/grant_sqlite3_privileges.cmd | 7 + .../win32/cats/make_mysql_catalog_backup.cmd | 41 + .../cats/make_postgresql_catalog_backup.cmd | 41 + .../cats/make_sqlite3_catalog_backup.cmd | 38 + bacula/src/win32/cats/make_sqlite3_tables.cmd | 7 + bacula/src/win32/cats/make_sqlite3_tables.sql | 347 ++++++++ bacula/src/win32/patches/sqlite_msc.patch | 768 ++++++++++++++++++ bacula/src/win32/scripts/.cvsignore | 1 + bacula/src/win32/scripts/disk-changer.cmd | 201 +++++ bacula/src/win32/scripts/dvd-handler.cmd | 383 +++++++++ 13 files changed, 1855 insertions(+) create mode 100644 bacula/src/win32/cats/create_sqlite3_database.cmd create mode 100644 bacula/src/win32/cats/drop_sqlite3_database.cmd create mode 100644 bacula/src/win32/cats/drop_sqlite3_tables.cmd create mode 100644 bacula/src/win32/cats/grant_sqlite3_privileges.cmd create mode 100644 bacula/src/win32/cats/make_mysql_catalog_backup.cmd create mode 100644 bacula/src/win32/cats/make_postgresql_catalog_backup.cmd create mode 100644 bacula/src/win32/cats/make_sqlite3_catalog_backup.cmd create mode 100644 bacula/src/win32/cats/make_sqlite3_tables.cmd create mode 100644 bacula/src/win32/cats/make_sqlite3_tables.sql create mode 100644 bacula/src/win32/patches/sqlite_msc.patch create mode 100644 bacula/src/win32/scripts/disk-changer.cmd create mode 100644 bacula/src/win32/scripts/dvd-handler.cmd diff --git a/bacula/src/win32/cats/create_sqlite3_database.cmd b/bacula/src/win32/cats/create_sqlite3_database.cmd new file mode 100644 index 0000000000..9ea7f5200b --- /dev/null +++ b/bacula/src/win32/cats/create_sqlite3_database.cmd @@ -0,0 +1,6 @@ +@ECHO off +REM +REM Script to create Bacula SQLite tables + +ECHO .databases | "@bin_dir_cmd@\sqlite3" %* @working_dir_cmd@\bacula.db +EXIT /b 0 diff --git a/bacula/src/win32/cats/drop_sqlite3_database.cmd b/bacula/src/win32/cats/drop_sqlite3_database.cmd new file mode 100644 index 0000000000..6be1689c1a --- /dev/null +++ b/bacula/src/win32/cats/drop_sqlite3_database.cmd @@ -0,0 +1,7 @@ +@ECHO off +REM +REM Script to drop Bacula SQLite tables + +DEL @working_dir_cmd@\bacula.db +ECHO SQLite database dropped. +EXIT /b 0 diff --git a/bacula/src/win32/cats/drop_sqlite3_tables.cmd b/bacula/src/win32/cats/drop_sqlite3_tables.cmd new file mode 100644 index 0000000000..3a58647e76 --- /dev/null +++ b/bacula/src/win32/cats/drop_sqlite3_tables.cmd @@ -0,0 +1,8 @@ +@ECHO off +REM +REM Script to delete the SQLite Bacula database (same as deleting +REM the tables) +REM + +DEL "@working_dir_cmd@\bacula.db" +EXIT /b 0 diff --git a/bacula/src/win32/cats/grant_sqlite3_privileges.cmd b/bacula/src/win32/cats/grant_sqlite3_privileges.cmd new file mode 100644 index 0000000000..1aa0ff2215 --- /dev/null +++ b/bacula/src/win32/cats/grant_sqlite3_privileges.cmd @@ -0,0 +1,7 @@ +@ECHO off +REM +REM Script to grant privileges to the bacula database +REM + +REM nothing to do here +EXIT /b 0 diff --git a/bacula/src/win32/cats/make_mysql_catalog_backup.cmd b/bacula/src/win32/cats/make_mysql_catalog_backup.cmd new file mode 100644 index 0000000000..2d29289b28 --- /dev/null +++ b/bacula/src/win32/cats/make_mysql_catalog_backup.cmd @@ -0,0 +1,41 @@ +@ECHO off +REM +REM This script dumps your Bacula catalog in ASCII format +REM It works for MySQL, SQLite, and PostgreSQL +REM +REM %1 is the name of the database to be backed up and the name +REM of the output file (default = bacula +REM %2 is the user name with which to access the database +REM (default = bacula). +REM %3 is the password with which to access the database or "" if no password +REM (default "") +REM +REM +@ECHO on + +DEL /f "@working_dir_cmd@\%1.sql" 2>nul + +set MYSQLPASSWORD= + +IF NOT "%3"=="" SET MYSQLPASSWORD=--password=%3 +"@SQL_BINDIR@\mysqldump" -u %2 %MYSQLPASSWORD% -f --opt %1 > "@working_dir_cmd@\%1.sql" + +@ECHO off +REM +REM To read back a MySQL database use: +REM cd @working_dir_cmd@ +REM rd /s /q @SQL_BINDIR@\..\data\bacula +REM mysql < bacula.sql +REM +REM To read back a SQLite database use: +REM cd @working_dir_cmd@ +REM del /f bacula.db +REM sqlite bacula.db < bacula.sql +REM +REM To read back a PostgreSQL database use: +REM cd @working_dir_cmd@ +REM dropdb bacula +REM createdb bacula +REM psql bacula < bacula.sql +REM +EXIT /b 0 diff --git a/bacula/src/win32/cats/make_postgresql_catalog_backup.cmd b/bacula/src/win32/cats/make_postgresql_catalog_backup.cmd new file mode 100644 index 0000000000..7a2c7feb72 --- /dev/null +++ b/bacula/src/win32/cats/make_postgresql_catalog_backup.cmd @@ -0,0 +1,41 @@ +@ECHO off +REM +REM This script dumps your Bacula catalog in ASCII format +REM It works for MySQL, SQLite, and PostgreSQL +REM +REM %1 is the name of the database to be backed up and the name +REM of the output file (default = bacula +REM %2 is the user name with which to access the database +REM (default = bacula). +REM %3 is the password with which to access the database or "" if no password +REM (default "") +REM +REM +@ECHO on + +DEL /f "@working_dir_cmd@\%1.sql" 2>nul + +SET PGPASSWORD= + +IF NOT "%3"=="" SET PGPASSWORD=--password=%3 +"@SQL_BINDIR@\pg_dump" -c -U %2 %1 >"@working_dir_cmd@\%1.sql" + +@ECHO off +REM +REM To read back a MySQL database use: +REM cd @working_dir_cmd@ +REM rd /s /q @SQL_BINDIR@\..\data\bacula +REM mysql < bacula.sql +REM +REM To read back a SQLite database use: +REM cd @working_dir_cmd@ +REM del /f bacula.db +REM sqlite bacula.db < bacula.sql +REM +REM To read back a PostgreSQL database use: +REM cd @working_dir_cmd@ +REM dropdb bacula +REM createdb bacula +REM psql bacula < bacula.sql +REM +EXIT /b 0 diff --git a/bacula/src/win32/cats/make_sqlite3_catalog_backup.cmd b/bacula/src/win32/cats/make_sqlite3_catalog_backup.cmd new file mode 100644 index 0000000000..9af7713558 --- /dev/null +++ b/bacula/src/win32/cats/make_sqlite3_catalog_backup.cmd @@ -0,0 +1,38 @@ +@ECHO off +REM +REM This script dumps your Bacula catalog in ASCII format +REM It works for MySQL, SQLite, and PostgreSQL +REM +REM %1 is the name of the database to be backed up and the name +REM of the output file (default = bacula +REM %2 is the user name with which to access the database +REM (default = bacula). +REM %3 is the password with which to access the database or "" if no password +REM (default "") +REM +REM +@ECHO on + +DEL /f "@working_dir_cmd@\%1.sql" 2>nul + +ECHO .dump | "@bin_dir_cmd@\sqlite3" %1.db > "@working_dir_cmd@\%1.sql" + +@ECHO off +REM +REM To read back a MySQL database use: +REM cd @working_dir_cmd@ +REM rd /s /q @SQL_BINDIR@\..\data\bacula +REM mysql < bacula.sql +REM +REM To read back a SQLite database use: +REM cd @working_dir_cmd@ +REM del /f bacula.db +REM sqlite bacula.db < bacula.sql +REM +REM To read back a PostgreSQL database use: +REM cd @working_dir_cmd@ +REM dropdb bacula +REM createdb bacula +REM psql bacula < bacula.sql +REM +EXIT /b 0 diff --git a/bacula/src/win32/cats/make_sqlite3_tables.cmd b/bacula/src/win32/cats/make_sqlite3_tables.cmd new file mode 100644 index 0000000000..1aed723397 --- /dev/null +++ b/bacula/src/win32/cats/make_sqlite3_tables.cmd @@ -0,0 +1,7 @@ +@ECHO off +REM +REM Script to create Bacula SQLite tables + +"@bin_dir_cmd@\sqlite3" %* "@working_dir_cmd@\bacula.db" < "@bin_dir_cmd@\make_sqlite3_tables.sql" + +EXIT /b 0 diff --git a/bacula/src/win32/cats/make_sqlite3_tables.sql b/bacula/src/win32/cats/make_sqlite3_tables.sql new file mode 100644 index 0000000000..bab40f436a --- /dev/null +++ b/bacula/src/win32/cats/make_sqlite3_tables.sql @@ -0,0 +1,347 @@ +CREATE TABLE Filename ( + FilenameId INTEGER, + Name TEXT DEFAULT "", + PRIMARY KEY(FilenameId) + ); + +CREATE INDEX inx1 ON Filename (Name); + +CREATE TABLE Path ( + PathId INTEGER, + Path TEXT DEFAULT "", + PRIMARY KEY(PathId) + ); + +CREATE INDEX inx2 ON Path (Path); + + +CREATE TABLE File ( + FileId INTEGER, + FileIndex INTEGER UNSIGNED NOT NULL, + JobId INTEGER UNSIGNED REFERENCES Job NOT NULL, + PathId INTEGER UNSIGNED REFERENCES Path NOT NULL, + FilenameId INTEGER UNSIGNED REFERENCES Filename NOT NULL, + MarkId INTEGER UNSIGNED DEFAULT 0, + LStat VARCHAR(255) NOT NULL, + MD5 VARCHAR(255) NOT NULL, + PRIMARY KEY(FileId) + ); + +CREATE INDEX inx3 ON File (JobId); +CREATE INDEX inx4 ON File (FilenameId, PathId); +-- +-- Possibly add one or more of the following indexes +-- if your Verifies are too slow. +-- +-- CREATE INDEX inx4 ON File (PathId); +-- CREATE INDEX inx5 ON File (FileNameId); +-- CREATE INDEX inx9 ON File (JobId, PathId, FilenameId); + +CREATE TABLE Job ( + JobId INTEGER, + Job VARCHAR(128) NOT NULL, + Name VARCHAR(128) NOT NULL, + Type CHAR NOT NULL, + Level CHAR NOT NULL, + ClientId INTEGER REFERENCES Client DEFAULT 0, + JobStatus CHAR NOT NULL, + SchedTime DATETIME NOT NULL, + StartTime DATETIME DEFAULT 0, + EndTime DATETIME DEFAULT 0, + RealEndTime DATETIME DEFAULT 0, + JobTDate BIGINT UNSIGNED DEFAULT 0, + VolSessionId INTEGER UNSIGNED DEFAULT 0, + VolSessionTime INTEGER UNSIGNED DEFAULT 0, + JobFiles INTEGER UNSIGNED DEFAULT 0, + JobBytes BIGINT UNSIGNED DEFAULT 0, + JobErrors INTEGER UNSIGNED DEFAULT 0, + JobMissingFiles INTEGER UNSIGNED DEFAULT 0, + PoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0, + FileSetId INTEGER UNSIGNED REFERENCES FileSet DEFAULT 0, + PriorJobId INTEGER UNSIGNED REFERENCES Job DEFAULT 0, + PurgedFiles TINYINT DEFAULT 0, + HasBase TINYINT DEFAULT 0, + PRIMARY KEY(JobId) + ); +CREATE INDEX inx6 ON Job (Name); + +CREATE TABLE Location ( + LocationId INTEGER, + Location TEXT NOT NULL, + Cost INTEGER DEFAULT 0, + Enabled TINYINT, + PRIMARY KEY(LocationId) + ); + +CREATE TABLE LocationLog ( + LocLogId INTEGER, + Date DATETIME NOT NULL, + Comment TEXT NOT NULL, + MediaId INTEGER UNSIGNED REFERENCES Media DEFAULT 0, + LocationId INTEGER UNSIGNED REFERENCES LocationId DEFAULT 0, + NewVolStatus VARCHAR(20) NOT NULL, + NewEnabled TINYINT NOT NULL, + PRIMARY KEY(LocLogId) +); + + +CREATE TABLE Log ( + LogId INTEGER, + JobId INTEGER UNSIGNED REFERENCES Job NOT NULL, + Time DATETIME NOT NULL, + LogText TEXT NOT NULL, + PRIMARY KEY(LogId) + ); +CREATE INDEX LogInx1 ON File (JobId); + + +CREATE TABLE FileSet ( + FileSetId INTEGER, + FileSet VARCHAR(128) NOT NULL, + MD5 VARCHAR(25) NOT NULL, + CreateTime DATETIME DEFAULT 0, + PRIMARY KEY(FileSetId) + ); + +CREATE TABLE JobMedia ( + JobMediaId INTEGER, + JobId INTEGER UNSIGNED REFERENCES Job NOT NULL, + MediaId INTEGER UNSIGNED REFERENCES Media NOT NULL, + FirstIndex INTEGER UNSIGNED NOT NULL, + LastIndex INTEGER UNSIGNED NOT NULL, + StartFile INTEGER UNSIGNED DEFAULT 0, + EndFile INTEGER UNSIGNED DEFAULT 0, + StartBlock INTEGER UNSIGNED DEFAULT 0, + EndBlock INTEGER UNSIGNED DEFAULT 0, + VolIndex INTEGER UNSIGNED DEFAULT 0, + Copy INTEGER UNSIGNED DEFAULT 0, + PRIMARY KEY(JobMediaId) + ); + +CREATE INDEX inx7 ON JobMedia (JobId, MediaId); + + +CREATE TABLE Media ( + MediaId INTEGER, + VolumeName VARCHAR(128) NOT NULL, + Slot INTEGER DEFAULT 0, + PoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0, + MediaType VARCHAR(128) NOT NULL, + MediaTypeId INTEGER UNSIGNED REFERENCES MediaType DEFAULT 0, + LabelType TINYINT DEFAULT 0, + FirstWritten DATETIME DEFAULT 0, + LastWritten DATETIME DEFAULT 0, + LabelDate DATETIME DEFAULT 0, + VolJobs INTEGER UNSIGNED DEFAULT 0, + VolFiles INTEGER UNSIGNED DEFAULT 0, + VolBlocks INTEGER UNSIGNED DEFAULT 0, + VolMounts INTEGER UNSIGNED DEFAULT 0, + VolBytes BIGINT UNSIGNED DEFAULT 0, + VolParts INTEGER UNSIGNED DEFAULT 0, + VolErrors INTEGER UNSIGNED DEFAULT 0, + VolWrites INTEGER UNSIGNED DEFAULT 0, + VolCapacityBytes BIGINT UNSIGNED DEFAULT 0, + VolStatus VARCHAR(20) NOT NULL, + Enabled TINYINT DEFAULT 1, + Recycle TINYINT DEFAULT 0, + VolRetention BIGINT UNSIGNED DEFAULT 0, + VolUseDuration BIGINT UNSIGNED DEFAULT 0, + MaxVolJobs INTEGER UNSIGNED DEFAULT 0, + MaxVolFiles INTEGER UNSIGNED DEFAULT 0, + MaxVolBytes BIGINT UNSIGNED DEFAULT 0, + InChanger TINYINT DEFAULT 0, + StorageId INTEGER UNSIGNED REFERENCES Storage DEFAULT 0, + DeviceId INTEGER UNSIGNED REFERENCES Device DEFAULT 0, + MediaAddressing TINYINT DEFAULT 0, + VolReadTime BIGINT UNSIGNED DEFAULT 0, + VolWriteTime BIGINT UNSIGNED DEFAULT 0, + EndFile INTEGER UNSIGNED DEFAULT 0, + EndBlock INTEGER UNSIGNED DEFAULT 0, + LocationId INTEGER UNSIGNED REFERENCES Location DEFAULT 0, + RecycleCount INTEGER UNSIGNED DEFAULT 0, + InitialWrite DATETIME DEFAULT 0, + ScratchPoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0, + RecyclePoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0, + Comment TEXT, + PRIMARY KEY(MediaId) + ); + +CREATE INDEX inx8 ON Media (PoolId); + +CREATE TABLE MediaType ( + MediaTypeId INTEGER, + MediaType VARCHAR(128) NOT NULL, + ReadOnly TINYINT DEFAULT 0, + PRIMARY KEY(MediaTypeId) + ); + +CREATE TABLE Storage ( + StorageId INTEGER, + Name VARCHAR(128) NOT NULL, + AutoChanger TINYINT DEFAULT 0, + PRIMARY KEY(StorageId) + ); + +CREATE TABLE Device ( + DeviceId INTEGER, + Name VARCHAR(128) NOT NULL, + MediaTypeId INTEGER UNSIGNED REFERENCES MediaType NOT NULL, + StorageId INTEGER UNSIGNED REFERENCES Storage, + DevMounts INTEGER UNSIGNED DEFAULT 0, + DevReadBytes BIGINT UNSIGNED DEFAULT 0, + DevWriteBytes BIGINT UNSIGNED DEFAULT 0, + DevReadBytesSinceCleaning BIGINT UNSIGNED DEFAULT 0, + DevWriteBytesSinceCleaning BIGINT UNSIGNED DEFAULT 0, + DevReadTime BIGINT UNSIGNED DEFAULT 0, + DevWriteTime BIGINT UNSIGNED DEFAULT 0, + DevReadTimeSinceCleaning BIGINT UNSIGNED DEFAULT 0, + DevWriteTimeSinceCleaning BIGINT UNSIGNED DEFAULT 0, + CleaningDate DATETIME DEFAULT 0, + CleaningPeriod BIGINT UNSIGNED DEFAULT 0, + PRIMARY KEY(DeviceId) + ); + + +CREATE TABLE Pool ( + PoolId INTEGER, + Name VARCHAR(128) NOT NULL, + NumVols INTEGER UNSIGNED DEFAULT 0, + MaxVols INTEGER UNSIGNED DEFAULT 0, + UseOnce TINYINT DEFAULT 0, + UseCatalog TINYINT DEFAULT 1, + AcceptAnyVolume TINYINT DEFAULT 0, + VolRetention BIGINT UNSIGNED DEFAULT 0, + VolUseDuration BIGINT UNSIGNED DEFAULT 0, + MaxVolJobs INTEGER UNSIGNED DEFAULT 0, + MaxVolFiles INTEGER UNSIGNED DEFAULT 0, + MaxVolBytes BIGINT UNSIGNED DEFAULT 0, + AutoPrune TINYINT DEFAULT 0, + Recycle TINYINT DEFAULT 0, + PoolType VARCHAR(20) NOT NULL, + LabelType TINYINT DEFAULT 0, + LabelFormat VARCHAR(128) NOT NULL, + Enabled TINYINT DEFAULT 1, + ScratchPoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0, + RecyclePoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0, + NextPoolId INTEGER UNSIGNED REFERENCES Pool DEFAULT 0, + MigrationHighBytes BIGINT UNSIGNED DEFAULT 0, + MigrationLowBytes BIGINT UNSIGNED DEFAULT 0, + MigrationTime BIGINT UNSIGNED DEFAULT 0, + UNIQUE (Name), + PRIMARY KEY (PoolId) + ); + + +CREATE TABLE Client ( + ClientId INTEGER, + Name VARCHAR(128) NOT NULL, + Uname VARCHAR(255) NOT NULL, -- uname -a field + AutoPrune TINYINT DEFAULT 0, + FileRetention BIGINT UNSIGNED DEFAULT 0, + JobRetention BIGINT UNSIGNED DEFAULT 0, + UNIQUE (Name), + PRIMARY KEY(ClientId) + ); + +CREATE TABLE BaseFiles ( + BaseId INTEGER, + BaseJobId INTEGER UNSIGNED REFERENCES Job NOT NULL, + JobId INTEGER UNSIGNED REFERENCES Job NOT NULL, + FileId INTEGER UNSIGNED REFERENCES File NOT NULL, + FileIndex INTEGER UNSIGNED, + PRIMARY KEY(BaseId) + ); + +CREATE TABLE UnsavedFiles ( + UnsavedId INTEGER, + JobId INTEGER UNSIGNED REFERENCES Job NOT NULL, + PathId INTEGER UNSIGNED REFERENCES Path NOT NULL, + FilenameId INTEGER UNSIGNED REFERENCES Filename NOT NULL, + PRIMARY KEY (UnsavedId) + ); + + +CREATE TABLE NextId ( + id INTEGER UNSIGNED DEFAULT 0, + TableName TEXT NOT NULL, + PRIMARY KEY (TableName) + ); + + + +-- Initialize JobId to start at 1 +INSERT INTO NextId (id, TableName) VALUES (1, "Job"); + +CREATE TABLE Version ( + VersionId INTEGER UNSIGNED NOT NULL + ); + + +CREATE TABLE Counters ( + Counter TEXT NOT NULL, + MinValue INTEGER DEFAULT 0, + MaxValue INTEGER DEFAULT 0, + CurrentValue INTEGER DEFAULT 0, + WrapCounter TEXT NOT NULL, + PRIMARY KEY (Counter) + ); + +CREATE TABLE CDImages ( + MediaId INTEGER UNSIGNED NOT NULL, + LastBurn DATETIME NOT NULL, + PRIMARY KEY (MediaId) + ); + + +CREATE TABLE Status ( + JobStatus CHAR(1) NOT NULL, + JobStatusLong BLOB, + PRIMARY KEY (JobStatus) + ); + +INSERT INTO Status (JobStatus,JobStatusLong) VALUES + ('C', 'Created, not yet running'); +INSERT INTO Status (JobStatus,JobStatusLong) VALUES + ('R', 'Running'); +INSERT INTO Status (JobStatus,JobStatusLong) VALUES + ('B', 'Blocked'); +INSERT INTO Status (JobStatus,JobStatusLong) VALUES + ('T', 'Completed successfully'); +INSERT INTO Status (JobStatus,JobStatusLong) VALUES + ('E', 'Terminated with errors'); +INSERT INTO Status (JobStatus,JobStatusLong) VALUES + ('e', 'Non-fatal error'); +INSERT INTO Status (JobStatus,JobStatusLong) VALUES + ('f', 'Fatal error'); +INSERT INTO Status (JobStatus,JobStatusLong) VALUES + ('D', 'Verify found differences'); +INSERT INTO Status (JobStatus,JobStatusLong) VALUES + ('A', 'Canceled by user'); +INSERT INTO Status (JobStatus,JobStatusLong) VALUES + ('F', 'Waiting for Client'); +INSERT INTO Status (JobStatus,JobStatusLong) VALUES + ('S', 'Waiting for Storage daemon'); +INSERT INTO Status (JobStatus,JobStatusLong) VALUES + ('m', 'Waiting for new media'); +INSERT INTO Status (JobStatus,JobStatusLong) VALUES + ('M', 'Waiting for media mount'); +INSERT INTO Status (JobStatus,JobStatusLong) VALUES + ('s', 'Waiting for storage resource'); +INSERT INTO Status (JobStatus,JobStatusLong) VALUES + ('j', 'Waiting for job resource'); +INSERT INTO Status (JobStatus,JobStatusLong) VALUES + ('c', 'Waiting for client resource'); +INSERT INTO Status (JobStatus,JobStatusLong) VALUES + ('d', 'Waiting on maximum jobs'); +INSERT INTO Status (JobStatus,JobStatusLong) VALUES + ('t', 'Waiting on start time'); +INSERT INTO Status (JobStatus,JobStatusLong) VALUES + ('p', 'Waiting on higher priority jobs'); + + +-- Initialize Version +INSERT INTO Version (VersionId) VALUES (10); + + +PRAGMA default_synchronous = OFF; +PRAGMA default_cache_size = 10000; diff --git a/bacula/src/win32/patches/sqlite_msc.patch b/bacula/src/win32/patches/sqlite_msc.patch new file mode 100644 index 0000000000..5f8161d8de --- /dev/null +++ b/bacula/src/win32/patches/sqlite_msc.patch @@ -0,0 +1,768 @@ +--- /dev/null 1969-12-31 16:00:00.000000000 -0800 ++++ Makefile.msvc 2006-11-23 12:38:22.724805900 -0800 +@@ -0,0 +1,136 @@ ++#!/usr/make ++# ++# Makefile for SQLITE ++# ++# This is a template makefile for SQLite. Most people prefer to ++# use the autoconf generated "configure" script to generate the ++# makefile automatically. But that does not work for everybody ++# and in every situation. If you are having problems with the ++# "configure" script, you might want to try this makefile as an ++# alternative. Create a copy of this file, edit the parameters ++# below and type "make". ++# ++ ++#### The toplevel directory of the source tree. This is the directory ++# that contains this "Makefile.in" and the "configure.in" script. ++# ++TOP = .. ++ ++#### C Compiler and options for use in building executables that ++# will run on the platform that is doing the build. ++# ++BCC = cl /Zi /Ox /Gy /MD ++#BCC = /opt/ancic/bin/c89 -0 ++ ++#### If the target operating system supports the "usleep()" system ++# call, then define the HAVE_USLEEP macro for all C modules. ++# ++USLEEP = ++#USLEEP = -DHAVE_USLEEP=1 ++ ++#### If you want the SQLite library to be safe for use within a ++# multi-threaded program, then define the following macro ++# appropriately: ++# ++THREADSAFE = -DTHREADSAFE=1 ++#THREADSAFE = -DTHREADSAFE=0 ++ ++#### Specify any extra linker options needed to make the library ++# thread safe ++# ++#THREADLIB = -lpthread ++THREADLIB = ++ ++#### Specify any extra libraries needed to access required functions. ++# ++#TLIBS = -lrt # fdatasync on Solaris 8 ++TLIBS = ++ ++#### Leave SQLITE_DEBUG undefined for maximum speed. Use SQLITE_DEBUG=1 ++# to check for memory leaks. Use SQLITE_DEBUG=2 to print a log of all ++# malloc()s and free()s in order to track down memory leaks. ++# ++# SQLite uses some expensive assert() statements in the inner loop. ++# You can make the library go almost twice as fast if you compile ++# with -DNDEBUG=1 ++# ++#OPTS = -DSQLITE_DEBUG=2 ++#OPTS = -DSQLITE_DEBUG=1 ++#OPTS = ++OPTS = -DNDEBUG=1 -D_CRT_SECURE_NO_DEPRECATE ++#OPTS += -DHAVE_FDATASYNC=1 ++ ++#### The suffix to add to executable files. ".exe" for windows. ++# Nothing for unix. ++# ++EXE = .exe ++#EXE = ++ ++#### C Compile and options for use in building executables that ++# will run on the target platform. This is usually the same ++# as BCC, unless you are cross-compiling. ++# ++#TCC = gcc -O6 ++#TCC = gcc -g -O0 -Wall ++#TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage ++#TCC = /opt/mingw/bin/i386-mingw32-gcc -O6 ++#TCC = /opt/ansic/bin/c89 -O +z -Wl,-a,archive ++TCC = cl /Zi /Ox /Gy /MD ++ ++#### Tools used to build a static library. ++# ++AR = lib ++#AR = /opt/mingw/bin/i386-mingw32-ar cr ++#RANLIB = ranlib ++#RANLIB = /opt/mingw/bin/i386-mingw32-ranlib ++ ++#MKSHLIB = gcc -shared ++#SO = so ++#SHPREFIX = lib ++SO = dll ++SHPREFIX = ++ ++#### Extra compiler options needed for programs that use the TCL library. ++# ++#TCL_FLAGS = ++#TCL_FLAGS = -DSTATIC_BUILD=1 ++#TCL_FLAGS = -I/home/drh/tcltk/8.4linux ++#TCL_FLAGS = -I/home/drh/tcltk/8.4win -DSTATIC_BUILD=1 ++#TCL_FLAGS = -I/home/drh/tcltk/8.3hpux ++ ++#### Linker options needed to link against the TCL library. ++# ++#LIBTCL = -ltcl -lm -ldl ++#LIBTCL = /home/drh/tcltk/8.4linux/libtcl8.4g.a -lm -ldl ++#LIBTCL = /home/drh/tcltk/8.4win/libtcl84s.a -lmsvcrt ++#LIBTCL = /home/drh/tcltk/8.3hpux/libtcl8.3.a -ldld -lm -lc ++ ++#### Compiler options needed for programs that use the readline() library. ++# ++READLINE_FLAGS = ++#READLINE_FLAGS = -DHAVE_READLINE=1 -I/usr/include/readline ++ ++#### Linker options needed by programs using readline() must link against. ++# ++LIBREADLINE = ++#LIBREADLINE = -static -lreadline -ltermcap ++ ++#### Should the database engine assume text is coded as UTF-8 or iso8859? ++# ++ENCODING = UTF8 ++#ENCODING = ISO8859 ++ ++ ++#### Which "awk" program provides nawk compatibilty ++# ++NAWK = nawk ++# NAWK = awk ++ ++#### Where to install ++BINDIR = /usr/bin ++LIBDIR = /usr/lib ++INCDIR = /usr/include ++ ++# You should not have to change anything below this line ++############################################################################### ++include ../main.mk.msvc +--- /dev/null 1969-12-31 16:00:00.000000000 -0800 ++++ main.mk.msvc 2006-11-23 12:38:22.709180800 -0800 +@@ -0,0 +1,619 @@ ++############################################################################### ++# The following macros should be defined before this script is ++# invoked: ++# ++# TOP The toplevel directory of the source tree. This is the ++# directory that contains this "Makefile.in" and the ++# "configure.in" script. ++# ++# BCC C Compiler and options for use in building executables that ++# will run on the platform that is doing the build. ++# ++# USLEEP If the target operating system supports the "usleep()" system ++# call, then define the HAVE_USLEEP macro for all C modules. ++# ++# THREADSAFE If you want the SQLite library to be safe for use within a ++# multi-threaded program, then define the following macro ++# appropriately: ++# ++# THREADLIB Specify any extra linker options needed to make the library ++# thread safe ++# ++# OPTS Extra compiler command-line options. ++# ++# EXE The suffix to add to executable files. ".exe" for windows ++# and "" for Unix. ++# ++# TCC C Compiler and options for use in building executables that ++# will run on the target platform. This is usually the same ++# as BCC, unless you are cross-compiling. ++# ++# AR Tools used to build a static library. ++# RANLIB ++# ++# TCL_FLAGS Extra compiler options needed for programs that use the ++# TCL library. ++# ++# LIBTCL Linker options needed to link against the TCL library. ++# ++# READLINE_FLAGS Compiler options needed for programs that use the ++# readline() library. ++# ++# LIBREADLINE Linker options needed by programs using readline() must ++# link against. ++# ++# NAWK Nawk compatible awk program. Older (obsolete?) solaris ++# systems need this to avoid using the original AT&T AWK. ++# ++# Once the macros above are defined, the rest of this make script will ++# build the SQLite library and testing tools. ++################################################################################ ++ ++# This is how we compile ++# ++TCCX = $(TCC) $(OPTS) $(THREADSAFE) $(USLEEP) -I. -I$(TOP)/src ++ ++# Object files for the SQLite library. ++# ++LIBOBJ = alter.obj analyze.obj attach.obj auth.obj btree.obj build.obj \ ++ callback.obj complete.obj date.obj delete.obj \ ++ expr.obj func.obj hash.obj insert.obj loadext.obj \ ++ main.obj opcodes.obj os.obj os_os2.obj os_unix.obj os_win.obj \ ++ pager.obj parse.obj pragma.obj prepare.obj printf.obj random.obj \ ++ select.obj table.obj tokenize.obj trigger.obj \ ++ update.obj util.obj vacuum.obj \ ++ vdbe.obj vdbeapi.obj vdbeaux.obj vdbefifo.obj vdbemem.obj \ ++ where.obj utf.obj legacy.obj vtab.obj ++# tclsqlite.obj ++ ++# ++# All of the source code files. ++# ++SRC = \ ++ $(TOP)/src/alter.c \ ++ $(TOP)/src/analyze.c \ ++ $(TOP)/src/attach.c \ ++ $(TOP)/src/auth.c \ ++ $(TOP)/src/btree.c \ ++ $(TOP)/src/btree.h \ ++ $(TOP)/src/build.c \ ++ $(TOP)/src/callback.c \ ++ $(TOP)/src/complete.c \ ++ $(TOP)/src/date.c \ ++ $(TOP)/src/delete.c \ ++ $(TOP)/src/expr.c \ ++ $(TOP)/src/func.c \ ++ $(TOP)/src/hash.c \ ++ $(TOP)/src/hash.h \ ++ $(TOP)/src/insert.c \ ++ $(TOP)/src/legacy.c \ ++ $(TOP)/src/loadext.c \ ++ $(TOP)/src/main.c \ ++ $(TOP)/src/os.c \ ++ $(TOP)/src/os_os2.c \ ++ $(TOP)/src/os_unix.c \ ++ $(TOP)/src/os_win.c \ ++ $(TOP)/src/pager.c \ ++ $(TOP)/src/pager.h \ ++ $(TOP)/src/parse.y \ ++ $(TOP)/src/pragma.c \ ++ $(TOP)/src/prepare.c \ ++ $(TOP)/src/printf.c \ ++ $(TOP)/src/random.c \ ++ $(TOP)/src/select.c \ ++ $(TOP)/src/shell.c \ ++ $(TOP)/src/sqlite.h.in \ ++ $(TOP)/src/sqliteInt.h \ ++ $(TOP)/src/table.c \ ++ $(TOP)/src/tclsqlite.c \ ++ $(TOP)/src/tokenize.c \ ++ $(TOP)/src/trigger.c \ ++ $(TOP)/src/utf.c \ ++ $(TOP)/src/update.c \ ++ $(TOP)/src/util.c \ ++ $(TOP)/src/vacuum.c \ ++ $(TOP)/src/vdbe.c \ ++ $(TOP)/src/vdbe.h \ ++ $(TOP)/src/vdbeapi.c \ ++ $(TOP)/src/vdbeaux.c \ ++ $(TOP)/src/vdbefifo.c \ ++ $(TOP)/src/vdbemem.c \ ++ $(TOP)/src/vdbeInt.h \ ++ $(TOP)/src/vtab.c \ ++ $(TOP)/src/where.c ++ ++# Source code for extensions ++# ++SRC = \ ++ $(TOP)/ext/fts1/fts1.c \ ++ $(TOP)/ext/fts1/fts1.h \ ++ $(TOP)/ext/fts1/fts1_hash.c \ ++ $(TOP)/ext/fts1/fts1_hash.h \ ++ $(TOP)/ext/fts1/fts1_porter.c \ ++ $(TOP)/ext/fts1/fts1_tokenizer.h \ ++ $(TOP)/ext/fts1/fts1_tokenizer1.c ++ ++ ++# Source code to the test files. ++# ++TESTSRC = \ ++ $(TOP)/src/btree.c \ ++ $(TOP)/src/date.c \ ++ $(TOP)/src/func.c \ ++ $(TOP)/src/main.c \ ++ $(TOP)/src/os.c \ ++ $(TOP)/src/os_os2.c \ ++ $(TOP)/src/os_unix.c \ ++ $(TOP)/src/os_win.c \ ++ $(TOP)/src/pager.c \ ++ $(TOP)/src/pragma.c \ ++ $(TOP)/src/printf.c \ ++ $(TOP)/src/test1.c \ ++ $(TOP)/src/test2.c \ ++ $(TOP)/src/test3.c \ ++ $(TOP)/src/test4.c \ ++ $(TOP)/src/test5.c \ ++ $(TOP)/src/test6.c \ ++ $(TOP)/src/test7.c \ ++ $(TOP)/src/test8.c \ ++ $(TOP)/src/test_autoext.c \ ++ $(TOP)/src/test_async.c \ ++ $(TOP)/src/test_md5.c \ ++ $(TOP)/src/test_schema.c \ ++ $(TOP)/src/test_server.c \ ++ $(TOP)/src/test_tclvar.c \ ++ $(TOP)/src/utf.c \ ++ $(TOP)/src/util.c \ ++ $(TOP)/src/vdbe.c \ ++ $(TOP)/src/vdbeaux.c \ ++ $(TOP)/src/where.c ++ ++# Header files used by all library source files. ++# ++HDR = \ ++ sqlite3.h \ ++ $(TOP)/src/btree.h \ ++ $(TOP)/src/hash.h \ ++ opcodes.h \ ++ $(TOP)/src/os.h \ ++ $(TOP)/src/os_common.h \ ++ $(TOP)/src/sqlite3ext.h \ ++ $(TOP)/src/sqliteInt.h \ ++ $(TOP)/src/vdbe.h \ ++ parse.h ++ ++# Header files used by extensions ++# ++HDR = \ ++ $(TOP)/ext/fts1/fts1.h \ ++ $(TOP)/ext/fts1/fts1_hash.h \ ++ $(TOP)/ext/fts1/fts1_tokenizer.h ++ ++ ++# Header files used by the VDBE submodule ++# ++VDBEHDR = \ ++ $(HDR) \ ++ $(TOP)/src/vdbeInt.h ++ ++# This is the default Makefile target. The objects listed here ++# are what get build when you type just "make" with no arguments. ++# ++all: sqlite3.h parse.h opcodes.h sqlite3.lib sqlite3$(EXE) ++ ++# Generate the file "last_change" which contains the date of change ++# of the most recently modified source code file ++# ++last_change: $(SRC) ++ cat $(SRC) | grep '$Id: ' | sort -k 5 | tail -1 \ ++ | $(NAWK) '{print $5,$6}' >last_change ++ ++sqlite3.lib: $(LIBOBJ) ++ $(AR) /out:sqlite3.lib $(LIBOBJ) ++ ++sqlite3$(EXE): $(TOP)/src/shell.c sqlite3.lib sqlite3.h ++ $(TCCX) $(READLINE_FLAGS) /Fesqlite3$(EXE) $(TOP)/src/shell.c \ ++ sqlite3.lib $(LIBREADLINE) $(TLIBS) $(THREADLIB) ++ ++objects: $(LIBOBJ_ORIG) ++ ++# This target creates a directory named "tsrc" and fills it with ++# copies of all of the C source code and header files needed to ++# build on the target system. Some of the C source code and header ++# files are automatically generated. This target takes care of ++# all that automatic generation. ++# ++target_source: $(SRC) $(VDBEHDR) opcodes.c keywordhash.h ++ rd /s /q tsrc ++ mkdir tsrc ++ copy $(SRC) $(VDBEHDR) tsrc ++ del tsrc\sqlite.h.in tsrc\parse.y ++ copy parse.c opcodes.c keywordhash.h tsrc ++ ++# Rules to build the LEMON compiler generator ++# ++lemon: $(TOP)/tool/lemon.c $(TOP)/tool/lempar.c ++ $(BCC) /Felemon $(OPTS) $(TOP)/tool/lemon.c ++ copy $(TOP)\tool\lempar.c . ++ ++# Rules to build individual files ++# ++alter.obj: $(TOP)/src/alter.c $(HDR) ++ $(TCCX) -c $(TOP)/src/alter.c ++ ++analyze.obj: $(TOP)/src/analyze.c $(HDR) ++ $(TCCX) -c $(TOP)/src/analyze.c ++ ++attach.obj: $(TOP)/src/attach.c $(HDR) ++ $(TCCX) -c $(TOP)/src/attach.c ++ ++auth.obj: $(TOP)/src/auth.c $(HDR) ++ $(TCCX) -c $(TOP)/src/auth.c ++ ++btree.obj: $(TOP)/src/btree.c $(HDR) $(TOP)/src/pager.h ++ $(TCCX) -c $(TOP)/src/btree.c ++ ++build.obj: $(TOP)/src/build.c $(HDR) ++ $(TCCX) -c $(TOP)/src/build.c ++ ++callback.obj: $(TOP)/src/callback.c $(HDR) ++ $(TCCX) -c $(TOP)/src/callback.c ++ ++complete.obj: $(TOP)/src/complete.c $(HDR) ++ $(TCCX) -c $(TOP)/src/complete.c ++ ++date.obj: $(TOP)/src/date.c $(HDR) ++ $(TCCX) -c $(TOP)/src/date.c ++ ++delete.obj: $(TOP)/src/delete.c $(HDR) ++ $(TCCX) -c $(TOP)/src/delete.c ++ ++expr.obj: $(TOP)/src/expr.c $(HDR) ++ $(TCCX) -c $(TOP)/src/expr.c ++ ++func.obj: $(TOP)/src/func.c $(HDR) ++ $(TCCX) -c $(TOP)/src/func.c ++ ++hash.obj: $(TOP)/src/hash.c $(HDR) ++ $(TCCX) -c $(TOP)/src/hash.c ++ ++insert.obj: $(TOP)/src/insert.c $(HDR) ++ $(TCCX) -c $(TOP)/src/insert.c ++ ++legacy.obj: $(TOP)/src/legacy.c $(HDR) ++ $(TCCX) -c $(TOP)/src/legacy.c ++ ++loadext.obj: $(TOP)/src/loadext.c $(HDR) ++ $(TCCX) -c $(TOP)/src/loadext.c ++ ++main.obj: $(TOP)/src/main.c $(HDR) ++ $(TCCX) -c $(TOP)/src/main.c ++ ++pager.obj: $(TOP)/src/pager.c $(HDR) $(TOP)/src/pager.h ++ $(TCCX) -c $(TOP)/src/pager.c ++ ++opcodes.obj: opcodes.c ++ $(TCCX) -c opcodes.c ++ ++opcodes.c: opcodes.h $(TOP)/mkopcodec.awk ++ sort -n -b -k 3 opcodes.h | $(NAWK) -f $(TOP)/mkopcodec.awk >opcodes.c ++ ++opcodes.h: parse.h $(TOP)/src/vdbe.c $(TOP)/mkopcodeh.awk ++ copy parse.h+$(TOP)\src\vdbe.c input.tmp ++ $(NAWK) -f $(TOP)/mkopcodeh.awk opcodes.h ++ del input.tmp ++ ++os.obj: $(TOP)/src/os.c $(HDR) ++ $(TCCX) -c $(TOP)/src/os.c ++ ++os_os2.obj: $(TOP)/src/os_os2.c $(HDR) ++ $(TCCX) -c $(TOP)/src/os_os2.c ++ ++os_unix.obj: $(TOP)/src/os_unix.c $(HDR) ++ $(TCCX) -c $(TOP)/src/os_unix.c ++ ++os_win.obj: $(TOP)/src/os_win.c $(HDR) ++ $(TCCX) -c $(TOP)/src/os_win.c ++ ++parse.obj: parse.c $(HDR) ++ $(TCCX) -c parse.c ++ ++#parse.h: parse.c ++ ++parse.c parse.h: $(TOP)/src/parse.y lemon $(TOP)/addopcodes.awk ++ copy $(TOP)\src\parse.y . ++ lemon $(OPTS) parse.y ++ ren parse.h parse.h.temp ++ nawk -f $(TOP)/addopcodes.awk parse.h.temp >parse.h ++ del parse.h.temp ++ ++pragma.obj: $(TOP)/src/pragma.c $(HDR) ++ $(TCCX) $(TCL_FLAGS) -c $(TOP)/src/pragma.c ++ ++prepare.obj: $(TOP)/src/prepare.c $(HDR) ++ $(TCCX) $(TCL_FLAGS) -c $(TOP)/src/prepare.c ++ ++printf.obj: $(TOP)/src/printf.c $(HDR) ++ $(TCCX) $(TCL_FLAGS) -c $(TOP)/src/printf.c ++ ++random.obj: $(TOP)/src/random.c $(HDR) ++ $(TCCX) -c $(TOP)/src/random.c ++ ++select.obj: $(TOP)/src/select.c $(HDR) ++ $(TCCX) -c $(TOP)/src/select.c ++ ++sqlite3.h: $(TOP)/src/sqlite.h.in ++ ..\update_ver $(TOP)\src\sqlite.h.in >sqlite3.h ++ ++table.obj: $(TOP)/src/table.c $(HDR) ++ $(TCCX) -c $(TOP)/src/table.c ++ ++tclsqlite.obj: $(TOP)/src/tclsqlite.c $(HDR) ++ $(TCCX) $(TCL_FLAGS) -c $(TOP)/src/tclsqlite.c ++ ++tokenize.obj: $(TOP)/src/tokenize.c keywordhash.h $(HDR) ++ $(TCCX) -c $(TOP)/src/tokenize.c ++ ++keywordhash.h: $(TOP)/tool/mkkeywordhash.c ++ $(BCC) /Femkkeywordhash $(OPTS) $(TOP)/tool/mkkeywordhash.c ++ mkkeywordhash >keywordhash.h ++ ++trigger.obj: $(TOP)/src/trigger.c $(HDR) ++ $(TCCX) -c $(TOP)/src/trigger.c ++ ++update.obj: $(TOP)/src/update.c $(HDR) ++ $(TCCX) -c $(TOP)/src/update.c ++ ++utf.obj: $(TOP)/src/utf.c $(HDR) ++ $(TCCX) -c $(TOP)/src/utf.c ++ ++util.obj: $(TOP)/src/util.c $(HDR) ++ $(TCCX) -c $(TOP)/src/util.c ++ ++vacuum.obj: $(TOP)/src/vacuum.c $(HDR) ++ $(TCCX) -c $(TOP)/src/vacuum.c ++ ++vdbe.obj: $(TOP)/src/vdbe.c $(VDBEHDR) ++ $(TCCX) -c $(TOP)/src/vdbe.c ++ ++vdbeapi.obj: $(TOP)/src/vdbeapi.c $(VDBEHDR) ++ $(TCCX) -c $(TOP)/src/vdbeapi.c ++ ++vdbeaux.obj: $(TOP)/src/vdbeaux.c $(VDBEHDR) ++ $(TCCX) -c $(TOP)/src/vdbeaux.c ++ ++vdbefifo.obj: $(TOP)/src/vdbefifo.c $(VDBEHDR) ++ $(TCCX) -c $(TOP)/src/vdbefifo.c ++ ++vdbemem.obj: $(TOP)/src/vdbemem.c $(VDBEHDR) ++ $(TCCX) -c $(TOP)/src/vdbemem.c ++ ++vtab.obj: $(TOP)/src/vtab.c $(VDBEHDR) ++ $(TCCX) -c $(TOP)/src/vtab.c ++ ++where.obj: $(TOP)/src/where.c $(HDR) ++ $(TCCX) -c $(TOP)/src/where.c ++ ++# Rules for building test programs and for running tests ++# ++tclsqlite3: $(TOP)/src/tclsqlite.c sqlite3.lib ++ $(TCCX) $(TCL_FLAGS) -DTCLSH=1 /Fetclsqlite3 \ ++ $(TOP)/src/tclsqlite.c sqlite3.lib $(LIBTCL) $(THREADLIB) ++ ++testfixture$(EXE): $(TOP)/src/tclsqlite.c sqlite3.lib $(TESTSRC) ++ $(TCCX) $(TCL_FLAGS) -DTCLSH=1 -DSQLITE_TEST=1 -DSQLITE_CRASH_TEST=1 \ ++ -DSQLITE_SERVER=1 /Fetestfixture$(EXE) \ ++ $(TESTSRC) $(TOP)/src/tclsqlite.c \ ++ sqlite3.lib $(LIBTCL) $(THREADLIB) ++ ++fulltest: testfixture$(EXE) sqlite3$(EXE) ++ testfixture$(EXE) $(TOP)/test/all.test ++ ++test: testfixture$(EXE) sqlite3$(EXE) ++ testfixture$(EXE) $(TOP)/test/quick.test ++ ++sqlite3_analyzer$(EXE): $(TOP)/src/tclsqlite.c sqlite3.lib $(TESTSRC) \ ++ $(TOP)/tool/spaceanal.tcl ++ sed \ ++ -e '/^#/d' \ ++ -e 's,\\,\\\\,g' \ ++ -e 's,",\\",g' \ ++ -e 's,^,",' \ ++ -e 's,$$,\\n",' \ ++ $(TOP)/tool/spaceanal.tcl >spaceanal_tcl.h ++ $(TCCX) $(TCL_FLAGS) -DTCLSH=2 -DSQLITE_TEST=1 -DSQLITE_DEBUG=1 \ ++ /Fesqlite3_analyzer$(EXE) $(TESTSRC) $(TOP)/src/tclsqlite.c \ ++ sqlite3.lib $(LIBTCL) $(THREADLIB) ++ ++TEST_EXTENSION = $(SHPREFIX)testloadext.$(SO) ++$(TEST_EXTENSION): $(TOP)/src/test_loadext.c ++ $(MKSHLIB) $(TOP)/src/test_loadext.c /Fe$(TEST_EXTENSION) ++ ++extensiontest: testfixture$(EXE) $(TEST_EXTENSION) ++ testfixture$(EXE) $(TOP)/test/loadext.test ++ ++# Rules used to build documentation ++# ++arch.html: $(TOP)/www/arch.tcl ++ tclsh $(TOP)/www/arch.tcl >arch.html ++ ++autoinc.html: $(TOP)/www/autoinc.tcl ++ tclsh $(TOP)/www/autoinc.tcl >autoinc.html ++ ++c_interface.html: $(TOP)/www/c_interface.tcl ++ tclsh $(TOP)/www/c_interface.tcl >c_interface.html ++ ++capi3.html: $(TOP)/www/capi3.tcl ++ tclsh $(TOP)/www/capi3.tcl >capi3.html ++ ++capi3ref.html: $(TOP)/www/capi3ref.tcl ++ tclsh $(TOP)/www/capi3ref.tcl >capi3ref.html ++ ++changes.html: $(TOP)/www/changes.tcl ++ tclsh $(TOP)/www/changes.tcl >changes.html ++ ++compile.html: $(TOP)/www/compile.tcl ++ tclsh $(TOP)/www/compile.tcl >compile.html ++ ++copyright.html: $(TOP)/www/copyright.tcl ++ tclsh $(TOP)/www/copyright.tcl >copyright.html ++ ++copyright-release.html: $(TOP)/www/copyright-release.html ++ copy $(TOP)/www/copyright-release.html . ++ ++copyright-release.pdf: $(TOP)/www/copyright-release.pdf ++ copy $(TOP)/www/copyright-release.pdf . ++ ++common.tcl: $(TOP)/www/common.tcl ++ copy $(TOP)/www/common.tcl . ++ ++conflict.html: $(TOP)/www/conflict.tcl ++ tclsh $(TOP)/www/conflict.tcl >conflict.html ++ ++datatypes.html: $(TOP)/www/datatypes.tcl ++ tclsh $(TOP)/www/datatypes.tcl >datatypes.html ++ ++datatype3.html: $(TOP)/www/datatype3.tcl ++ tclsh $(TOP)/www/datatype3.tcl >datatype3.html ++ ++different.html: $(TOP)/www/different.tcl ++ tclsh $(TOP)/www/different.tcl >different.html ++ ++docs.html: $(TOP)/www/docs.tcl ++ tclsh $(TOP)/www/docs.tcl >docs.html ++ ++download.html: $(TOP)/www/download.tcl ++ mkdir -p doc ++ tclsh $(TOP)/www/download.tcl >download.html ++ ++faq.html: $(TOP)/www/faq.tcl ++ tclsh $(TOP)/www/faq.tcl >faq.html ++ ++fileformat.html: $(TOP)/www/fileformat.tcl ++ tclsh $(TOP)/www/fileformat.tcl >fileformat.html ++ ++formatchng.html: $(TOP)/www/formatchng.tcl ++ tclsh $(TOP)/www/formatchng.tcl >formatchng.html ++ ++index.html: $(TOP)/www/index.tcl last_change ++ tclsh $(TOP)/www/index.tcl >index.html ++ ++lang.html: $(TOP)/www/lang.tcl ++ tclsh $(TOP)/www/lang.tcl doc >lang.html ++ ++pragma.html: $(TOP)/www/pragma.tcl ++ tclsh $(TOP)/www/pragma.tcl >pragma.html ++ ++lockingv3.html: $(TOP)/www/lockingv3.tcl ++ tclsh $(TOP)/www/lockingv3.tcl >lockingv3.html ++ ++sharedcache.html: $(TOP)/www/sharedcache.tcl ++ tclsh $(TOP)/www/sharedcache.tcl >sharedcache.html ++ ++mingw.html: $(TOP)/www/mingw.tcl ++ tclsh $(TOP)/www/mingw.tcl >mingw.html ++ ++nulls.html: $(TOP)/www/nulls.tcl ++ tclsh $(TOP)/www/nulls.tcl >nulls.html ++ ++oldnews.html: $(TOP)/www/oldnews.tcl ++ tclsh $(TOP)/www/oldnews.tcl >oldnews.html ++ ++omitted.html: $(TOP)/www/omitted.tcl ++ tclsh $(TOP)/www/omitted.tcl >omitted.html ++ ++opcode.html: $(TOP)/www/opcode.tcl $(TOP)/src/vdbe.c ++ tclsh $(TOP)/www/opcode.tcl $(TOP)/src/vdbe.c >opcode.html ++ ++optimizer.html: $(TOP)/www/optimizer.tcl ++ tclsh $(TOP)/www/optimizer.tcl >optimizer.html ++ ++optoverview.html: $(TOP)/www/optoverview.tcl ++ tclsh $(TOP)/www/optoverview.tcl >optoverview.html ++ ++quickstart.html: $(TOP)/www/quickstart.tcl ++ tclsh $(TOP)/www/quickstart.tcl >quickstart.html ++ ++speed.html: $(TOP)/www/speed.tcl ++ tclsh $(TOP)/www/speed.tcl >speed.html ++ ++sqlite.html: $(TOP)/www/sqlite.tcl ++ tclsh $(TOP)/www/sqlite.tcl >sqlite.html ++ ++support.html: $(TOP)/www/support.tcl ++ tclsh $(TOP)/www/support.tcl >support.html ++ ++tclsqlite.html: $(TOP)/www/tclsqlite.tcl ++ tclsh $(TOP)/www/tclsqlite.tcl >tclsqlite.html ++ ++vdbe.html: $(TOP)/www/vdbe.tcl ++ tclsh $(TOP)/www/vdbe.tcl >vdbe.html ++ ++version3.html: $(TOP)/www/version3.tcl ++ tclsh $(TOP)/www/version3.tcl >version3.html ++ ++whentouse.html: $(TOP)/www/whentouse.tcl ++ tclsh $(TOP)/www/whentouse.tcl >whentouse.html ++ ++ ++# Files to be published on the website. ++# ++DOC = \ ++ arch.html \ ++ autoinc.html \ ++ c_interface.html \ ++ capi3.html \ ++ capi3ref.html \ ++ changes.html \ ++ compile.html \ ++ copyright.html \ ++ copyright-release.html \ ++ copyright-release.pdf \ ++ conflict.html \ ++ datatypes.html \ ++ datatype3.html \ ++ different.html \ ++ docs.html \ ++ download.html \ ++ faq.html \ ++ fileformat.html \ ++ formatchng.html \ ++ index.html \ ++ lang.html \ ++ lockingv3.html \ ++ mingw.html \ ++ nulls.html \ ++ oldnews.html \ ++ omitted.html \ ++ opcode.html \ ++ optimizer.html \ ++ optoverview.html \ ++ pragma.html \ ++ quickstart.html \ ++ sharedcache.html \ ++ speed.html \ ++ sqlite.html \ ++ support.html \ ++ tclsqlite.html \ ++ vdbe.html \ ++ version3.html \ ++ whentouse.html ++ ++doc: common.tcl $(DOC) ++ mkdir -p doc ++ ren $(DOC) doc ++ copy $(TOP)/www/*.gif $(TOP)/art/*.gif doc ++ ++# Standard install and cleanup targets ++# ++install: sqlite3 sqlite3.lib sqlite3.h ++ copy sqlite3 $(BINDIR) ++ copy sqlite3.lib $(LIBDIR) ++ copy sqlite3.h $(INCDIR) ++ ++clean: ++ -del *~ *.obj *.ilk *.pdb sqlite3.exe sqlite3.lib sqlite3.h opcodes.* 2>nul ++ -del lemon.exe lempar.c parse.* sqlite*.tar.gz mkkeywordhash.exe keywordhash.h 2>nul ++ -del *.da *.bb *.bbg gmon.out 2>nul ++ -rd /s /q tsrc 2>nul ++ -del testloadext.dll 2>nul +--- /dev/null 1969-12-31 16:00:00.000000000 -0800 ++++ update_ver.cmd 2006-11-23 07:09:03.334906700 -0800 +@@ -0,0 +1,4 @@ ++@echo off ++for /f %%i in ( ..\VERSION ) do set VERSION=%%i ++for /f "usebackq" %%i in ( `cmd /c sed "s/[^0-9]/ /g" ^< ..\VERSION ^| nawk "{printf \"%%d%%03d%%03d\",$1,$2,$3}"` ) do set VERS_NUM=%%i ++sed -e s/--VERS--/%VERSION%/ -e s/--VERSION-NUMBER--/%VERS_NUM%/ %1 diff --git a/bacula/src/win32/scripts/.cvsignore b/bacula/src/win32/scripts/.cvsignore index a4383358ec..042d93ce53 100644 --- a/bacula/src/win32/scripts/.cvsignore +++ b/bacula/src/win32/scripts/.cvsignore @@ -1 +1,2 @@ *.d +*.user diff --git a/bacula/src/win32/scripts/disk-changer.cmd b/bacula/src/win32/scripts/disk-changer.cmd new file mode 100644 index 0000000000..4deb4e9ccb --- /dev/null +++ b/bacula/src/win32/scripts/disk-changer.cmd @@ -0,0 +1,201 @@ +@ECHO off +setlocal ENABLEDELAYEDEXPANSION +REM +REM +REM Bacula interface to virtual autoloader using disk storage +REM +REM $Id: disk-changer.in,v 1.3 2006/07/30 16:00:32 kerns Exp $ +REM +REM If you set in your Device resource +REM +REM Changer Command = "disk-changer %c %o %S %a %d" +REM you will have the following input to this script: +REM +REM So Bacula will always call with all the following arguments, even though +REM in some cases, not all are used. +REM +REM disk-changer "changer-device" "command" "slot" "archive-device" "drive-index" +REM %1 %2 %3 %4 %5 +REM +REM By default the autochanger has 10 Volumes and 1 Drive. +REM +REM Note: For this script to work, you *must" specify +REM Device Type = File +REM in each of the Devices associated with your AutoChanger resource. +REM +REM changer-device is the name of a file that overrides the default +REM volumes and drives. It may have: +REM maxslot=n where n is one based (default 10) +REM maxdrive=m where m is zero based (default 1 -- i.e. 2 drives) +REM +REM This code can also simulate barcodes. You simply put +REM a list of the slots and barcodes in the "base" directory/barcodes. +REM See below for the base directory definition. Example of a +REM barcodes file: +REM C:\TEMP\bacula\barcodes +REM 1:Vol001 +REM 2:Vol002 +REM ... +REM +REM archive-device is the name of the base directory where you want the +REM Volumes stored appended with \drive0 for the first drive; \drive1 +REM for the second drive, ... For example, you might use +REM C:\Temp\bacula\drive0 Note: you must not have a trailing slash, and +REM the string (e.g. \drive0) must be unique, and it must not match +REM any other part of the directory name. These restrictions could be +REM easily removed by any clever script jockey. +REM +REM Full example: disk-changer C:\Temp\bacula\conf load 1 C:\Temp\bacula\drive0 0 +REM +REM The Volumes will be created with names slot1, slot2, slot3, ... maxslot in the +REM base directory. In the above example the base directory is C:\Temp\bacula. +REM However, as with tapes, their Bacula Volume names will be stored inside the +REM Volume label. In addition to the Volumes (e.g. C:\Temp\bacula\slot1, +REM C:\Temp\bacula\slot3, ...) this script will create a C:\Temp\bacula\loadedn +REM file to keep track of what Slot is loaded. You should not change this file. +REM + +SET dbgfile=%CD%\disk-changer.log + +REM to turn on logging, uncomment the following line +IF NOT EXIST %dbgfile% COPY nul %dbgfile% >nul + +REM +REM check parameter count on commandline +REM +REM Check for special cases where only 2 arguments are needed, +REM all others are a minimum of 5 +REM +IF "%1" EQU "" goto :param_count_invalid +IF "%2" EQU "" goto :param_count_invalid +IF "%2" EQU "list" goto :param_count_valid +IF "%2" EQU "slots" goto :param_count_valid +IF "%3" EQU "" goto :param_count_invalid +IF "%4" EQU "" goto :param_count_invalid +IF "%5" EQU "" goto :param_count_invalid +GOTO :param_count_valid + +:param_count_invalid + echo Insufficient number of arguments given. + IF "%2" EQU "" ( + echo At least two arguments must be specified. + ) else echo Command expected 5 arguments. +:usage + ECHO. + ECHO usage: disk-changer ctl-device command [slot archive-device drive-index] + ECHO Valid commands are: unload, load, list, loaded, and slots. + EXIT /B 1 + +:param_count_valid + +REM Setup arguments +SET ctl=%1 +SET cmd=%2 +SET slot=%3 +SET device=%4 +SET drive=%5 + +REM set defaults +SET maxdrive=1 +SET maxslot=10 + +SET ctl=%ctl:/=\% +SET ctl=%ctl:\\=\% + +SET device=%device:/=\% +SET device=%device:\\=\% + +REM Pull in conf file +IF EXIST %ctl% CALL %ctl% + +FOR %%i IN ( %ctl% ) DO SET dirname=%%~dpi +IF NOT EXIST %dirname%nul ( + ECHO ERROR: Autochanger directory "%dirname%" does not exist. + ECHO You must create it. + EXIT /b 1 +) + +CALL :debug "Parms: %ctl% %cmd% %slot% %device% %drive%" +IF "%cmd%" EQU "unload" GOTO :cmdUnload +IF "%cmd%" EQU "load" GOTO :cmdLoad +IF "%cmd%" EQU "list" GOTO :cmdList +IF "%cmd%" EQU "loaded" GOTO :cmdLoaded +IF "%cmd%" EQU "slots" GOTO :cmdSlots +GOTO :cmdUnknown + +:cmdUnload + CALL :debug "Doing disk -f %ctl% unload %slot% %device% %drive%" + IF NOT EXIST %dirname%loaded%drive% ECHO 0 >%dirname%loaded%drive% + FOR /f %%i IN ( %dirname%loaded%drive% ) DO SET ld=%%i + + IF "%slot%" EQU "%ld%" ( + CALL :debug "Unloaded slot %ld% from drive %drive%" + ECHO 0 >%dirname%loaded%drive% + DEL %dirname%%device% >nul 2>nul + SET rtn=0 + ) ELSE ( + ECHO Storage Element %slot% is Already Full + CALL :debug "Storage Element %slot% is Already Full" + SET rtn=1 + ) + GOTO :cmdExit + +:cmdLoad + CALL :debug "Doing disk -f %ctl% load %slot% %device% %drive%" + SET ld=0 + IF NOT EXIST %dirname%loaded%drive% ECHO 0 >%dirname%loaded%drive% + FOR /f %%i IN ( %dirname%loaded%drive% ) DO SET ld=%%i + IF %ld% EQU 0 ( + IF NOT EXIST %dirname%slot%slot% COPY nul %dirname%slot%slot% >nul + DEL %device% + fsutil hardlink create %device% %dirname%slot%slot% >nul 2>&1 + SET rtn=%ERRORLEVEL% + IF !rtn! EQU 0 ( + ECHO %slot% >%dirname%loaded%drive% + CALL :debug "Loaded slot %slot% into drive %drive%" + ) ELSE ( + CALL :debug "Create hardlink failed, return = !rtn!" + ) + ) ELSE ( + ECHO Drive %drive% Full - Storage element %ld% loaded + CALL :debug "Drive %drive% Full - Storage element %ld% loaded" + ) + GOTO :cmdExit + +:cmdList + CALL :debug "Doing disk -f %ctl% -- to list volumes" + IF EXIST %dirname%barcodes ( + TYPE %dirname%barcodes + ) ELSE ( + FOR /l %%i IN ( 1, 1, %maxslot% ) DO ECHO %%i: + ) + SET rtn=0 + GOTO :cmdExit + +:cmdLoaded + CALL :debug "Doing disk -f %ctl% %drive% -- to find what is loaded" + IF EXIST %dirname%loaded%drive% ( TYPE %dirname%loaded%drive% ) ELSE ECHO 0 + SET rtn=0 + GOTO :cmdExit + +:cmdSlots + CALL :debug "Doing disk -f %ctl% -- to get count of slots" + ECHO %maxslot% + SET rtn=0 + GOTO :cmdExit + +:cmdExit + EXIT /b %rtn% + +:cmdUnknown + ECHO '%cmd%' is an invalid command. + GOTO :usage + +REM +REM log whats done +REM +:debug + IF NOT EXIST %dbgfile% GOTO :EOF + FOR /f "usebackq tokens=2-4,5-7 delims=/:. " %%i IN ( '%DATE% %TIME%' ) do SET TIMESTAMP=%%k%%i%%j-%%l:%%m:%%n + ECHO %TIMESTAMP% %* >> %dbgfile% + GOTO :EOF diff --git a/bacula/src/win32/scripts/dvd-handler.cmd b/bacula/src/win32/scripts/dvd-handler.cmd new file mode 100644 index 0000000000..017edf335c --- /dev/null +++ b/bacula/src/win32/scripts/dvd-handler.cmd @@ -0,0 +1,383 @@ +@ECHO off +REM !@PYTHON@ +REM +REM Check the free space available on a writable DVD +REM Should always exit with 0 status, otherwise it indicates a serious error. +REM (wrong number of arguments, Python exception...) +REM +REM called: dvd-handler operation args +REM +REM operations used by Bacula: +REM +REM free (no arguments) +REM Scan the device and report the available space. It returns: +REM Prints on the first output line the free space available in bytes. +REM If an error occurs, prints a negative number (-errno), followed, +REM on the second line, by an error message. +REM +REM write op filename +REM Write a part file to disk. +REM This operation needs two additional arguments. +REM The first (op) indicates to +REM 0 -- append +REM 1 -- first write to a blank disk +REM 2 -- blank or truncate a disk +REM +REM The second is the filename to write +REM +REM operations available but not used by Bacula: +REM +REM test Scan the device and report the information found. +REM This operation needs no further arguments. +REM prepare Prepare a DVD+/-RW for being used by Bacula. +REM Note: This is only useful if you already have some +REM non-Bacula data on a medium, and you want to use +REM it with Bacula. Don't run this on blank media, it +REM is useless. +REM +REM +REM $Id: dvd-handler.in,v 1.11 2006/08/30 16:19:30 kerns Exp $ +REM + +setlocal ENABLEDELAYEDEXPANSION + +REM Configurable values: + +SET self_dvdrwmediainfo=dvd+rw-mediainfo.exe +SET self_growcmd=growisofs.exe +SET self_dvdrwformat=dvd+rw-format.exe +SET self_dd=dd.exe +SET self_margin=5120 + +REM Comment the following line if you want the tray to be reloaded +REM when writing ends. +SET self_growcmd=%self_growcmd% -use-the-force-luke^^^^^=notray + +REM end of configurable values + +IF "%1" == "" GOTO :usage +IF "%2" == "" GOTO :usage + +CALL :init %1 + +IF "%2" == "free" ( + CALL :free + ECHO !ERRORLEVEL! + ECHO No Error reported. +) ELSE IF "%2" == "prepare" ( + CALL :prepare + ECHO Medium prepared successfully. +) ELSE IF "%2" == "test" ( + IF %self_freespace_collected% EQU 0 CALL :collect_freespace + IF %self_mediumtype_collected% EQU 0 CALL :collect_mediumtype + ECHO Class disk, initialized with device %self_device% + ECHO type = '!self_disktype!' mode='!self_diskmode!' status = '!self_diskstatus!' + ECHO next_session = !self_next_session! capacity = !self_capacity! + ECHO Hardware device is '!self_hardwaredevice!' + ECHO growcmd = '!self_growcmd!' + ECHO growparams = '!self_growparams!' + ECHO. + SET empty_disk=false + CALL :is_blank + IF !ERRORLEVEL! EQU 1 SET empty_disk=true + SET rewritable=false + CALL :is_RW + IF !ERRORLEVEL! EQU 1 SET rewritable=true + SET plus_RW_disk=false + CALL :is_plus_RW + IF !ERRORLEVEL! EQU 1 SET plus_RW_disk=true + SET minus_RW_disk=false + CALL :is_minus_RW + IF !ERRORLEVEL! EQU 1 SET minus_RW_disk=true + SET restricted_overwrite_disk=false + CALL :is_restricted_overwrite + IF !ERRORLEVEL! EQU 1 SET restricted_overwrite_disk=true + SET blank_disk=false + CALL :is_blank + IF !ERRORLEVEL! EQU 1 SET blank_disk=true + ECHO Empty disk: !empty_disk! Blank Disk: !blank_disk! ReWritable disk: !rewritable! + ECHO Plus RW: !plus_RW_disk! Minus RW: !minus_RW_disk! Restricted Overwrite: !restricted_overwrite_disk! + CALL :free + ECHO Free space: !ERRORLEVEL! +) ELSE IF "%2" == "write" ( + IF "%3" == "" GOTO :usage + IF "%4" == "" GOTO :usage + CALL :write %3 %4 + ECHO Part file %4 successfully written to disk. +) ELSE ( + ECHO No operation - use test, free, prepare or write. + ECHO THIS MIGHT BE A CASE OF DEBUGGING BACULA OR AN ERROR! +) +EXIT /b 0 + +REM ############################################################################## +REM +REM This class represents DVD disk informations. +REM When instantiated, it needs a device name. +REM Status information about the device and the disk loaded is collected only when +REM asked for (for example dvd-freespace doesn't need to know the media type, and +REM dvd-writepart doesn't not always need to know the free space). +REM +REM The following methods are implemented: +REM __init__ we need that... +REM __repr__ this seems to be a good idea to have. +REM Quite minimalistic implementation, though. +REM __str__ For casts to string. Return the current disk information +REM is_empty Returns TRUE if the disk is empty, blank... this needs more +REM work, especially concerning non-RW media and blank vs. no +REM filesystem considerations. Here, we should also look for +REM other filesystems - probably we don't want to silently +REM overwrite UDF or ext2 or anything not mentioned in fstab... +REM (NB: I don't think it is a problem) +REM free Returns the available free space. +REM write Writes one part file to disk, either starting a new file +REM system on disk, or appending to it. +REM This method should also prepare a blank disk so that a +REM certain part of the disk is used to allow detection of a +REM used disk by all / more disk drives. +REM blank Blank the device +REM +REM ############################################################################## +:init +SET self_device=%1 +SET self_disktype=none +SET self_diskmode=none +SET self_diskstatus=none +SET self_hardwaredevice=none +SET self_pid=0 +SET self_next_session=-1 +SET self_capacity=-1 + +SET self_freespace_collected=0 +SET self_mediumtype_collected=0 + +SET self_growcmd=%self_growcmd% -quiet -use-the-force-luke^^^=4gms + +SET self_growparams=-A "Bacula Data" -input-charset=default -iso-level 3 -pad +SET self_growparams=%self_growparams% -p "dvd-handler / growisofs" -sysid "BACULADATA" -R +GOTO :EOF + +:collect_freespace +SET self_next_session=0 +SET self_capacity=0 +FOR /f "delims== tokens=1*" %%i in ( '%self_growcmd% -F %self_device%' ) DO ( + IF "%%i" == "next_session" ( + SET self_next_session=%%j + ) ELSE IF "%%i" == "capacity" ( + SET self_capacity=%%j + ) ELSE IF "%%j" == "" ( + SET result=!result! %%i + ) ELSE ( + SET RESULT=!result! %%i=%%j + ) +) +SET status=%ERRORLEVEL% +IF %STATUS% NEQ 0 ( + SET /a STATUS=STATUS ^& 0x7F + IF !STATUS! EQU 112 ( + REM Kludge to force dvd-handler to return a free space of 0 + self_next_session = 1 + self_capacity = 1 + self_freespace_collected = 1 + GOTO :EOF + ) ELSE ( + ECHO growisofs returned with an error !STATUS!. Please check your are using a patched version of dvd+rw-tools. + EXIT !STATUS! + ) +) + +IF %self_next_session% EQU 0 IF %self_capacity% EQU 0 ( + ECHO Cannot get next_session and capacity from growisofs. + ECHO Returned: %result:|=^|% + EXIT 1 +) +SET self_freespace_collected=1 +GOTO :EOF + +:collect_mediumtype +SET self_hardwaredevice= +SET self_disktype= +SET self_diskmode= +SET self_diskstatus= +SET self_lasterror= +FOR /f "delims=: tokens=1,2 usebackq" %%i in ( `"%self_dvdrwmediainfo%" %self_device%` ) DO ( + IF "%%i" == "INQUIRY" FOR /f "tokens=*" %%k in ( "%%j" ) DO SET self_hardwaredevice=%%k + IF "%%i" == " Mounted Media" FOR /f "tokens=1,2* delims=, " %%k in ( "%%j" ) DO ( + SET self_disktype=%%l + SET self_diskmode=%%m + ) + IF "%%i" == " Disc status" FOR /f "tokens=*" %%k in ( "%%j" ) DO SET self_diskstatus=%%k +) + +IF NOT DEFINED self_disktype ( + ECHO Media type not found in %self_dvdrwmediainfo% output + EXIT 1 +) + +IF "%self_disktype%" == "DVD-RW" IF NOT DEFINED self_diskmode ( + ECHO Media mode not found for DVD-RW in %self_dvdrwmediainfo% output + EXIT 1 +) + +IF NOT DEFINED self_diskstatus ( + ECHO Disc status not found in %self_dvdrwmediainfo% output + EXIT 1 +) + +SET self_mediumtype_collected=1 +GOTO :EOF + +:is_empty +IF %self_freespace_collected% EQU 0 CALL :collect_freespace +IF %self_next_session% EQU 0 ( EXIT /b 1 ) ELSE EXIT /b 0 + +:is_RW +IF %self_mediumtype_collected% EQU 0 CALL :collect_mediumtype +IF %self_disktype% == "DVD-RW" EXIT /b 1 +IF %self_disktype% == "DVD+RW" EXIT /b 1 +IF %self_disktype% == "DVD-RAM" EXIT /b 1 +EXIT /b 0 + +:is_plus_RW +IF %self_mediumtype_collected% EQU 0 CALL :collect_mediumtype +IF "%self_disktype%" == "DVD+RW" EXIT /b 1 +EXIT /b 0 + +:is_minus_RW +IF %self_mediumtype_collected% EQU 0 CALL :collect_mediumtype +IF "%self_disktype%" == "DVD-RW" EXIT /b 1 +EXIT /b 0 + +:is_restricted_overwrite +IF %self_mediumtype_collected% EQU 0 CALL :collect_mediumtype +IF "%self_diskmode%" == "Restricted Overwrite" EXIT /b 1 +EXIT /b 0 + +:is_blank +IF %self_mediumtype_collected% EQU 0 CALL :collect_mediumtype +IF "%self_diskstatus%" == "blank" EXIT /b 1 +EXIT /b 0 + +:free +IF %self_freespace_collected% EQU 0 CALL :collect_freespace +SET /a fr=self_capacity - self_next_session - self_margin +IF %fr% LSS 0 ( EXIT /b 0 ) ELSE EXIT /b %fr% + +REM %1 - newvol, %2 - partfile +:write +REM Blank DVD+RW when there is no data on it +CALL :is_plus_RW +SET tmpvar=%ERRORLEVEL% +CALL :is_blank +SET /a tmpvar=tmpvar + ERRORLEVEL +IF %1 EQU 1 IF %tmpvar% EQU 2 ( + ECHO DVD+RW looks brand-new, blank it to fix some DVD-writers bugs. + CALL :blank + ECHO Done, now writing the part file. +) +CALL :is_minus_RW +IF %ERRORLEVEL% NEQ 0 IF %1 NEQ 0 ( + CALL :is_restricted_overwrite + IF !ERRORLEVEL! EQU 0 ( + ECHO DVD-RW is in %self_diskmode% mode, reformating it to Restricted Overwrite + CALL :reformat_minus_RW + ECHO Done, now writing the part file. + ) +) +if %1 NEQ 0 ( + REM Ignore any existing iso9660 filesystem - used for truncate + if %1 EQU 2 ( + SET cmd_opts= -use-the-force-luke^^^=tty -Z + ) ELSE ( + SET cmd_opts= -Z + ) +) ELSE ( + SET cmd_opts= -M +) +ECHO Running %self_growcmd% %self_growparams% %cmd_opts% %self_device% %2 +%self_growcmd% %self_growparams% %cmd_opts% %self_device% %2 +IF %ERRORLEVEL% NEQ 0 ( + ECHO Exited with status !ERRORLEVEL! + EXIT !ERRORLEVEL! +) +GOTO :EOF + +:prepare +CALL :is_RW +IF %ERRORLEVEL% EQU 0 ( + ECHO I won't prepare a non-rewritable medium + EXIT /b 1 +) + +REM Blank DVD+RW when there is no data on it +CALL :is_plus_RW +SET result=%ERRORLEVEL% +CALL :is_blank +SET /a result=result + ERRORLEVEL +IF %result% EQU 2 ( + ECHO DVD+RW looks brand-new, blank it to fix some DVD-writers bugs. + CALL :blank + GOTO :EOF +) + +CALL :is_minus_RW +IF %ERRORLEVEL% EQU 1 ( + CALL :is_restricted_overwrite + IF !ERRORLEVEL! EQU 0 ( + ECHO DVD-RW is in %self_diskmode% mode, reformating it to Restricted Overwrite + CALL :reformat_minus_RW + GOTO :EOF + ) +) + +CALL :blank +GOTO :EOF + +:blank +ECHO Running %self_growcmd% -Z %self_device% =/dev/zero +%self_growcmd% -Z %self_device% =/dev/zero +IF %ERRORLEVEL% NEQ 0 ( + ECHO Exited with status !ERRORLEVEL! + EXIT !ERRORLEVEL! +) +GOTO :EOF + +:reformat_minus_RW +ECHO Running %self_dvdrwformat% -force %self_device% +%self_dvdrwformat% -force %self_device% +IF %ERRORLEVEL% NEQ 0 ( + ECHO Exited with status !ERRORLEVEL! + EXIT !ERRORLEVEL! +) +GOTO :EOF + +REM class disk ends here. + +:usage +ECHO Wrong number of arguments. +ECHO. +ECHO Usage: +ECHO. +ECHO dvd-handler DVD-DRIVE test +ECHO dvd-handler DVD-DRIVE free +ECHO dvd-handler DVD-DRIVE write APPEND FILE +ECHO dvd-handler DVD-DRIVE blank +ECHO. +ECHO where DVD-DRIVE is the drive letter of the DVD burner like D: +ECHO. +ECHO Operations: +ECHO test Scan the device and report the information found. +ECHO This operation needs no further arguments. +ECHO free Scan the device and report the available space. +ECHO write Write a part file to disk. +ECHO This operation needs two additional arguments. +ECHO The first indicates to append (0), restart the +ECHO disk (1) or restart existing disk (2). The second +ECHO is the file to write. +ECHO prepare Prepare a DVD+/-RW for being used by Bacula. +ECHO Note: This is only useful if you already have some +ECHO non-Bacula data on a medium, and you want to use +ECHO it with Bacula. Don't run this on blank media, it +ECHO is useless. + +EXIT /b 1 -- 2.39.5