/contrib/other/kpm/app.lds |
---|
File deleted |
/contrib/other/kpm/Makefile |
---|
8,7 → 8,7 |
CPP= kos32-g++ |
STRIP = kos32-strip |
CFLAGS = -U_Win32 -U_WIN32 -U__MINGW32__ -c -Os -fomit-frame-pointer -fno-asynchronous-unwind-tables -fno-ident -fomit-frame-pointer -mno-ms-bitfields |
CFLAGS = -U_Win32 -U_WIN32 -U__MINGW32__ -c -Os -fno-ident -fomit-frame-pointer -mno-ms-bitfields |
ARFLAG = crs |
SDK_DIR:= $(abspath ../../sdk) |
17,12 → 17,11 |
INCLUDES= -I. -I$(SDK_DIR)/sources/newlib/libc/include |
INCLUDES+=-I$(SDK_DIR)/sources/freetype/include |
#DEFINES= -DDEBUG=1 -D_7ZIP_PPMD_SUPPPORT |
#DEFINES= -DDEBUG=1 |
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 |
52,6 → 51,7 |
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) -fno-rtti -fno-exceptions $(DEFINES) $(INCLUDES) -o $@ $< |
$(CPP) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ $< |
%.o : %.asm Makefile |
$(FASM) $< $@ |
/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,8 → 18,7 |
{ |
OPTION_HELP = OPTION_STD_BASE, |
OPTION_LIST_PACKAGES, |
OPTION_LIST_INSTALLED, |
OPTION_INSTALL_ALL |
OPTION_LIST_INSTALLED |
}; |
static const struct option longopts[] = |
26,32 → 25,9 |
{ |
{"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); |
63,7 → 39,6 |
int count; |
char *cache_path; |
char *tmp_path; |
int act = 1; |
if(http_init()) |
goto err_init; |
79,7 → 54,7 |
if(count) |
build_server_list(&server_list, tmp_path); |
while(act) |
while(1) |
{ |
int val; |
int index; |
86,6 → 61,9 |
val = getopt_long_only(argc, argv,"",longopts, &index); |
if(val == -1) |
break; |
switch(val) |
{ |
case OPTION_LIST_PACKAGES: |
92,28 → 70,46 |
sprintf(conbuf,"available packages:\n\n"); |
con_write_asciiz(conbuf); |
print_pkg_list(&server_list); |
act = 0; |
break; |
con_exit(0); |
return 0; |
case OPTION_LIST_INSTALLED: |
sprintf(conbuf,"installed packages:\n\n"); |
con_write_asciiz(conbuf); |
print_pkg_list(&local_list); |
act = 0; |
break; |
con_exit(0); |
return 0; |
case OPTION_INSTALL_ALL: |
copy_list(&task_list, &server_list); |
process_task(&task_list); |
act = 0; |
default: |
break; |
default: |
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; |
123,3 → 119,6 |
return -1; |
} |
/contrib/other/kpm/package.h |
---|
8,10 → 8,17 |
typedef struct |
{ |
list_t packages; |
list_t groups; |
char *issue; |
}collection_t; |
typedef struct |
{ |
list_t list; |
list_t packages; |
char *name; |
}pkg_group_t; |
typedef struct package |
{ |
list_t list; |
19,7 → 26,6 |
int id; |
char *name; |
char *version; |
char *group; |
char *filename; |
char *description; |
}package_t; |
29,7 → 35,6 |
list_del(&pkg->list); |
free(pkg->description); |
free(pkg->filename); |
free(pkg->group); |
free(pkg->version); |
free(pkg->name); |
free(pkg); |
38,9 → 43,8 |
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); |
49,8 → 53,6 |
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,7 → 143,6 |
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); |
167,7 → 166,6 |
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 |
194,13 → 192,17 |
}; |
}; |
int copy_list(list_t *list, list_t *src) |
int build_install_list(list_t *list, collection_t *collection) |
{ |
package_t *pkg, *tmp; |
pkg_group_t *gr; |
int count = 0; |
list_for_each_entry(tmp, src, list) |
list_for_each_entry(gr, &collection->groups, 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); |
207,11 → 209,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; |
} |
228,9 → 230,13 |
if(collection) |
{ |
pkg_group_t *gr; |
list_for_each_entry(gr, &collection->groups, list) |
{ |
package_t *pkg, *tmp; |
list_for_each_entry(tmp, &collection->packages, list) |
list_for_each_entry(tmp, &gr->packages, list) |
{ |
pkg = (package_t*)malloc(sizeof(package_t)); |
238,11 → 244,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; |
254,20 → 260,7 |
list_for_each_entry(pkg, list, list) |
{ |
sprintf(conbuf,"%s-%s-%s\n", pkg->name, pkg->version, pkg->group); |
sprintf(conbuf,"%s-%s\n", pkg->name, pkg->version); |
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); |
} |
/contrib/other/kpm/7z/7z.c |
---|
6,7 → 6,6 |
#include "7zCrc.h" |
#include "7zFile.h" |
#include "7zVersion.h" |
#include "http.h" |
#include "package.h" |
#define PERIOD_4 (4 * 365 + 1) |
324,11 → 323,11 |
} |
void do_7z_unpack(const char *srcpath) |
void do_install(list_t *install) |
{ |
CFileInStream archiveStream; |
CLookToRead lookStream; |
CSzArEx db; |
SRes res; |
ISzAlloc allocImp; |
336,7 → 335,8 |
UInt16 *temp = NULL; |
size_t tempSize = 0; |
memset(&lookStream,0,sizeof(lookStream)); |
package_t *pkg, *tmp; |
char *cache_path; |
allocImp.Alloc = SzAlloc; |
allocImp.Free = SzFree; |
344,15 → 344,19 |
allocTempImp.Alloc = SzAllocTemp; |
allocTempImp.Free = SzFreeTemp; |
if (InFile_Open(&archiveStream.file, srcpath)) |
return; |
list_for_each_entry_safe(pkg, tmp, install, list) |
{ |
cache_path = make_cache_path(pkg->filename); |
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); |
417,10 → 421,15 |
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) |
{ |
439,7 → 448,7 |
if (File_Write(&outFile, outBuffer + offset, &processedSize) != 0 || processedSize != outSizeProcessed) |
{ |
PrintError("can not write output file\n"); |
PrintError("can not write output file"); |
res = SZ_ERROR_FAIL; |
break; |
} |
446,34 → 455,15 |
if (File_Close(&outFile)) |
{ |
PrintError("can not close output file\n"); |
PrintError("can not close output file"); |
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,7 → 6,6 |
#include "LzmaDec.h" |
#include <string.h> |
#include <stdio.h> |
#define kNumTopBits 24 |
#define kTopValue ((UInt32)1 << kNumTopBits) |
440,14 → 439,13 |
{ |
if (distance >= processedPos) |
{ |
printf("%s fail line %d distance %d processedPos %d\n", |
__FUNCTION__,__LINE__,distance,processedPos ); |
p->dicPos = dicPos; |
return SZ_ERROR_DATA; |
} |
} |
else if (distance >= checkDicSize) |
{ |
printf("%s fail line %d\n", __FUNCTION__,__LINE__); |
p->dicPos = dicPos; |
return SZ_ERROR_DATA; |
} |
state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3; |
/contrib/other/kpm/collection.cpp |
---|
1,39 → 1,23 |
#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; |
collection_t * |
load_collection_file(const char *name) |
void parse_group(pkg_group_t* gr, TiXmlElement *xmlgroup) |
{ |
TiXmlDocument doc; |
TiXmlElement *col; |
collection_t *collection = NULL; |
doc.LoadFile(name); |
col = doc.FirstChildElement(key_collection); |
if (col) |
{ |
TiXmlElement *xmlpkg; |
TiXmlElement *xmle; |
collection = (collection_t *) malloc(sizeof(collection_t)); |
INIT_LIST_HEAD(&collection->packages); |
xmlpkg = col->FirstChildElement(key_package); |
xmlpkg = xmlgroup->FirstChildElement(key_package); |
while (xmlpkg) |
{ |
package_t *pkg; |
41,11 → 25,9 |
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)); |
53,10 → 35,41 |
xmle = xmlpkg->FirstChildElement(key_release); |
pkg->filename = strdup(xmle->Attribute(key_file)); |
list_add_tail(&pkg->list, &collection->packages); |
list_add_tail(&pkg->list, &gr->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; |
}; |
} |