/contrib/other/kpm/7z/7z.c |
---|
6,6 → 6,7 |
#include "7zCrc.h" |
#include "7zFile.h" |
#include "7zVersion.h" |
#include "http.h" |
#include "package.h" |
#define PERIOD_4 (4 * 365 + 1) |
323,11 → 324,11 |
} |
void do_install(list_t *install) |
void do_7z_unpack(const char *srcpath) |
{ |
CFileInStream archiveStream; |
CLookToRead lookStream; |
CSzArEx db; |
SRes res; |
ISzAlloc allocImp; |
335,8 → 336,7 |
UInt16 *temp = NULL; |
size_t tempSize = 0; |
package_t *pkg, *tmp; |
char *cache_path; |
memset(&lookStream,0,sizeof(lookStream)); |
allocImp.Alloc = SzAlloc; |
allocImp.Free = SzFree; |
344,19 → 344,15 |
allocTempImp.Alloc = SzAllocTemp; |
allocTempImp.Free = SzFreeTemp; |
list_for_each_entry_safe(pkg, tmp, install, list) |
{ |
cache_path = make_cache_path(pkg->filename); |
if (InFile_Open(&archiveStream.file, srcpath)) |
return; |
if (InFile_Open(&archiveStream.file, cache_path)) |
continue; |
FileInStream_CreateVTable(&archiveStream); |
LookToRead_CreateVTable(&lookStream, False); |
lookStream.realStream = &archiveStream.s; |
LookToRead_Init(&lookStream); |
CrcGenerateTable(); |
SzArEx_Init(&db); |
res = SzArEx_Open(&db, &lookStream.s, &allocImp, &allocTempImp); |
421,15 → 417,10 |
for (j = 0; name[j] != 0; j++) |
if (name[j] == '/') |
{ |
if (1) |
{ |
name[j] = 0; |
MyCreateDir(name); |
name[j] = CHAR_PATH_SEPARATOR; |
} |
else |
destPath = name + j + 1; |
} |
if (isDir) |
{ |
448,7 → 439,7 |
if (File_Write(&outFile, outBuffer + offset, &processedSize) != 0 || processedSize != outSizeProcessed) |
{ |
PrintError("can not write output file"); |
PrintError("can not write output file\n"); |
res = SZ_ERROR_FAIL; |
break; |
} |
455,15 → 446,34 |
if (File_Close(&outFile)) |
{ |
PrintError("can not close output file"); |
PrintError("can not close output file\n"); |
res = SZ_ERROR_FAIL; |
break; |
} |
}; |
continue; |
}; |
IAlloc_Free(&allocImp, outBuffer); |
}; |
SzArEx_Free(&db, &allocImp); |
SzFree(NULL, temp); |
File_Close(&archiveStream.file); |
}; |
void do_install(list_t *install) |
{ |
package_t *pkg, *tmp; |
char *cache_path; |
list_for_each_entry_safe(pkg, tmp, install, list) |
{ |
cache_path = make_cache_path(pkg->filename); |
sprintf(conbuf,"install package %s-%s\n", pkg->name, pkg->version); |
con_write_asciiz(conbuf); |
do_7z_unpack(cache_path); |
list_del_pkg(pkg); |
}; |
}; |
/contrib/other/kpm/7z/LzmaDec.c |
---|
6,6 → 6,7 |
#include "LzmaDec.h" |
#include <string.h> |
#include <stdio.h> |
#define kNumTopBits 24 |
#define kTopValue ((UInt32)1 << kNumTopBits) |
439,13 → 440,14 |
{ |
if (distance >= processedPos) |
{ |
p->dicPos = dicPos; |
printf("%s fail line %d distance %d processedPos %d\n", |
__FUNCTION__,__LINE__,distance,processedPos ); |
return SZ_ERROR_DATA; |
} |
} |
else if (distance >= checkDicSize) |
{ |
p->dicPos = dicPos; |
printf("%s fail line %d\n", __FUNCTION__,__LINE__); |
return SZ_ERROR_DATA; |
} |
state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3; |
/contrib/other/kpm/Makefile |
---|
8,7 → 8,7 |
CPP= kos32-g++ |
STRIP = kos32-strip |
CFLAGS = -U_Win32 -U_WIN32 -U__MINGW32__ -c -Os -fno-ident -fomit-frame-pointer -mno-ms-bitfields |
CFLAGS = -U_Win32 -U_WIN32 -U__MINGW32__ -c -Os -fomit-frame-pointer -fno-asynchronous-unwind-tables -fno-ident -fomit-frame-pointer -mno-ms-bitfields |
ARFLAG = crs |
SDK_DIR:= $(abspath ../../sdk) |
17,11 → 17,12 |
INCLUDES= -I. -I$(SDK_DIR)/sources/newlib/libc/include |
INCLUDES+=-I$(SDK_DIR)/sources/freetype/include |
#DEFINES= -DDEBUG=1 |
#DEFINES= -DDEBUG=1 -D_7ZIP_PPMD_SUPPPORT |
DEFINES= -DNDEBUG |
LIBS:= -liberty -lsupc++ -lgcc_eh -lc.dll -lapp -lgcc |
LIBS:= -liberty -lsupc++ -lgcc_eh -lc.dll -lapp -lgcc -lc.dll |
LIBPATH:= -L$(LIB_DIR) -L/home/autobuild/tools/win32/mingw32/lib |
LDFLAGS = -static -nostdlib --stack 0x10000 -Map kpm.map -T$(SDK_DIR)/sources/newlib/app.lds --image-base 0 |
51,7 → 52,6 |
7z/Bra86.c \ |
7z/BraIA64.c \ |
7z/7zAlloc.c \ |
7z/Alloc.c \ |
$(NULL) |
OBJECTS = $(patsubst %.asm, %.o, $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SOURCES)))) |
68,7 → 68,7 |
$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ $< |
%.o : %.cpp Makefile |
$(CPP) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ $< |
$(CPP) $(CFLAGS) -fno-rtti -fno-exceptions $(DEFINES) $(INCLUDES) -o $@ $< |
%.o : %.asm Makefile |
$(FASM) $< $@ |
/contrib/other/kpm/app.lds |
---|
0,0 → 1,129 |
/*OUTPUT_FORMAT("binary")*/ |
ENTRY(__start) |
SECTIONS |
{ |
.text 0x000000: |
{ |
LONG(0x554e454D); |
LONG(0x32305445); |
LONG(1); |
LONG(__start); |
LONG(___iend); |
LONG(___memsize); |
LONG(___stacktop); |
LONG(___cmdline); |
LONG(___pgmname); /* full path */ |
LONG(0); /*FIXME tls data */ |
LONG(__idata_start) |
LONG(__idata_end) |
LONG(_main) |
*(.init) |
*(.text) |
*(SORT(.text$*)) |
*(.text.*) |
*(.glue_7t) |
*(.glue_7) |
___CTOR_LIST__ = .; __CTOR_LIST__ = . ; |
LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*)); LONG (0); |
___DTOR_LIST__ = .; __DTOR_LIST__ = . ; |
LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*)); LONG (0); |
*(.fini) |
/* ??? Why is .gcc_exc here? */ |
*(.gcc_exc) |
PROVIDE (etext = .); |
*(.gcc_except_table) |
} |
.rdata ALIGN(32) : |
{ |
*(.rdata) |
*(SORT(.rdata$*)) |
___RUNTIME_PSEUDO_RELOC_LIST__ = .; |
__RUNTIME_PSEUDO_RELOC_LIST__ = .; |
*(.rdata_runtime_pseudo_reloc) |
___RUNTIME_PSEUDO_RELOC_LIST_END__ = .; |
__RUNTIME_PSEUDO_RELOC_LIST_END__ = .; |
} |
.CRT ALIGN(32) : |
{ |
___crt_xc_start__ = . ; |
*(SORT(.CRT$XC*)) /* C initialization */ |
___crt_xc_end__ = . ; |
___crt_xi_start__ = . ; |
*(SORT(.CRT$XI*)) /* C++ initialization */ |
___crt_xi_end__ = . ; |
___crt_xl_start__ = . ; |
*(SORT(.CRT$XL*)) /* TLS callbacks */ |
/* ___crt_xl_end__ is defined in the TLS Directory support code */ |
___crt_xp_start__ = . ; |
*(SORT(.CRT$XP*)) /* Pre-termination */ |
___crt_xp_end__ = . ; |
___crt_xt_start__ = . ; |
*(SORT(.CRT$XT*)) /* Termination */ |
___crt_xt_end__ = . ; |
} |
.data ALIGN(32) : |
{ |
PROVIDE ( __data_start__ = .) ; |
*(.data) |
*(.data2) |
*(SORT(.data$*)) |
*(.jcr) |
__CRT_MT = .; |
LONG(0); |
PROVIDE ( __data_end__ = .) ; |
*(.data_cygwin_nocopy) |
___iend = . ; |
} |
.idata ALIGN(32): |
{ |
__idata_start = .; |
SORT(*)(.idata$2) |
SORT(*)(.idata$3) |
/* These zeroes mark the end of the import list. */ |
LONG (0); LONG (0); LONG (0); LONG (0); LONG (0); |
SORT(*)(.idata$4) |
SORT(*)(.idata$5) |
SORT(*)(.idata$6) |
SORT(*)(.idata$7) |
__idata_end = . ; |
} |
bss ALIGN(32): |
{ |
*(.bss) |
*(COMMON) |
. = ALIGN(16); |
___cmdline = .; |
. = . + 256; |
___pgmname = .; |
. = . + 1024 + 16; |
___stacktop = .; |
___memsize = . ; |
} |
/DISCARD/ : |
{ |
*(.debug$S) |
*(.debug$T) |
*(.debug$F) |
*(.drectve) |
*(.note.GNU-stack) |
*(.eh_frame) |
*(.comment) |
*(.debug_abbrev) |
*(.debug_info) |
*(.debug_line) |
*(.debug_frame) |
*(.debug_loc) |
*(.debug_pubnames) |
*(.debug_aranges) |
*(.debug_ranges) |
} |
} |
/contrib/other/kpm/collection.cpp |
---|
1,23 → 1,39 |
#include "tinyxml/tinyxml.h" |
#include "package.h" |
// *INDENT-OFF* |
const char *key_collection = "collection"; |
const char *key_package = "package"; |
const char *key_name = "name"; |
const char *key_version = "version"; |
const char *key_group = "group"; |
const char *key_description = "description"; |
const char *key_title = "title"; |
const char *key_release = "release"; |
const char *key_file = "file"; |
// *INDENT-ON* |
int package_id; |
void parse_group(pkg_group_t* gr, TiXmlElement *xmlgroup) |
collection_t * |
load_collection_file(const char *name) |
{ |
TiXmlDocument doc; |
TiXmlElement *col; |
collection_t *collection = NULL; |
doc.LoadFile(name); |
col = doc.FirstChildElement(key_collection); |
if (col) |
{ |
TiXmlElement *xmlpkg; |
TiXmlElement *xmle; |
xmlpkg = xmlgroup->FirstChildElement(key_package); |
collection = (collection_t *) malloc(sizeof(collection_t)); |
INIT_LIST_HEAD(&collection->packages); |
xmlpkg = col->FirstChildElement(key_package); |
while (xmlpkg) |
{ |
package_t *pkg; |
25,9 → 41,11 |
pkg = (package_t*)malloc(sizeof(package_t)); |
INIT_LIST_HEAD(&pkg->file_list); |
pkg->id = package_id++; |
pkg->name = strdup(xmlpkg->Attribute(key_name)); |
pkg->version = strdup(xmlpkg->Attribute(key_version)); |
pkg->group = strdup(xmlpkg->Attribute(key_group)); |
xmle = xmlpkg->FirstChildElement(key_description); |
pkg->description = strdup(xmle->Attribute(key_title)); |
35,41 → 53,10 |
xmle = xmlpkg->FirstChildElement(key_release); |
pkg->filename = strdup(xmle->Attribute(key_file)); |
list_add_tail(&pkg->list, &gr->packages); |
list_add_tail(&pkg->list, &collection->packages); |
xmlpkg = xmlpkg->NextSiblingElement(); |
}; |
}; |
collection_t* load_collection_file(const char *name) |
{ |
TiXmlDocument doc; |
TiXmlElement *col; |
collection_t *collection = NULL; |
doc.LoadFile(name); |
col = doc.FirstChildElement(key_collection); |
if (col) |
{ |
collection = (collection_t*)malloc(sizeof(collection_t)); |
INIT_LIST_HEAD(&collection->groups); |
TiXmlElement* xmlgroup = col->FirstChildElement(); |
if (xmlgroup) |
{ |
pkg_group_t *gr; |
gr = (pkg_group_t*)malloc(sizeof(pkg_group_t)); |
INIT_LIST_HEAD(&gr->list); |
INIT_LIST_HEAD(&gr->packages); |
gr->name = strdup(xmlgroup->Value()); |
list_add_tail(&gr->list, &collection->groups); |
parse_group(gr, xmlgroup); |
return collection; |
}; |
}; |
return collection; |
} |
/contrib/other/kpm/kpm.c |
---|
8,10 → 8,10 |
#include "package.h" |
#include "http.h" |
void process_task(list_t *task); |
#define BUFFSIZE (64*1024) |
extern char conbuf[256]; |
#define OPTION_STD_BASE 150 |
enum option_values |
18,7 → 18,8 |
{ |
OPTION_HELP = OPTION_STD_BASE, |
OPTION_LIST_PACKAGES, |
OPTION_LIST_INSTALLED |
OPTION_LIST_INSTALLED, |
OPTION_INSTALL_ALL |
}; |
static const struct option longopts[] = |
25,9 → 26,32 |
{ |
{"list-packages", no_argument, NULL, OPTION_LIST_PACKAGES}, |
{"list-installed",no_argument, NULL, OPTION_LIST_INSTALLED}, |
{"install-all",no_argument, NULL, OPTION_INSTALL_ALL}, |
{NULL,0,NULL,0} |
}; |
static void show_usage () |
{ |
sprintf (conbuf, "Usage: kpm [option...]\n"); |
con_write_asciiz(conbuf); |
sprintf (conbuf, ("\ |
Options:\n\ |
--list-packages\n\ |
show available packages\n")); |
con_write_asciiz(conbuf); |
sprintf (conbuf, ("\ |
--list-installed\n\ |
show available packages\n")); |
con_write_asciiz(conbuf); |
sprintf (conbuf, ("\ |
--install all\n\ |
install all packages\n")); |
con_write_asciiz(conbuf); |
}; |
int main(int argc, char *argv[]) |
{ |
LIST_HEAD(server_list); |
39,6 → 63,7 |
int count; |
char *cache_path; |
char *tmp_path; |
int act = 1; |
if(http_init()) |
goto err_init; |
54,7 → 79,7 |
if(count) |
build_server_list(&server_list, tmp_path); |
while(1) |
while(act) |
{ |
int val; |
int index; |
61,9 → 86,6 |
val = getopt_long_only(argc, argv,"",longopts, &index); |
if(val == -1) |
break; |
switch(val) |
{ |
case OPTION_LIST_PACKAGES: |
70,46 → 92,28 |
sprintf(conbuf,"available packages:\n\n"); |
con_write_asciiz(conbuf); |
print_pkg_list(&server_list); |
con_exit(0); |
return 0; |
act = 0; |
break; |
case OPTION_LIST_INSTALLED: |
sprintf(conbuf,"installed packages:\n\n"); |
con_write_asciiz(conbuf); |
print_pkg_list(&local_list); |
con_exit(0); |
return 0; |
act = 0; |
break; |
case OPTION_INSTALL_ALL: |
copy_list(&task_list, &server_list); |
process_task(&task_list); |
act = 0; |
break; |
default: |
break; |
show_usage(); |
act = 0; |
} |
}; |
#if 0 |
{ |
package_t *pkg; |
LIST_HEAD(install_list); |
LIST_HEAD(download_list); |
if(collection && build_install_list(&install_list, collection)) |
{ |
if(build_download_list(&download_list, &install_list)) |
do_download(&download_list); |
if(!list_empty(&download_list)) |
remove_missing_packages(&install_list, &download_list); |
list_for_each_entry(pkg, &install_list, list) |
{ |
sprintf(conbuf,"install package %s-%s\n", pkg->name, pkg->version); |
con_write_asciiz(conbuf); |
}; |
do_install(&install_list); |
}; |
} |
#endif |
con_exit(0); |
return 0; |
119,6 → 123,3 |
return -1; |
} |
/contrib/other/kpm/package.h |
---|
8,17 → 8,10 |
typedef struct |
{ |
list_t groups; |
list_t packages; |
char *issue; |
}collection_t; |
typedef struct |
{ |
list_t list; |
list_t packages; |
char *name; |
}pkg_group_t; |
typedef struct package |
{ |
list_t list; |
26,6 → 19,7 |
int id; |
char *name; |
char *version; |
char *group; |
char *filename; |
char *description; |
}package_t; |
35,6 → 29,7 |
list_del(&pkg->list); |
free(pkg->description); |
free(pkg->filename); |
free(pkg->group); |
free(pkg->version); |
free(pkg->name); |
free(pkg); |
43,8 → 38,9 |
collection_t* load_collection_file(const char *name); |
collection_t* load_collection_buffer(const char *buffer); |
int copy_list(list_t *list, list_t *src); |
int build_server_list(list_t *slist, const char *path); |
int build_install_list(list_t *list, collection_t *collection); |
int build_download_list(list_t *download, list_t *src); |
void remove_missing_packages(list_t *install, list_t *missed); |
char *make_cache_path(const char *path); |
53,6 → 49,8 |
void do_download(list_t *download); |
void do_install(list_t *install); |
extern char conbuf[256]; |
#ifdef __cplusplus |
} |
#endif |
/contrib/other/kpm/utils.c |
---|
143,6 → 143,7 |
pkg->id = tmp->id; |
pkg->name = strdup(tmp->name); |
pkg->version = strdup(tmp->version); |
pkg->group = strdup(tmp->group); |
pkg->filename = strdup(tmp->filename); |
pkg->description = strdup(tmp->description); |
list_add_tail(&pkg->list, download); |
166,6 → 167,7 |
count = http_load_file(cache_path, make_url(pkg->filename)); |
sprintf(conbuf,"%s %d bytes loaded\n",cache_path, count); |
con_write_asciiz(conbuf); |
if( !test_archive(cache_path)) |
list_del_pkg(pkg); |
else |
192,17 → 194,13 |
}; |
}; |
int build_install_list(list_t *list, collection_t *collection) |
int copy_list(list_t *list, list_t *src) |
{ |
pkg_group_t *gr; |
package_t *pkg, *tmp; |
int count = 0; |
list_for_each_entry(gr, &collection->groups, list) |
list_for_each_entry(tmp, src, list) |
{ |
package_t *pkg, *tmp; |
list_for_each_entry(tmp, &gr->packages, list) |
{ |
pkg = (package_t*)malloc(sizeof(package_t)); |
INIT_LIST_HEAD(&pkg->file_list); |
209,11 → 207,11 |
pkg->id = tmp->id; |
pkg->name = strdup(tmp->name); |
pkg->version = strdup(tmp->version); |
pkg->group = strdup(tmp->group); |
pkg->filename = strdup(tmp->filename); |
pkg->description = strdup(tmp->description); |
list_add_tail(&pkg->list, list); |
count++; |
} |
}; |
return count; |
} |
230,13 → 228,9 |
if(collection) |
{ |
pkg_group_t *gr; |
list_for_each_entry(gr, &collection->groups, list) |
{ |
package_t *pkg, *tmp; |
list_for_each_entry(tmp, &gr->packages, list) |
list_for_each_entry(tmp, &collection->packages, list) |
{ |
pkg = (package_t*)malloc(sizeof(package_t)); |
244,11 → 238,11 |
pkg->id = tmp->id; |
pkg->name = strdup(tmp->name); |
pkg->version = strdup(tmp->version); |
pkg->group = strdup(tmp->group); |
pkg->filename = strdup(tmp->filename); |
pkg->description = strdup(tmp->description); |
list_add_tail(&pkg->list, slist); |
count++; |
} |
}; |
}; |
return count; |
260,7 → 254,20 |
list_for_each_entry(pkg, list, list) |
{ |
sprintf(conbuf,"%s-%s\n", pkg->name, pkg->version); |
sprintf(conbuf,"%s-%s-%s\n", pkg->name, pkg->version, pkg->group); |
con_write_asciiz(conbuf); |
} |
} |
void process_task(list_t *task) |
{ |
LIST_HEAD(download_list); |
if(build_download_list(&download_list, task)) |
do_download(&download_list); |
if(!list_empty(&download_list)) |
remove_missing_packages(task, &download_list); |
do_install(task); |
} |