forked from KolibriOS/kolibrios
kpm: show usage and --install-all option
git-svn-id: svn://kolibrios.org@5809 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
2d6646029b
commit
e9ad07e519
@ -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 @@ static void ConvertFileTimeToString(const CNtfsFileTime *nt, char *s)
|
||||
}
|
||||
|
||||
|
||||
|
||||
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 @@ void do_install(list_t *install)
|
||||
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,126 +344,136 @@ void do_install(list_t *install)
|
||||
allocTempImp.Alloc = SzAllocTemp;
|
||||
allocTempImp.Free = SzFreeTemp;
|
||||
|
||||
if (InFile_Open(&archiveStream.file, srcpath))
|
||||
return;
|
||||
|
||||
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);
|
||||
|
||||
if (res == SZ_OK)
|
||||
{
|
||||
UInt32 i;
|
||||
UInt32 blockIndex = 0xFFFFFFFF; /* it can have any value before first call (if outBuffer = 0) */
|
||||
Byte *outBuffer = 0; /* it must be 0 before first call for each new archive. */
|
||||
size_t outBufferSize = 0; /* it can have any value before first call (if outBuffer = 0) */
|
||||
|
||||
for (i = 0; i < db.NumFiles; i++)
|
||||
{
|
||||
size_t offset = 0;
|
||||
size_t outSizeProcessed = 0;
|
||||
size_t len;
|
||||
unsigned isDir = SzArEx_IsDir(&db, i);
|
||||
|
||||
if ( isDir )
|
||||
continue;
|
||||
|
||||
len = SzArEx_GetFileNameUtf16(&db, i, NULL);
|
||||
|
||||
if (len > tempSize)
|
||||
{
|
||||
SzFree(NULL, temp);
|
||||
tempSize = len;
|
||||
temp = (UInt16 *)SzAlloc(NULL, tempSize * sizeof(temp[0]));
|
||||
if (!temp)
|
||||
{
|
||||
res = SZ_ERROR_MEM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SzArEx_GetFileNameUtf16(&db, i, temp);
|
||||
res = PrintString(temp);
|
||||
if (res != SZ_OK)
|
||||
break;
|
||||
printf("\n");
|
||||
|
||||
if (isDir)
|
||||
printf("/");
|
||||
else
|
||||
{
|
||||
res = SzArEx_Extract(&db, &lookStream.s, i,
|
||||
&blockIndex, &outBuffer, &outBufferSize,
|
||||
&offset, &outSizeProcessed,
|
||||
&allocImp, &allocTempImp);
|
||||
if (res != SZ_OK)
|
||||
break;
|
||||
}
|
||||
|
||||
if (1)
|
||||
{
|
||||
CSzFile outFile;
|
||||
size_t processedSize;
|
||||
size_t j;
|
||||
UInt16 *name = (UInt16 *)temp;
|
||||
const UInt16 *destPath = (const UInt16 *)name;
|
||||
|
||||
for (j = 0; name[j] != 0; j++)
|
||||
if (name[j] == '/')
|
||||
{
|
||||
name[j] = 0;
|
||||
MyCreateDir(name);
|
||||
name[j] = CHAR_PATH_SEPARATOR;
|
||||
}
|
||||
|
||||
if (isDir)
|
||||
{
|
||||
MyCreateDir(destPath);
|
||||
printf("\n");
|
||||
continue;
|
||||
}
|
||||
else if (OutFile_OpenUtf16(&outFile, destPath))
|
||||
{
|
||||
PrintError("can not open output file");
|
||||
res = SZ_ERROR_FAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
processedSize = outSizeProcessed;
|
||||
|
||||
if (File_Write(&outFile, outBuffer + offset, &processedSize) != 0 || processedSize != outSizeProcessed)
|
||||
{
|
||||
PrintError("can not write output file\n");
|
||||
res = SZ_ERROR_FAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (File_Close(&outFile))
|
||||
{
|
||||
PrintError("can not close output file\n");
|
||||
res = SZ_ERROR_FAIL;
|
||||
break;
|
||||
}
|
||||
};
|
||||
};
|
||||
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);
|
||||
|
||||
if (InFile_Open(&archiveStream.file, cache_path))
|
||||
continue;
|
||||
sprintf(conbuf,"install package %s-%s\n", pkg->name, pkg->version);
|
||||
con_write_asciiz(conbuf);
|
||||
|
||||
FileInStream_CreateVTable(&archiveStream);
|
||||
LookToRead_CreateVTable(&lookStream, False);
|
||||
|
||||
lookStream.realStream = &archiveStream.s;
|
||||
LookToRead_Init(&lookStream);
|
||||
|
||||
SzArEx_Init(&db);
|
||||
|
||||
res = SzArEx_Open(&db, &lookStream.s, &allocImp, &allocTempImp);
|
||||
|
||||
if (res == SZ_OK)
|
||||
{
|
||||
UInt32 i;
|
||||
UInt32 blockIndex = 0xFFFFFFFF; /* it can have any value before first call (if outBuffer = 0) */
|
||||
Byte *outBuffer = 0; /* it must be 0 before first call for each new archive. */
|
||||
size_t outBufferSize = 0; /* it can have any value before first call (if outBuffer = 0) */
|
||||
|
||||
for (i = 0; i < db.NumFiles; i++)
|
||||
{
|
||||
size_t offset = 0;
|
||||
size_t outSizeProcessed = 0;
|
||||
size_t len;
|
||||
unsigned isDir = SzArEx_IsDir(&db, i);
|
||||
|
||||
if ( isDir )
|
||||
continue;
|
||||
|
||||
len = SzArEx_GetFileNameUtf16(&db, i, NULL);
|
||||
|
||||
if (len > tempSize)
|
||||
{
|
||||
SzFree(NULL, temp);
|
||||
tempSize = len;
|
||||
temp = (UInt16 *)SzAlloc(NULL, tempSize * sizeof(temp[0]));
|
||||
if (!temp)
|
||||
{
|
||||
res = SZ_ERROR_MEM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SzArEx_GetFileNameUtf16(&db, i, temp);
|
||||
res = PrintString(temp);
|
||||
if (res != SZ_OK)
|
||||
break;
|
||||
printf("\n");
|
||||
|
||||
if (isDir)
|
||||
printf("/");
|
||||
else
|
||||
{
|
||||
res = SzArEx_Extract(&db, &lookStream.s, i,
|
||||
&blockIndex, &outBuffer, &outBufferSize,
|
||||
&offset, &outSizeProcessed,
|
||||
&allocImp, &allocTempImp);
|
||||
if (res != SZ_OK)
|
||||
break;
|
||||
}
|
||||
|
||||
if (1)
|
||||
{
|
||||
CSzFile outFile;
|
||||
size_t processedSize;
|
||||
size_t j;
|
||||
UInt16 *name = (UInt16 *)temp;
|
||||
const UInt16 *destPath = (const UInt16 *)name;
|
||||
|
||||
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)
|
||||
{
|
||||
MyCreateDir(destPath);
|
||||
printf("\n");
|
||||
continue;
|
||||
}
|
||||
else if (OutFile_OpenUtf16(&outFile, destPath))
|
||||
{
|
||||
PrintError("can not open output file");
|
||||
res = SZ_ERROR_FAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
processedSize = outSizeProcessed;
|
||||
|
||||
if (File_Write(&outFile, outBuffer + offset, &processedSize) != 0 || processedSize != outSizeProcessed)
|
||||
{
|
||||
PrintError("can not write output file");
|
||||
res = SZ_ERROR_FAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (File_Close(&outFile))
|
||||
{
|
||||
PrintError("can not close output file");
|
||||
res = SZ_ERROR_FAIL;
|
||||
break;
|
||||
}
|
||||
};
|
||||
continue;
|
||||
};
|
||||
};
|
||||
do_7z_unpack(cache_path);
|
||||
list_del_pkg(pkg);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
@ -81,8 +81,8 @@ static SRes SzBitUi32s_Alloc(CSzBitUi32s *p, size_t num, ISzAlloc *alloc)
|
||||
}
|
||||
else
|
||||
{
|
||||
MY_ALLOC(Byte, p->Defs, (num + 7) >> 3, alloc);
|
||||
MY_ALLOC(UInt32, p->Vals, num, alloc);
|
||||
MY_ALLOC(Byte, p->Defs, (num + 7) >> 3, alloc);
|
||||
MY_ALLOC(UInt32, p->Vals, num, alloc);
|
||||
}
|
||||
return SZ_OK;
|
||||
}
|
||||
@ -593,67 +593,67 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd, CSzData *sdSizes)
|
||||
{
|
||||
Byte streamUsed[k_NumCodersStreams_in_Folder_MAX];
|
||||
UInt32 numBonds, numPackStreams;
|
||||
|
||||
|
||||
numBonds = numCoders - 1;
|
||||
if (numInStreams < numBonds)
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
if (numBonds > SZ_NUM_BONDS_IN_FOLDER_MAX)
|
||||
return SZ_ERROR_UNSUPPORTED;
|
||||
return SZ_ERROR_UNSUPPORTED;
|
||||
f->NumBonds = numBonds;
|
||||
|
||||
numPackStreams = numInStreams - numBonds;
|
||||
if (numPackStreams > SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX)
|
||||
return SZ_ERROR_UNSUPPORTED;
|
||||
if (numPackStreams > SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX)
|
||||
return SZ_ERROR_UNSUPPORTED;
|
||||
f->NumPackStreams = numPackStreams;
|
||||
|
||||
for (i = 0; i < numInStreams; i++)
|
||||
for (i = 0; i < numInStreams; i++)
|
||||
streamUsed[i] = False;
|
||||
|
||||
if (numBonds != 0)
|
||||
{
|
||||
{
|
||||
Byte coderUsed[SZ_NUM_CODERS_IN_FOLDER_MAX];
|
||||
|
||||
for (i = 0; i < numCoders; i++)
|
||||
coderUsed[i] = False;
|
||||
|
||||
|
||||
for (i = 0; i < numBonds; i++)
|
||||
{
|
||||
CSzBond *bp = f->Bonds + i;
|
||||
|
||||
RINOK(SzReadNumber32(sd, &bp->InIndex));
|
||||
|
||||
RINOK(SzReadNumber32(sd, &bp->InIndex));
|
||||
if (bp->InIndex >= numInStreams || streamUsed[bp->InIndex])
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
streamUsed[bp->InIndex] = True;
|
||||
|
||||
RINOK(SzReadNumber32(sd, &bp->OutIndex));
|
||||
RINOK(SzReadNumber32(sd, &bp->OutIndex));
|
||||
if (bp->OutIndex >= numCoders || coderUsed[bp->OutIndex])
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
coderUsed[bp->OutIndex] = True;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < numCoders; i++)
|
||||
if (!coderUsed[i])
|
||||
{
|
||||
{
|
||||
f->UnpackStream = i;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == numCoders)
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
}
|
||||
|
||||
if (numPackStreams == 1)
|
||||
{
|
||||
for (i = 0; i < numInStreams; i++)
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
}
|
||||
|
||||
if (numPackStreams == 1)
|
||||
{
|
||||
for (i = 0; i < numInStreams; i++)
|
||||
if (!streamUsed[i])
|
||||
break;
|
||||
if (i == numInStreams)
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
f->PackStreams[0] = i;
|
||||
}
|
||||
else
|
||||
for (i = 0; i < numPackStreams; i++)
|
||||
{
|
||||
break;
|
||||
if (i == numInStreams)
|
||||
return SZ_ERROR_ARCHIVE;
|
||||
f->PackStreams[0] = i;
|
||||
}
|
||||
else
|
||||
for (i = 0; i < numPackStreams; i++)
|
||||
{
|
||||
UInt32 index;
|
||||
RINOK(SzReadNumber32(sd, &index));
|
||||
if (index >= numInStreams || streamUsed[index])
|
||||
@ -661,7 +661,7 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd, CSzData *sdSizes)
|
||||
streamUsed[index] = True;
|
||||
f->PackStreams[i] = index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < numCoders; i++)
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ void MY_FAST_CALL CrcGenerateTable()
|
||||
UInt32 r = g_CrcTable[i - 256];
|
||||
g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8);
|
||||
}
|
||||
|
||||
|
||||
#if CRC_NUM_TABLES < 4
|
||||
|
||||
g_CrcUpdate = CrcUpdateT1;
|
||||
@ -79,15 +79,15 @@ void MY_FAST_CALL CrcGenerateTable()
|
||||
#ifdef MY_CPU_LE
|
||||
|
||||
g_CrcUpdateT4 = CrcUpdateT4;
|
||||
g_CrcUpdate = CrcUpdateT4;
|
||||
|
||||
g_CrcUpdate = CrcUpdateT4;
|
||||
|
||||
#if CRC_NUM_TABLES >= 8
|
||||
g_CrcUpdateT8 = CrcUpdateT8;
|
||||
|
||||
#ifdef MY_CPU_X86_OR_AMD64
|
||||
if (!CPU_Is_InOrder())
|
||||
g_CrcUpdate = CrcUpdateT8;
|
||||
#endif
|
||||
if (!CPU_Is_InOrder())
|
||||
g_CrcUpdate = CrcUpdateT8;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
@ -446,7 +446,7 @@ static SRes SzFolder_Decode2(const CSzFolder *folder,
|
||||
tempBuf[2] = (Byte *)IAlloc_Alloc(allocMain, tempSizes[2]);
|
||||
if (!tempBuf[2] && tempSizes[2] != 0)
|
||||
return SZ_ERROR_MEM;
|
||||
|
||||
|
||||
RINOK(LookInStream_SeekTo(inStream, startPos + offset));
|
||||
RINOK(SzDecodeCopy(s3Size, inStream, tempBuf[2]));
|
||||
|
||||
@ -496,30 +496,30 @@ static SRes SzFolder_Decode2(const CSzFolder *folder,
|
||||
Delta_Init(state);
|
||||
Delta_Decode(state, (unsigned)(propsData[coder->PropsOffset]) + 1, outBuffer, outSize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
if (coder->PropsSize != 0)
|
||||
return SZ_ERROR_UNSUPPORTED;
|
||||
switch (coder->MethodID)
|
||||
return SZ_ERROR_UNSUPPORTED;
|
||||
switch (coder->MethodID)
|
||||
{
|
||||
case k_BCJ:
|
||||
{
|
||||
case k_BCJ:
|
||||
{
|
||||
UInt32 state;
|
||||
x86_Convert_Init(state);
|
||||
x86_Convert(outBuffer, outSize, 0, &state, 0);
|
||||
break;
|
||||
}
|
||||
UInt32 state;
|
||||
x86_Convert_Init(state);
|
||||
x86_Convert(outBuffer, outSize, 0, &state, 0);
|
||||
break;
|
||||
}
|
||||
CASE_BRA_CONV(PPC)
|
||||
CASE_BRA_CONV(IA64)
|
||||
CASE_BRA_CONV(SPARC)
|
||||
CASE_BRA_CONV(ARM)
|
||||
CASE_BRA_CONV(ARM)
|
||||
CASE_BRA_CONV(ARMT)
|
||||
default:
|
||||
return SZ_ERROR_UNSUPPORTED;
|
||||
}
|
||||
default:
|
||||
return SZ_ERROR_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else
|
||||
return SZ_ERROR_UNSUPPORTED;
|
||||
|
@ -122,12 +122,12 @@ WRes File_Read(CSzFile *p, void *data, size_t *size)
|
||||
return 0;
|
||||
|
||||
#else
|
||||
|
||||
|
||||
*size = fread(data, 1, originalSize, p->file);
|
||||
if (*size == originalSize)
|
||||
return 0;
|
||||
return ferror(p->file);
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ WRes File_Write(CSzFile *p, const void *data, size_t *size)
|
||||
size_t originalSize = *size;
|
||||
if (originalSize == 0)
|
||||
return 0;
|
||||
|
||||
|
||||
#ifdef USE_WINDOWS_FILE
|
||||
|
||||
*size = 0;
|
||||
@ -162,7 +162,7 @@ WRes File_Write(CSzFile *p, const void *data, size_t *size)
|
||||
if (*size == originalSize)
|
||||
return 0;
|
||||
return ferror(p->file);
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin)
|
||||
return 0;
|
||||
|
||||
#else
|
||||
|
||||
|
||||
int moveMethod;
|
||||
int res;
|
||||
switch (origin)
|
||||
@ -205,14 +205,14 @@ WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin)
|
||||
res = fseek(p->file, (long)*pos, moveMethod);
|
||||
*pos = ftell(p->file);
|
||||
return res;
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
WRes File_GetLength(CSzFile *p, UInt64 *length)
|
||||
{
|
||||
#ifdef USE_WINDOWS_FILE
|
||||
|
||||
|
||||
DWORD sizeHigh;
|
||||
DWORD sizeLow = GetFileSize(p->handle, &sizeHigh);
|
||||
if (sizeLow == 0xFFFFFFFF)
|
||||
@ -223,15 +223,15 @@ WRes File_GetLength(CSzFile *p, UInt64 *length)
|
||||
}
|
||||
*length = (((UInt64)sizeHigh) << 32) + sizeLow;
|
||||
return 0;
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
long pos = ftell(p->file);
|
||||
int res = fseek(p->file, 0, SEEK_END);
|
||||
*length = ftell(p->file);
|
||||
fseek(p->file, pos, SEEK_SET);
|
||||
return res;
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ SRes Bcj2Dec_Decode(CBcj2Dec *p)
|
||||
{
|
||||
if (p->range == 1 && p->code != 0)
|
||||
return SZ_ERROR_DATA;
|
||||
|
||||
|
||||
if (p->bufs[BCJ2_STREAM_RC] == p->lims[BCJ2_STREAM_RC])
|
||||
{
|
||||
p->state = BCJ2_STREAM_RC;
|
||||
@ -71,7 +71,7 @@ SRes Bcj2Dec_Decode(CBcj2Dec *p)
|
||||
{
|
||||
const Byte *cur = p->bufs[p->state];
|
||||
if (cur == p->lims[p->state])
|
||||
return SZ_OK;
|
||||
return SZ_OK;
|
||||
p->bufs[p->state] = cur + 4;
|
||||
|
||||
{
|
||||
@ -150,9 +150,9 @@ SRes Bcj2Dec_Decode(CBcj2Dec *p)
|
||||
Byte b = *src;
|
||||
*dest = b;
|
||||
if (b != 0x0F)
|
||||
{
|
||||
{
|
||||
if ((b & 0xFE) == 0xE8)
|
||||
break;
|
||||
break;
|
||||
dest++;
|
||||
if (++src != srcLim)
|
||||
continue;
|
||||
@ -181,8 +181,8 @@ SRes Bcj2Dec_Decode(CBcj2Dec *p)
|
||||
(unsigned)BCJ2_STREAM_MAIN :
|
||||
(unsigned)BCJ2_DEC_STATE_ORIG;
|
||||
return SZ_OK;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
UInt32 bound, ttt;
|
||||
CProb *prob;
|
||||
@ -194,17 +194,17 @@ SRes Bcj2Dec_Decode(CBcj2Dec *p)
|
||||
num++;
|
||||
p->ip += (UInt32)num;
|
||||
p->dest += num;
|
||||
|
||||
|
||||
prob = p->probs + (unsigned)(b == 0xE8 ? 2 + (unsigned)prev : (b == 0xE9 ? 1 : 0));
|
||||
|
||||
|
||||
_IF_BIT_0
|
||||
{
|
||||
_UPDATE_0
|
||||
continue;
|
||||
}
|
||||
_UPDATE_1
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,8 +243,8 @@ SRes Bcj2Dec_Decode(CBcj2Dec *p)
|
||||
SetUi32(dest, val);
|
||||
p->temp[3] = (Byte)(val >> 24);
|
||||
p->dest = dest + 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (p->range < kTopValue && p->bufs[BCJ2_STREAM_RC] != p->lims[BCJ2_STREAM_RC])
|
||||
{
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "LzmaDec.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define kNumTopBits 24
|
||||
#define kTopValue ((UInt32)1 << kNumTopBits)
|
||||
@ -150,7 +151,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
|
||||
Byte *dic = p->dic;
|
||||
SizeT dicBufSize = p->dicBufSize;
|
||||
SizeT dicPos = p->dicPos;
|
||||
|
||||
|
||||
UInt32 processedPos = p->processedPos;
|
||||
UInt32 checkDicSize = p->checkDicSize;
|
||||
unsigned len = 0;
|
||||
@ -174,7 +175,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
|
||||
prob = probs + Literal;
|
||||
if (processedPos != 0 || checkDicSize != 0)
|
||||
prob += ((UInt32)LZMA_LIT_SIZE * (((processedPos & lpMask) << lc) +
|
||||
(dic[(dicPos == 0 ? dicBufSize : dicPos) - 1] >> (8 - lc))));
|
||||
(dic[(dicPos == 0 ? dicBufSize : dicPos) - 1] >> (8 - lc))));
|
||||
processedPos++;
|
||||
|
||||
if (state < kNumLitStates)
|
||||
@ -395,7 +396,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
|
||||
{
|
||||
NORMALIZE
|
||||
range >>= 1;
|
||||
|
||||
|
||||
{
|
||||
UInt32 t;
|
||||
code -= range;
|
||||
@ -439,13 +440,14 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
|
||||
{
|
||||
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;
|
||||
@ -461,7 +463,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
|
||||
if ((rem = limit - dicPos) == 0)
|
||||
{
|
||||
p->dicPos = dicPos;
|
||||
return SZ_ERROR_DATA;
|
||||
return SZ_ERROR_DATA;
|
||||
}
|
||||
|
||||
curLen = ((rem < len) ? (unsigned)rem : len);
|
||||
@ -600,8 +602,8 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS
|
||||
prob = probs + Literal;
|
||||
if (p->checkDicSize != 0 || p->processedPos != 0)
|
||||
prob += ((UInt32)LZMA_LIT_SIZE *
|
||||
((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) +
|
||||
(p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc))));
|
||||
((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) +
|
||||
(p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc))));
|
||||
|
||||
if (state < kNumLitStates)
|
||||
{
|
||||
@ -806,7 +808,7 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr
|
||||
SizeT inSize = *srcLen;
|
||||
(*srcLen) = 0;
|
||||
LzmaDec_WriteRem(p, dicLimit);
|
||||
|
||||
|
||||
*status = LZMA_STATUS_NOT_SPECIFIED;
|
||||
|
||||
while (p->remainLen != kMatchSpecLenStart)
|
||||
@ -857,7 +859,7 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr
|
||||
|
||||
if (p->needInitState)
|
||||
LzmaDec_InitStateReal(p);
|
||||
|
||||
|
||||
if (p->tempBufSize == 0)
|
||||
{
|
||||
SizeT processed;
|
||||
@ -997,12 +999,12 @@ SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
|
||||
{
|
||||
UInt32 dicSize;
|
||||
Byte d;
|
||||
|
||||
|
||||
if (size < LZMA_PROPS_SIZE)
|
||||
return SZ_ERROR_UNSUPPORTED;
|
||||
else
|
||||
dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24);
|
||||
|
||||
|
||||
if (dicSize < LZMA_DIC_MIN)
|
||||
dicSize = LZMA_DIC_MIN;
|
||||
p->dicSize = dicSize;
|
||||
|
@ -8,7 +8,7 @@ LD = kos32-ld
|
||||
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,10 +17,11 @@ LIB_DIR:= $(SDK_DIR)/lib
|
||||
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
|
||||
|
||||
@ -51,12 +52,11 @@ SOURCES = http.asm \
|
||||
7z/Bra86.c \
|
||||
7z/BraIA64.c \
|
||||
7z/7zAlloc.c \
|
||||
7z/Alloc.c \
|
||||
$(NULL)
|
||||
|
||||
OBJECTS = $(patsubst %.asm, %.o, $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SOURCES))))
|
||||
|
||||
# targets
|
||||
# targets
|
||||
|
||||
all:$(NAME)
|
||||
|
||||
@ -68,7 +68,7 @@ $(NAME): $(OBJECTS) Makefile
|
||||
$(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) $< $@
|
||||
|
129
contrib/other/kpm/app.lds
Normal file
129
contrib/other/kpm/app.lds
Normal file
@ -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)
|
||||
}
|
||||
|
||||
}
|
@ -1,75 +1,62 @@
|
||||
#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)
|
||||
{
|
||||
TiXmlElement *xmlpkg;
|
||||
TiXmlElement *xmle;
|
||||
|
||||
xmlpkg = xmlgroup->FirstChildElement(key_package);
|
||||
while (xmlpkg)
|
||||
{
|
||||
package_t *pkg;
|
||||
|
||||
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));
|
||||
|
||||
xmle = xmlpkg->FirstChildElement(key_description);
|
||||
pkg->description = strdup(xmle->Attribute(key_title));
|
||||
|
||||
xmle = xmlpkg->FirstChildElement(key_release);
|
||||
pkg->filename = strdup(xmle->Attribute(key_file));
|
||||
|
||||
list_add_tail(&pkg->list, &gr->packages);
|
||||
xmlpkg = xmlpkg->NextSiblingElement();
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
collection_t* load_collection_file(const char *name)
|
||||
collection_t *
|
||||
load_collection_file(const char *name)
|
||||
{
|
||||
TiXmlDocument doc;
|
||||
TiXmlElement *col;
|
||||
collection_t *collection = NULL;
|
||||
collection_t *collection = NULL;
|
||||
|
||||
doc.LoadFile(name);
|
||||
col = doc.FirstChildElement(key_collection);
|
||||
col = doc.FirstChildElement(key_collection);
|
||||
if (col)
|
||||
{
|
||||
collection = (collection_t*)malloc(sizeof(collection_t));
|
||||
INIT_LIST_HEAD(&collection->groups);
|
||||
TiXmlElement *xmlpkg;
|
||||
TiXmlElement *xmle;
|
||||
|
||||
TiXmlElement* xmlgroup = col->FirstChildElement();
|
||||
if (xmlgroup)
|
||||
collection = (collection_t *) malloc(sizeof(collection_t));
|
||||
INIT_LIST_HEAD(&collection->packages);
|
||||
|
||||
xmlpkg = col->FirstChildElement(key_package);
|
||||
|
||||
while (xmlpkg)
|
||||
{
|
||||
pkg_group_t *gr;
|
||||
package_t *pkg;
|
||||
|
||||
gr = (pkg_group_t*)malloc(sizeof(pkg_group_t));
|
||||
INIT_LIST_HEAD(&gr->list);
|
||||
INIT_LIST_HEAD(&gr->packages);
|
||||
pkg = (package_t *) malloc(sizeof(package_t));
|
||||
|
||||
gr->name = strdup(xmlgroup->Value());
|
||||
list_add_tail(&gr->list, &collection->groups);
|
||||
parse_group(gr, xmlgroup);
|
||||
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));
|
||||
|
||||
xmle = xmlpkg->FirstChildElement(key_release);
|
||||
pkg->filename = strdup(xmle->Attribute(key_file));
|
||||
|
||||
list_add_tail(&pkg->list, &collection->packages);
|
||||
xmlpkg = xmlpkg->NextSiblingElement();
|
||||
};
|
||||
};
|
||||
|
||||
return collection;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
return collection;
|
||||
};
|
||||
|
@ -8,9 +8,9 @@
|
||||
#include "package.h"
|
||||
#include "http.h"
|
||||
|
||||
#define BUFFSIZE (64*1024)
|
||||
void process_task(list_t *task);
|
||||
|
||||
extern char conbuf[256];
|
||||
#define BUFFSIZE (64*1024)
|
||||
|
||||
#define OPTION_STD_BASE 150
|
||||
|
||||
@ -18,16 +18,40 @@ enum option_values
|
||||
{
|
||||
OPTION_HELP = OPTION_STD_BASE,
|
||||
OPTION_LIST_PACKAGES,
|
||||
OPTION_LIST_INSTALLED
|
||||
OPTION_LIST_INSTALLED,
|
||||
OPTION_INSTALL_ALL
|
||||
};
|
||||
|
||||
static const struct option longopts[] =
|
||||
{
|
||||
{"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 main(int argc, char *argv[])
|
||||
int count;
|
||||
char *cache_path;
|
||||
char *tmp_path;
|
||||
int act = 1;
|
||||
|
||||
if(http_init())
|
||||
goto err_init;
|
||||
@ -54,62 +79,41 @@ int main(int argc, char *argv[])
|
||||
if(count)
|
||||
build_server_list(&server_list, tmp_path);
|
||||
|
||||
while(1)
|
||||
while(act)
|
||||
{
|
||||
int val;
|
||||
int index;
|
||||
|
||||
val = getopt_long_only(argc, argv,"",longopts, &index);
|
||||
|
||||
if(val == -1)
|
||||
break;
|
||||
|
||||
switch(val)
|
||||
{
|
||||
case OPTION_LIST_PACKAGES:
|
||||
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 @@ err_init:
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -8,17 +8,10 @@ extern "C" {
|
||||
|
||||
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 @@ typedef struct package
|
||||
int id;
|
||||
char *name;
|
||||
char *version;
|
||||
char *group;
|
||||
char *filename;
|
||||
char *description;
|
||||
}package_t;
|
||||
@ -35,6 +29,7 @@ static inline void list_del_pkg(package_t *pkg)
|
||||
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 @@ static inline void list_del_pkg(package_t *pkg)
|
||||
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 print_pkg_list(list_t *list);
|
||||
void do_download(list_t *download);
|
||||
void do_install(list_t *install);
|
||||
|
||||
extern char conbuf[256];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -143,6 +143,7 @@ int build_download_list(list_t *download, list_t *src)
|
||||
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 @@ void do_download(list_t *download_list)
|
||||
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,28 +194,24 @@ void remove_missing_packages(list_t *install, list_t *missed)
|
||||
};
|
||||
};
|
||||
|
||||
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;
|
||||
pkg = (package_t*)malloc(sizeof(package_t));
|
||||
|
||||
list_for_each_entry(tmp, &gr->packages, list)
|
||||
{
|
||||
pkg = (package_t*)malloc(sizeof(package_t));
|
||||
|
||||
INIT_LIST_HEAD(&pkg->file_list);
|
||||
pkg->id = tmp->id;
|
||||
pkg->name = strdup(tmp->name);
|
||||
pkg->version = strdup(tmp->version);
|
||||
pkg->filename = strdup(tmp->filename);
|
||||
pkg->description = strdup(tmp->description);
|
||||
list_add_tail(&pkg->list, list);
|
||||
count++;
|
||||
}
|
||||
INIT_LIST_HEAD(&pkg->file_list);
|
||||
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,25 +228,21 @@ int build_server_list(list_t *slist, const char *path)
|
||||
|
||||
if(collection)
|
||||
{
|
||||
pkg_group_t *gr;
|
||||
package_t *pkg, *tmp;
|
||||
|
||||
list_for_each_entry(gr, &collection->groups, list)
|
||||
list_for_each_entry(tmp, &collection->packages, list)
|
||||
{
|
||||
package_t *pkg, *tmp;
|
||||
pkg = (package_t*)malloc(sizeof(package_t));
|
||||
|
||||
list_for_each_entry(tmp, &gr->packages, list)
|
||||
{
|
||||
pkg = (package_t*)malloc(sizeof(package_t));
|
||||
|
||||
INIT_LIST_HEAD(&pkg->file_list);
|
||||
pkg->id = tmp->id;
|
||||
pkg->name = strdup(tmp->name);
|
||||
pkg->version = strdup(tmp->version);
|
||||
pkg->filename = strdup(tmp->filename);
|
||||
pkg->description = strdup(tmp->description);
|
||||
list_add_tail(&pkg->list, slist);
|
||||
count++;
|
||||
}
|
||||
INIT_LIST_HEAD(&pkg->file_list);
|
||||
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 @@ void print_pkg_list(list_t *list)
|
||||
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user