Commit bf546129 authored by Bernhard Link's avatar Bernhard Link

finish support for Flat: conf/updates field

parent c2bbfc9a
2008-07-26
* add support to retrieve packages from flat repositories.
2008-07-25
* refactor indexfile parsing. (Needed for future changes,
perhaps speeding some things up a tiny littly bit).
......
Updates between 3.5.2 and 3.5.3:
- add IgnoreHashes option
- allow list to list all packages if not package name specified.
- support retrieving packages from flat repositories
Updates between 3.5.1 and 3.5.2:
- fix bug in optionsfilename generation introduced in 3.5.1
......
......@@ -1026,6 +1026,29 @@ If this is present, no
file will be downloaded and thus the md5sums of the other
index files will not be checked.
.TP
.B Flat
If this field is in an update rule, is is supposed to be a
flat repository, i.e. an repository without an \fBdists\fP
dir and no subdirectories for the index files.
(If the corresponding \fBsources.list\fP line has the suite
end with an slash, then you might need this one.)
The argument for the \fBFlat:\fP field is the Component to
put those packages into.
No \fBComponents\fP or \fBUDebComponents\fP
fields are allowed in an flat update rule.
If the \fBArchitecture\fP field has any \fB>\fP items,
the part left of the "\fB>\fP" is ignored.
.br
For example the \fBsources.list\fP line
deb http://cran.r-project.org/bin/linux/debian etch-cran/
.br
would translate to
.br
Name: R
Method: http://cran.r-project.org/bin/linux/debian
Suite: etch-cran
Flat: whatevercomponentyoudlikethepackagesin
.TP
.B IgnoreHashes
This directive tells reprepro to not check the listed
hashes in the downloaded Release file (and only in the Release file).
......
......@@ -151,55 +151,91 @@ static retvalue indexfile_get(struct indexfile *f) {
bool indexfile_getnext(struct indexfile *f, char **name_p, char **version_p, const char **control_p, const struct target *target, bool allowwrongarchitecture) {
retvalue r;
bool ignorecruft = false; // TODO
char *packagename, *version;
char *packagename, *version, *architecture;
const char *control;
packagename = NULL; version = NULL;
do {
free(packagename); packagename = NULL;
free(version); version = NULL;
r = indexfile_get(f);
if( !RET_IS_OK(r) ) {
RET_UPDATE(f->status, r);
return false;
}
if( !RET_IS_OK(r) )
break;
control = f->buffer;
r = chunk_getvalue(control, "Package", &packagename);
if( r == RET_NOTHING ) {
fprintf(stderr,
"Error parsing %s line %d: Chunk without 'Package:' field!\n",
f->filename, f->linenumber);
"Error parsing %s line %d to %d: Chunk without 'Package:' field!\n",
f->filename,
f->startlinenumber, f->linenumber);
if( !ignorecruft )
r = RET_ERROR_MISSING;
else
continue;
}
if( RET_WAS_ERROR(r) ) {
RET_UPDATE(f->status, r);
return false;
}
if( RET_WAS_ERROR(r) )
break;
r = chunk_getvalue(control, "Version", &version);
if( r == RET_NOTHING ) {
fprintf(stderr,
"Error parsing %s line %d: Chunk without 'Version:' field!\n",
f->filename, f->linenumber);
"Error parsing %s line %d to %d: Chunk without 'Version:' field!\n",
f->filename,
f->startlinenumber, f->linenumber);
if( !ignorecruft )
r = RET_ERROR_MISSING;
else {
free(packagename);
else
continue;
}
}
if( RET_WAS_ERROR(r) ) {
free(packagename);
RET_UPDATE(f->status, r);
return false;
}
if( strcmp(target->architecture, "source") != 0 ) {
// check if architecture fits for target and error
// out if not ignorewrongarchitecture
if( RET_WAS_ERROR(r) )
break;
r = chunk_getvalue(control, "Architecture", &architecture);
if( RET_WAS_ERROR(r) )
break;
if( r == RET_NOTHING )
architecture = NULL;
if( strcmp(target->packagetype, "dsc") == 0 ) {
free(architecture);
} else {
/* check if architecture fits for target and error
out if not ignorewrongarchitecture */
if( architecture == NULL ) {
fprintf(stderr,
"Error parsing %s line %d to %d: Chunk without 'Architecture:' field!\n",
f->filename,
f->startlinenumber, f->linenumber);
if( !ignorecruft ) {
r = RET_ERROR_MISSING;
break;
} else
continue;
} else if( strcmp(architecture, "all") != 0 &&
strcmp(architecture,
target->architecture) != 0) {
if( allowwrongarchitecture ) {
free(architecture);
continue;
} else {
fprintf(stderr,
"Error parsing %s line %d to %d: Wrong 'Architecture:' field '%s' (need 'all' or '%s')!\n",
f->filename,
f->startlinenumber, f->linenumber,
architecture,
target->architecture);
r = RET_ERROR;
}
}
free(architecture);
}
if( RET_WAS_ERROR(r) )
break;
*control_p = control;
*name_p = packagename;
*version_p = version;
return true;
} while( true );
free(packagename);
free(version);
RET_UPDATE(f->status, r);
return false;
}
......@@ -17,7 +17,8 @@ EOF
cat > conf/updates.base <<EOF
Name: flattest
Flat: a
Method: file:$WORKDIR/flatsource
Method: file:$WORKDIR
Suite: flatsource
EOF
testrun - -b . export 1234 3<<EOF
......@@ -66,7 +67,7 @@ EOF
testrun - -b . update 1234 3<<EOF
returns 255
stderr
*=./conf/updates:1 to 5: Update pattern may not contain Components and Flat fields ad the same time.
*=./conf/updates:1 to 6: Update pattern may not contain Components and Flat fields ad the same time.
-v0*=There have been errors!
stdout
EOF
......@@ -79,7 +80,7 @@ EOF
testrun - -b . update 1234 3<<EOF
returns 255
stderr
*=./conf/updates:1 to 5: Update pattern may not contain UDebComponents and Flat fields ad the same time.
*=./conf/updates:1 to 6: Update pattern may not contain UDebComponents and Flat fields ad the same time.
-v0*=There have been errors!
stdout
EOF
......@@ -203,7 +204,7 @@ cat > flatsource/Packages.gz <<EOF
Package: test
Architecture: all
Version: 0
Filename: test.deb
Filename: flatsource/test.deb
EOF
cat > flatsource/Release <<EOF
MD5Sum:
......@@ -232,7 +233,7 @@ stderr
*= 'Package: test
*=Architecture: all
*=Version: 0
*=Filename: test.deb'
*=Filename: flatsource/test.deb'
-v1*=Stop reading further chunks from './lists/1234_flattest_deb_a_flat' due to previous errors.
-v0*=There have been errors!
return 249
......@@ -242,7 +243,7 @@ cat > flatsource/Packages.gz <<EOF
Package: test
Architecture: all
Version: 0
Filename: test.deb
Filename: flatsource/test.deb
Size: 0
MD5Sum: $EMPTYMD5ONLY
EOF
......@@ -327,7 +328,62 @@ stdout
-v6*= looking for changes in '1234|bb|source'...
EOF
# Todo: check architecture dependant packages (still needs support in upgradelist)
cat > flatsource/Packages.gz <<EOF
Package: test
Architecture: yyyyyyyyyy
Version: 1
Filename: flatsource/test.deb
Size: 0
MD5Sum: $EMPTYMD5ONLY
EOF
cat > flatsource/Release <<EOF
MD5Sum:
$(mdandsize flatsource/Sources.gz) Sources.gz
$(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/1234_flattest_rel_Release_data'...
-v1*=aptmethod got 'file:$WORKDIR/flatsource/Packages.gz'
-v2*=Copy file '$WORKDIR/flatsource/Packages.gz' to './lists/1234_flattest_deb_a_flat'...
-v1*=aptmethod got 'file:$WORKDIR/flatsource/test.deb'
-v2*=Linking file '$WORKDIR/flatsource/test.deb' to './pool/a/t/test/test_1_yyyyyyyyyy.deb'...
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'
-v0*= nothing new for '1234|a|source' (use --noskipold to process anyway)
-v4*= nothing to do for 'u|1234|a|yyyyyyyyyy'
-v3*= processing updates for '1234|a|yyyyyyyyyy'
-v5*= reading './lists/1234_flattest_deb_a_flat'
-v4*= nothing to do for 'u|1234|a|x'
-v3*= processing updates for '1234|a|x'
-v2=Created directory "./pool"
-v2=Created directory "./pool/a"
-v2=Created directory "./pool/a/t"
-v2=Created directory "./pool/a/t/test"
-v0*=Getting packages...
-e1*=db: 'pool/a/t/test/test_1_yyyyyyyyyy.deb' added to files.db(md5sums).
-d1*=db: 'pool/a/t/test/test_1_yyyyyyyyyy.deb' added to checksums.db(pool).
-v1*=Shutting down aptmethods...
-v0*=Installing (and possibly deleting) packages...
-d1*=db: 'test' removed from packages.db(1234|a|yyyyyyyyyy).
-d1*=db: 'test' added to packages.db(1234|a|yyyyyyyyyy).
-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*= replacing './dists/1234/a/binary-yyyyyyyyyy/Packages' (uncompressed,gzipped)
-v6*= looking for changes in 'u|1234|a|yyyyyyyyyy'...
-v6*= looking for changes in '1234|a|source'...
-v6*= looking for changes in '1234|bb|x'...
-v6*= looking for changes in '1234|bb|yyyyyyyyyy'...
-v6*= looking for changes in '1234|bb|source'...
-v0*=Deleting files no longer referenced...
EOF
rm -r -f db conf dists pool lists flatsource
testsuccess
......@@ -107,7 +107,7 @@ EOF
testrun - -b . -T deb -A ${FAKEARCHITECTURE} -C dog _addpackage B importindex bar foo 3<<EOF
returns 249
stderr
*=Error parsing importindex line 1: Chunk without 'Package:' field!
*=Error parsing importindex line 1 to 1: Chunk without 'Package:' field!
-v0*=There have been errors!
stdout
EOF
......
......@@ -484,13 +484,6 @@ CFfinishparse(update_pattern) {
config_line(iter));
return RET_ERROR;
}
if( n->suite_from != NULL && n->flat != NULL ) {
fprintf(stderr,
"%s:%u to %u: Update pattern may not contain Suite and Flat fields ad the same time.\n",
config_filename(iter), config_firstline(iter),
config_line(iter));
return RET_ERROR;
}
}
return linkedlistfinish(privdata_update_pattern, thisdata_update_pattern,
lastdata_p_update_pattern, complete, iter);
......@@ -765,7 +758,7 @@ static inline struct update_index_file *addindexfile(struct update_origin *origi
file->filename = f;
if( strcmp(packagetype, "deb") == 0 ) {
if( origin->pattern->flat != NULL ) {
u = strdup("Packages.gz");
u = mprintf("%s/Packages.gz", origin->suite_from);
uc = "Packages.gz";
} else {
u = mprintf("dists/%s/%s/binary-%s/Packages.gz",
......@@ -781,7 +774,7 @@ static inline struct update_index_file *addindexfile(struct update_origin *origi
uc = u + strlen(origin->suite_from) + 7; /* "dists/%s/" */
} else if( strcmp(packagetype, "dsc") == 0 ) {
if( origin->pattern->flat != NULL ) {
u = strdup("Sources.gz");
u = mprintf("%s/Sources.gz", origin->suite_from);
uc = "Sources.gz";
} else {
u = mprintf("dists/%s/%s/source/Sources.gz",
......@@ -1236,9 +1229,9 @@ static inline retvalue queuemetalists(struct update_origin *origin) {
}
if( p->flat != NULL )
toget = strdup("Release");
toget = mprintf("%s/Release", origin->suite_from);
else
toget = mprintf("dists/%s/Release",origin->suite_from);
toget = mprintf("dists/%s/Release", origin->suite_from);
r = aptmethod_queueindexfile(origin->download,
toget, origin->releasefile, NULL);
free(toget);
......@@ -1247,7 +1240,7 @@ static inline retvalue queuemetalists(struct update_origin *origin) {
if( p->verifyrelease != NULL ) {
if( p->flat != NULL )
toget = strdup("Release.gpg");
toget = mprintf("%s/Release.gpg", origin->suite_from);
else
toget = mprintf("dists/%s/Release.gpg",
origin->suite_from);
......
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