Commit 8ccfab82 authored by Bernhard Link's avatar Bernhard Link

fix importing of source packages from flat repositories without a Directory field in Sources index

parent 154d0a94
2009-01-22
* fix typo causing copyfilter to fail
* add --gnupghome option to set GNUPGHOME environment variable
* fix importing of source packages from flat repositories without
a Directory field in Sources index.
2009-01-17
* fix erroneous "strange filekey" warning for lib files in 3.8.0~alpha
......
......@@ -187,7 +187,8 @@ static inline retvalue calcnewcontrol(const char *chunk, const char *sourcename,
return r;
assert( filekeys->count == 1 );
*newchunk = chunk_replacefield(chunk,"Filename",filekeys->values[0]);
*newchunk = chunk_replacefield(chunk, "Filename",
filekeys->values[0], false);
if( *newchunk == NULL ) {
strlist_done(filekeys);
return RET_ERROR_OOM;
......@@ -280,7 +281,7 @@ retvalue binaries_doreoverride(const struct distribution *distribution,const cha
r = override_allreplacefields(o, &fields);
if( RET_WAS_ERROR(r) )
return r;
newchunk = chunk_replacefields(controlchunk, fields, "Filename");
newchunk = chunk_replacefields(controlchunk, fields, "Filename", false);
addfield_free(fields);
if( newchunk == NULL )
return RET_ERROR_OOM;
......@@ -303,7 +304,8 @@ retvalue ubinaries_doreoverride(const struct distribution *distribution,const ch
fields = override_addreplacefields(o,NULL);
if( fields == NULL )
return RET_ERROR_OOM;
newchunk = chunk_replacefields(controlchunk,fields,"Description");
newchunk = chunk_replacefields(controlchunk, fields, "Description",
true);
addfield_free(fields);
if( newchunk == NULL )
return RET_ERROR_OOM;
......@@ -572,7 +574,8 @@ retvalue binaries_complete(const struct deb_headers *pkg, const char *filekey, c
if( replace == NULL )
return RET_ERROR_OOM;
newchunk = chunk_replacefields(pkg->control,replace,"Description");
newchunk = chunk_replacefields(pkg->control, replace,
"Description", true);
addfield_free(replace);
if( newchunk == NULL ) {
return RET_ERROR_OOM;
......
......@@ -465,7 +465,7 @@ retvalue chunk_getnameandversion(const char *chunk,const char *name,
/* Add this the <fields to add> to <chunk> before <beforethis> field,
* replacing older fields of this name, if they are already there. */
char *chunk_replacefields(const char *chunk,const struct fieldtoadd *toadd,const char *beforethis) {
char *chunk_replacefields(const char *chunk, const struct fieldtoadd *toadd, const char *beforethis, bool maybemissing) {
const char *c,*ce;
char *newchunk,*n;
size_t size,len_beforethis;
......@@ -481,7 +481,7 @@ char *chunk_replacefields(const char *chunk,const struct fieldtoadd *toadd,const
c = chunk;
/* calculate the maximal size we might end up with */
size = 1+ strlen(c);
size = 2 + strlen(c);
f = toadd;
while( f != NULL ) {
if( f->data != NULL )
......@@ -549,6 +549,26 @@ char *chunk_replacefields(const char *chunk,const struct fieldtoadd *toadd,const
} while( *c != '\0' && *c != '\n' );
if( n > newchunk && *(n-1) != '\n' )
*(n++) = '\n';
if( maybemissing && !fieldsadded ) {
/* add them now, if they are allowed to come later */
f = toadd;
while( f != NULL ) {
if( f->data != NULL ) {
memcpy(n,f->field,f->len_field);
n += f->len_field;
*n = ':'; n++;
*n = ' '; n++;
memcpy(n,f->data,f->len_data);
n += f->len_data;
*n = '\n'; n++;
}
f = f->next;
}
result = RET_OK;
fieldsadded = true;
}
*n = '\0';
// If the problem still exists, I want to know it!
......@@ -641,7 +661,7 @@ void addfield_free(struct fieldtoadd *f) {
}
}
char *chunk_replacefield(const char *chunk,const char *fieldname,const char *data) {
char *chunk_replacefield(const char *chunk, const char *fieldname, const char *data, bool maybemissing) {
struct fieldtoadd toadd;
toadd.field = fieldname;
......@@ -649,7 +669,7 @@ char *chunk_replacefield(const char *chunk,const char *fieldname,const char *dat
toadd.data = data;
toadd.len_data = strlen(data);
toadd.next = NULL;
return chunk_replacefields(chunk,&toadd,fieldname);
return chunk_replacefields(chunk, &toadd, fieldname, maybemissing);
}
/* this is a bit wastefull, as with normaly perfect formated input, it just
......
......@@ -41,7 +41,7 @@ struct fieldtoadd {
// TODO make this return retvalue..
/* Add this the <fields to add> to <chunk> before <beforethis> field,
* replacing older fields of this name, if they are already there. */
/*@null@*/ char *chunk_replacefields(const char *chunk,const struct fieldtoadd *toadd,const char *beforethis);
/*@null@*/ char *chunk_replacefields(const char *chunk, const struct fieldtoadd *toadd, const char *beforethis, bool maybemissing);
/*@null@*/struct fieldtoadd *deletefield_new(/*@dependent@*/const char *field,/*@only@*//*@null@*/struct fieldtoadd *next);
/*@null@*/struct fieldtoadd *aodfield_new(/*@dependent@*/const char *field, /*@dependent@*//*@null@*/const char *data, /*@only@*/struct fieldtoadd *next);
/*@null@*/struct fieldtoadd *addfield_new(/*@dependent@*/const char *field,/*@dependent@*//*@null@*/const char *data,/*@only@*/struct fieldtoadd *next);
......@@ -49,7 +49,7 @@ struct fieldtoadd {
void addfield_free(/*@only@*//*@null@*/struct fieldtoadd *f);
/* that is chunk_replacefields(chunk,{fieldname,strlen,data,strlen},fieldname); */
/*@null@*/char *chunk_replacefield(const char *chunk,const char *fieldname,const char *data);
/*@null@*/char *chunk_replacefield(const char *chunk, const char *fieldname, const char *data, bool maybemissing);
/* check if all field names are in allowedfieldnames */
retvalue chunk_checkfields(const char *chunk, const char * const *allowedfieldnames, bool commentsallowed);
......
......@@ -212,7 +212,8 @@ retvalue sources_getinstalldata(const struct target *t, const char *packagename,
r = calc_inplacedirconcats(origdirectory, &files.names);
free(origdirectory);
if( !RET_WAS_ERROR(r) ) {
mychunk = chunk_replacefield(chunk, "Directory", directory);
mychunk = chunk_replacefield(chunk,
"Directory", directory, true);
if( mychunk == NULL )
r = RET_ERROR_OOM;
}
......@@ -337,7 +338,8 @@ retvalue sources_doreoverride(const struct distribution *distribution,const char
r = override_allreplacefields(o, &fields);
if( RET_WAS_ERROR(r) )
return r;
newchunk = chunk_replacefields(controlchunk, fields, "Directory");
newchunk = chunk_replacefields(controlchunk, fields,
"Directory", true);
addfield_free(fields);
if( newchunk == NULL )
return RET_ERROR_OOM;
......@@ -559,7 +561,7 @@ retvalue sources_complete(const struct dsc_headers *dsc, const char *directory,
name = deletefield_new("Source",name);
if( name == NULL )
return RET_ERROR_OOM;
newchunk2 = chunk_replacefields(dsc->control,name,"Format");
newchunk2 = chunk_replacefields(dsc->control, name, "Format", true);
addfield_free(name);
if( newchunk2 == NULL )
return RET_ERROR_OOM;
......@@ -594,7 +596,7 @@ retvalue sources_complete(const struct dsc_headers *dsc, const char *directory,
return RET_ERROR_OOM;
}
newchunk = chunk_replacefields(newchunk2,replace,"Files");
newchunk = chunk_replacefields(newchunk2, replace, "Files", false);
free(newsha256lines);
free(newsha1lines);
free(newfilelines);
......
......@@ -401,5 +401,99 @@ stdout
-v6*= looking for changes in '1234|bb|source'...
EOF
rm -r -f db conf dists pool lists flatsource
touch fake.dsc
cat > flatsource/Sources <<EOF
Package: test
Version: 0
Files:
$EMPTYMD5 fake.dsc
EOF
srcmd="$(mdandsize flatsource/Sources)"
gzip -f flatsource/Sources
cat > flatsource/Release <<EOF
MD5Sum:
$srcmd Sources
$(mdandsize flatsource/Sources.gz) Sources.gz
$pkgmd Packages
$(mdandsize flatsource/Packages.gz) Packages.gz
EOF
testrun - -b . update 1234 3<<EOF
stderr
-v1*=aptmethod got 'file:$WORKDIR/flatsource/Release'
-v2*=Copy file '$WORKDIR/flatsource/Release' to './lists/flattest_flatsource_flat_Release'...
-v1*=aptmethod got 'file:$WORKDIR/flatsource/Sources.gz'
-v2*=Uncompress '$WORKDIR/flatsource/Sources.gz' into './lists/flattest_flatsource_Sources' using '/bin/gunzip'...
-v1*=aptmethod got 'file:$WORKDIR/./fake.dsc'
-v2*=Linking file '$WORKDIR/./fake.dsc' to './pool/a/t/test/fake.dsc'...
stdout
-v0*=Calculating packages to get...
-v4*= nothing to do for '1234|bb|source'
-v4*= nothing to do for '1234|bb|yyyyyyyyyy'
-v4*= nothing to do for '1234|bb|x'
-v3*= processing updates for '1234|a|source'
-v0*= nothing new for '1234|a|yyyyyyyyyy' (use --noskipold to process anyway)
-v4*= nothing to do for 'u|1234|a|yyyyyyyyyy'
-v5*= reading './lists/flattest_flatsource_Sources'
-v4*= nothing to do for 'u|1234|a|x'
-v3*= nothing new for '1234|a|x' (use --noskipold to process anyway)
-v0*=Getting packages...
-e1*=db: 'pool/a/t/test/fake.dsc' added to files.db(md5sums).
-d1*=db: 'pool/a/t/test/fake.dsc' added to checksums.db(pool).
-v1*=Shutting down aptmethods...
-v0*=Installing (and possibly deleting) packages...
-d1*=db: 'test' added to packages.db(1234|a|source).
-v0*=Exporting indices...
-v6*= looking for changes in '1234|a|x'...
-v6*= looking for changes in 'u|1234|a|x'...
-v6*= looking for changes in '1234|a|yyyyyyyyyy'...
-v6*= looking for changes in 'u|1234|a|yyyyyyyyyy'...
-v6*= looking for changes in '1234|a|source'...
-v6*= replacing './dists/1234/a/source/Sources' (gzipped)
-v6*= looking for changes in '1234|bb|x'...
-v6*= looking for changes in '1234|bb|yyyyyyyyyy'...
-v6*= looking for changes in '1234|bb|source'...
EOF
cat > flatsource/Sources <<EOF
Package: test
Version: 1
Files:
$EMPTYMD5 ../fake.dsc
EOF
srcmd="$(mdandsize flatsource/Sources)"
gzip -f flatsource/Sources
cat > flatsource/Release <<EOF
MD5Sum:
$srcmd Sources
$(mdandsize flatsource/Sources.gz) Sources.gz
$pkgmd Packages
$(mdandsize flatsource/Packages.gz) Packages.gz
EOF
testrun - -b . update 1234 3<<EOF
stderr
-v1*=aptmethod got 'file:$WORKDIR/flatsource/Release'
-v2*=Copy file '$WORKDIR/flatsource/Release' to './lists/flattest_flatsource_flat_Release'...
-v1*=aptmethod got 'file:$WORKDIR/flatsource/Sources.gz'
-v2*=Uncompress '$WORKDIR/flatsource/Sources.gz' into './lists/flattest_flatsource_Sources' using '/bin/gunzip'...
stdout
-v0*=Calculating packages to get...
-v4*= nothing to do for '1234|bb|source'
-v4*= nothing to do for '1234|bb|yyyyyyyyyy'
-v4*= nothing to do for '1234|bb|x'
-v3*= processing updates for '1234|a|source'
-v5*= reading './lists/flattest_flatsource_Sources'
stderr
*=Character '/' not allowed within filename '../fake.dsc'!
*=Forbidden characters in source package 'test'!
*=Stop reading further chunks from './lists/flattest_flatsource_Sources' due to previous errors.
stdout
stderr
-v0*=There have been errors!
return 255
EOF
rm -r -f db conf dists pool lists flatsource fake.dsc
testsuccess
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment