build on win32

This commit is contained in:
David Rose 2009-06-16 20:02:03 +00:00
parent 503e28dd82
commit 0c123b6bce
2 changed files with 34 additions and 12 deletions

View File

@ -11,6 +11,12 @@ make_package.py [opts]
Options:
-s source_dir
Specify the source directory. This is the root directory that
contains the package contents. The default is the current
directory.
-d stage_dir
Specify the staging directory. This is a temporary directory on
@ -91,7 +97,7 @@ class PackageMaker:
print "\ncompressing"
source = open(uncompressedArchivePathname.toOsSpecific(), 'rb')
target = open(compressedArchivePathname.toOsSpecific(), 'w')
target = open(compressedArchivePathname.toOsSpecific(), 'wb')
z = zlib.compressobj(9)
data = source.read(4096)
while data:
@ -152,12 +158,14 @@ class PackageMaker:
self.archive.addSubfile(file.filename, file.pathname, 0)
def makePackage(args):
opts, args = getopt.getopt(args, 'd:p:v:h')
opts, args = getopt.getopt(args, 's:d:p:v:h')
pm = PackageMaker()
pm.startDir = Filename('.')
for option, value in opts:
if option == '-d':
if option == '-s':
pm.startDir = Filename.fromOsSpecific(value)
elif option == '-d':
pm.stageDir = Filename.fromOsSpecific(value)
elif option == '-p':
pm.packageName = value

View File

@ -25,13 +25,17 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <utime.h>
#ifdef _WIN32
#include <sys/utime.h>
#include <direct.h>
#define stat _stat
#define utime _utime
#define utimbuf _utimbuf
#else
#include <utime.h>
#endif
////////////////////////////////////////////////////////////////////
@ -314,29 +318,38 @@ uncompress_archive() {
report_done(false);
return;
}
static const int decompress_buffer_size = 1024;
char decompress_buffer[decompress_buffer_size];
static const int write_buffer_size = 1024;
char write_buffer[write_buffer_size];
z_stream z;
z.next_in = Z_NULL;
z.avail_in = 0;
z.next_out = Z_NULL;
z.avail_out = 0;
z.zalloc = Z_NULL;
z.zfree = Z_NULL;
z.opaque = Z_NULL;
z.msg = (char *)"no error message";
bool eof = false;
int flush = 0;
source.read(decompress_buffer, decompress_buffer_size);
size_t read_count = source.gcount();
eof = (read_count == 0 || source.eof() || source.fail());
z.next_in = (Bytef *)decompress_buffer;
z.avail_in = read_count;
int result = inflateInit(&z);
if (result < 0) {
cerr << z.msg << "\n";
report_done(false);
return;
}
static const int decompress_buffer_size = 1024;
char decompress_buffer[decompress_buffer_size];
static const int write_buffer_size = 1024;
char write_buffer[write_buffer_size];
bool eof = false;
int flush = 0;
while (true) {
if (z.avail_in == 0 && !eof) {
@ -656,6 +669,7 @@ quick_verify(const string &package_dir) const {
if (st.st_mtime == _timestamp) {
// If the size is right and the timestamp is right, the file passes.
cerr << "file ok: " << _filename << "\n";
return true;
}