[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [debian-installer] microdpkg

Randolph Chung wrote:
> > Im getting bogged down with forks and IPC with the C based debconf stuff
> > i was attempting, i might have a quick look now.
> Glenn, is your code available some place?
> randolph

Hi, i was looking at purely the unpacking side of things, the idea was
to use pipe to connect ar, unzip and tar, like your doing but just at a
lower level. 

I have updated busybox ar (its in lineo's busybox cvs) it now has a
function extractAr(srcFd, dstFd, filename) to make it easy to call from
other busybox functions.

source and destination file descriptors have to be setup before calling,
so dstFd can be redirected where ever, and filename is the name of the
one file to extract (have to loop to extract many files).

I had problems piping to the unzip(srcFd, dstFd) from gunzip.c i havent
looked to deeply at unzip yet, it looks pretty messy to me, i havent
gotten very far with it, might take a bit to clean it up, i have had a
look at tar though. 

The way tar.c was it needed some slight modification (unless it could
have all been done by redirecting stdin/stdout), i got a bit caried away
and have started making a mini-untar which shares the majority of code
with ar.c does. The code below only adds about 1k to the object code
size of ar.c.

I havent done a diff, or uploaded anything based on this, it was just a
rush job last night, i havent worked out the best place to call it from,
or even how it should fit in with the existing tar code, but i think it
looks promising, it was correctly passing a tar archive last night, i
had to change the file length to 100 in the headerL struct, and then i
just called parseTarArchive instead of parseArArchive.

To make a a new untar usable it needs code to create the files, i was
thinking of chopping up copyFile from utilities.c and making a
createFile routine that would be usefull to many functions, it could do
everything needed, make directories, chmod chgrp, handle links, etc, and
return just a file desriptor.

Im being a bit verbose as im moving (to melbourne) tommorow and ill be
out of contact for while, im changing ISP's but i dont get my cable
modem hooked up toll the 5th. My existing email address will remain
working (but i wont get much of a chance to check it), i will be
unsubsribing from mailing lists till the 5th.... i dont know what ill do
without a network connection for 8 and a bit days.

If you want what you have in cvs to be integrated with busybox i can do
that, you look like you have a better understanding of packaging than
me, so maybe im best assisting you where i can.

I will do my best to get some nice code happening for extracting debs
using busybox in the next 8 days, and secondly look at integrating what
you have done to use busybox functions if possible (if thats the way we
are are going).

Back on the 5th


here is the start of some code to untar from ar.c,

typedef struct rawTarHeader {
        char name[100];               /*   0-99 */
        char mode[8];                 /* 100-107 */
        char uid[8];                  /* 108-115 */
        char gid[8];                  /* 116-123 */
        char size[12];                /* 124-135 */
        char mtime[12];               /* 136-147 */
        char chksum[8];               /* 148-155 */
        char typeflag;                /* 156-156 */
        char linkname[100];           /* 157-256 */
        char magic[6];                /* 257-262 */
        char version[2];              /* 263-264 */
        char uname[32];               /* 265-296 */
        char gname[32];               /* 297-328 */
        char devmajor[8];             /* 329-336 */
        char devminor[8];             /* 337-344 */
        char prefix[155];             /* 345-499 */
        char padding[12];             /* 500-512 */
} rawTarHeader_t;

/* for .tar call this instead of parseArArchive 
 * it populates the headerL_t linked list with info from tar headers
 * instead of ar headers.
static int parseTarArchive(int srcFd, headerL_t *current)
        rawTarHeader_t rawTarHeader;
        unsigned char *temp = (unsigned char *) &rawTarHeader;
        while (fullRead(srcFd, (char *) &rawTarHeader, 512) == 512) {
                long sum = 0;
                int i;
                for (i =  0; i < 148 ; i++)
                        sum += temp[i];
                sum += ' ' * 8;
                for (i =  156; i < 512 ; i++)
                        sum += temp[i];
                if (sum==strtol(rawTarHeader.chksum, NULL, 8)) {
                        sscanf(rawTarHeader.name, "%s", current->name);
                        current->size = strtol(rawTarHeader.size, NULL,
                        current->uid = strtol(rawTarHeader.uid, NULL,
                        current->gid = strtol(rawTarHeader.gid, NULL,
                        current->mode = strtol(rawTarHeader.mode, NULL,
                        current->mtime = strtol(rawTarHeader.mtime,
NULL, 8);
                        current->offset = lseek(srcFd, 0 , SEEK_CUR);
/* debugging            printf("name [%s]\n",current->name);
                        printf("size = [%d]\n",current->size);  
                        printf("uid is %d\n",current->uid);
                        printf("gid is %d\n",current->gid);
                        printf("modie is
                        printf("time is

                        i = (int) current->size/512;
                        if ( current->size % 512 > 0) 
                        lseek(srcFd, i, SEEK_CUR);
                        current->next = (headerL_t *)
                        current = current->next;        

Reply to: