Commit e43b7a8c authored by Bernhard Link's avatar Bernhard Link

implement Packages.diff support (still needs resuming to other downloads to be fully usefull)

parent f66c3849
2009-03-01
* support using Packages.diff when updating.
(Fallback to other methods not yet supported, so not yet enabled
in the default DownloadlistsAs)
2009-02-28
* fix some bugs in --nothingiserror handling
......
......@@ -18,14 +18,14 @@ AM_CPPFLAGS = -std=gnu99 -Wall $(ARCHIVECPP) $(DBCPPFLAGS)
reprepro_LDADD = $(ARCHIVELIBS) $(DBLIBS)
changestool_LDADD = $(ARCHIVELIBS)
reprepro_SOURCES = pool.c atoms.c uncompression.c remoterepository.c indexfile.c copypackages.c sourceextraction.c checksums.c readtextfile.c filecntl.c sha1.c sha256.c configparser.c database.c freespace.c log.c changes.c incoming.c uploaderslist.c guesscomponent.c files.c md5.c dirs.c chunks.c reference.c binaries.c sources.c checks.c names.c dpkgversions.c release.c mprintf.c updates.c strlist.c signature.c distribution.c checkindeb.c checkindsc.c checkin.c upgradelist.c target.c aptmethod.c downloadcache.c main.c override.c terms.c ignore.c filterlist.c exports.c tracking.c optionsfile.c readrelease.c donefile.c pull.c contents.c filelist.c $(ARCHIVE_USED) $(ARCHIVE_CONTENTS)
reprepro_SOURCES = diffindex.c rredpatch.c pool.c atoms.c uncompression.c remoterepository.c indexfile.c copypackages.c sourceextraction.c checksums.c readtextfile.c filecntl.c sha1.c sha256.c configparser.c database.c freespace.c log.c changes.c incoming.c uploaderslist.c guesscomponent.c files.c md5.c dirs.c chunks.c reference.c binaries.c sources.c checks.c names.c dpkgversions.c release.c mprintf.c updates.c strlist.c signature.c distribution.c checkindeb.c checkindsc.c checkin.c upgradelist.c target.c aptmethod.c downloadcache.c main.c override.c terms.c ignore.c filterlist.c exports.c tracking.c optionsfile.c readrelease.c donefile.c pull.c contents.c filelist.c $(ARCHIVE_USED) $(ARCHIVE_CONTENTS)
EXTRA_reprepro_SOURCE = $(ARCHIVE_UNUSED)
changestool_SOURCES = uncompression.c sourceextraction.c readtextfile.c filecntl.c tool.c chunkedit.c strlist.c checksums.c sha1.c sha256.c md5.c mprintf.c chunks.c signature.c dirs.c names.c $(ARCHIVE_USED)
rredtool_SOURCES = rredtool.c rredpatch.c
noinst_HEADERS = pool.h atoms.h uncompression.h remoterepository.h copypackages.h sourceextraction.h checksums.h readtextfile.h filecntl.h sha1.h sha256.h configparser.h database_p.h database.h freespace.h log.h changes.h incoming.h guesscomponent.h md5.h dirs.h files.h chunks.h reference.h binaries.h sources.h checks.h names.h release.h error.h mprintf.h updates.h strlist.h signature.h distribution.h debfile.h checkindeb.h checkindsc.h upgradelist.h target.h aptmethod.h downloadcache.h override.h terms.h ignore.h filterlist.h dpkgversions.h checkin.h exports.h globals.h tracking.h trackingt.h optionsfile.h readrelease.h donefile.h pull.h ar.h filelist.h contents.h chunkedit.h uploaderslist.h indexfile.h rredpatch.h
noinst_HEADERS = pool.h atoms.h uncompression.h remoterepository.h copypackages.h sourceextraction.h checksums.h readtextfile.h filecntl.h sha1.h sha256.h configparser.h database_p.h database.h freespace.h log.h changes.h incoming.h guesscomponent.h md5.h dirs.h files.h chunks.h reference.h binaries.h sources.h checks.h names.h release.h error.h mprintf.h updates.h strlist.h signature.h distribution.h debfile.h checkindeb.h checkindsc.h upgradelist.h target.h aptmethod.h downloadcache.h override.h terms.h ignore.h filterlist.h dpkgversions.h checkin.h exports.h globals.h tracking.h trackingt.h optionsfile.h readrelease.h donefile.h pull.h ar.h filelist.h contents.h chunkedit.h uploaderslist.h indexfile.h rredpatch.h diffindex.h
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in $(srcdir)/configure $(srcdir)/stamp-h.in $(srcdir)/aclocal.m4 $(srcdir)/config.h.in
......
......@@ -5,6 +5,7 @@ reprepro (3.8.3-0) UNRELEASED; urgency=low
new --keeptemporaries is specified (Closes: 516395)
* delete unexpected files in the pool which are in the way of new files
(Closes: 516578)
* support using Packages.diff (Closes: 405634)
-- Bernhard R. Link <brlink@debian.org> Mon, 23 Feb 2009 21:31:18 +0100
......
/* This file is part of "reprepro"
* Copyright (C) 2003,2004,2005,2007 Bernhard R. Link
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1301 USA
*/
#include <config.h>
#include <errno.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "error.h"
#include "names.h"
#include "chunks.h"
#include "readtextfile.h"
#include "checksums.h"
#include "diffindex.h"
void diffindex_free(struct diffindex *diffindex) {
int i;
if( diffindex == NULL )
return;
checksums_free(diffindex->destination);
for( i = 0 ; i < diffindex->patchcount ; i ++ ) {
checksums_free(diffindex->patches[i].frompackages);
free(diffindex->patches[i].name);
checksums_free(diffindex->patches[i].checksums);
}
free(diffindex);
}
static void parse_sha1line(const char *p, /*@out@*/struct hashes *hashes, /*@out@*/const char **rest) {
memset(hashes, 0, sizeof(struct hashes));
hashes->hashes[cs_sha1sum].start = p;
while( (*p >= 'a' && *p <= 'f') || (*p >= 'A' && *p <= 'F')
|| (*p >= '0' && *p <= '9') )
p++;
hashes->hashes[cs_sha1sum].len = p - hashes->hashes[cs_sha1sum].start;
while( *p == ' ' || *p == '\t' )
p++;
hashes->hashes[cs_length].start = p;
while( *p >= '0' && *p <= '9' )
p++;
hashes->hashes[cs_length].len = p - hashes->hashes[cs_length].start;
while( *p == ' ' || *p == '\t' )
p++;
*rest = p;
}
static inline retvalue add_current(const char *diffindexfile, struct diffindex *n, const char *current) {
struct hashes hashes;
const char *p;
retvalue r;
parse_sha1line(current, &hashes, &p);
if( hashes.hashes[cs_sha1sum].len == 0
|| hashes.hashes[cs_length].len == 0
|| *p != '\0' ) {
r = RET_ERROR;
} else
r = checksums_initialize(&n->destination, hashes.hashes);
ASSERT_NOT_NOTHING(r);
if( RET_WAS_ERROR(r) )
fprintf(stderr, "Error parsing SHA1-Current in '%s'!\n",
diffindexfile);
return r;
}
static inline retvalue add_patches(const char *diffindexfile, struct diffindex *n, const struct strlist *patches) {
int i;
assert( patches->count == n->patchcount );
for( i = 0 ; i < n->patchcount; i++ ) {
struct hashes hashes;
const char *patchname;
retvalue r;
parse_sha1line(patches->values[i], &hashes, &patchname);
if( hashes.hashes[cs_sha1sum].len == 0
|| hashes.hashes[cs_length].len == 0
|| *patchname == '\0' ) {
r = RET_ERROR;
} else
r = checksums_initialize(&n->patches[i].checksums,
hashes.hashes);
ASSERT_NOT_NOTHING(r);
if( RET_WAS_ERROR(r) ) {
fprintf(stderr,
"Error parsing SHA1-Patches line %d in '%s':!\n'%s'\n",
i, diffindexfile, patches->values[i]);
return r;
}
n->patches[i].name = strdup(patchname);
if( FAILEDTOALLOC(n) )
return RET_ERROR_OOM;
}
return RET_OK;
}
static inline retvalue add_history(const char *diffindexfile, struct diffindex *n, const struct strlist *history) {
int i,j;
for( i = 0 ; i < history->count ; i++ ) {
struct hashes hashes;
const char *patchname;
struct checksums *checksums;
retvalue r;
parse_sha1line(history->values[i], &hashes, &patchname);
if( hashes.hashes[cs_sha1sum].len == 0
|| hashes.hashes[cs_length].len == 0
|| *patchname == '\0' ) {
r = RET_ERROR;
} else
r = checksums_initialize(&checksums,
hashes.hashes);
ASSERT_NOT_NOTHING(r);
if( RET_WAS_ERROR(r) ) {
fprintf(stderr,
"Error parsing SHA1-History line %d in '%s':!\n'%s'\n",
i, diffindexfile, history->values[i]);
return r;
}
j = 0;
while( j < n->patchcount && strcmp(n->patches[j].name,
patchname) != 0 )
j++;
if( j >= n->patchcount ) {
fprintf(stderr, "'%s' lists '%s' in history but not in patches!\n",
diffindexfile, patchname);
checksums_free(checksums);
continue;
}
if( n->patches[j].frompackages != NULL ) {
fprintf(stderr,
"Warning: '%s' lists multiple histories for '%s'!\nOnly using last one!\n",
diffindexfile, patchname);
checksums_free(n->patches[j].frompackages);
}
n->patches[j].frompackages = checksums;
}
return RET_OK;
}
retvalue diffindex_read(const char *diffindexfile, struct diffindex **out_p) {
retvalue r;
char *chunk, *current;
struct strlist history, patches;
struct diffindex *n;
r = readtextfile(diffindexfile, diffindexfile, &chunk, NULL);
ASSERT_NOT_NOTHING(r);
if( RET_WAS_ERROR(r) )
return r;
r = chunk_getextralinelist(chunk, "SHA1-History", &history);
if( r == RET_NOTHING ) {
fprintf(stderr, "'%s' misses SHA1-History field\n",
diffindexfile);
r = RET_ERROR;
}
if( RET_WAS_ERROR(r) ) {
free(chunk);
return r;
}
r = chunk_getextralinelist(chunk, "SHA1-Patches", &patches);
if( r == RET_NOTHING ) {
fprintf(stderr, "'%s' misses SHA1-Patches field\n",
diffindexfile);
r = RET_ERROR;
}
if( RET_WAS_ERROR(r) ) {
free(chunk);
strlist_done(&history);
return r;
}
r = chunk_getvalue(chunk, "SHA1-Current", &current);
free(chunk);
if( r == RET_NOTHING ) {
fprintf(stderr, "'%s' misses SHA1-Current field\n",
diffindexfile);
r = RET_ERROR;
}
if( RET_WAS_ERROR(r) ) {
strlist_done(&history);
strlist_done(&patches);
return r;
}
n = calloc(1, sizeof(struct diffindex) +
patches.count * sizeof(struct diffindex_patch));
if( FAILEDTOALLOC(n) ) {
strlist_done(&history);
strlist_done(&patches);
free(current);
return r;
}
n->patchcount = patches.count;
r = add_current(diffindexfile, n, current);
if( RET_IS_OK(r) )
r = add_patches(diffindexfile, n, &patches);
if( RET_IS_OK(r) )
r = add_history(diffindexfile, n, &history);
ASSERT_NOT_NOTHING(r);
strlist_done(&history);
strlist_done(&patches);
free(current);
if( RET_IS_OK(r) )
*out_p = n;
else
diffindex_free(n);
return r;
}
#ifndef REPREPRO_DIFFINDEX_H
#define REPREPRO_DIFFINDEX_H
struct diffindex {
struct checksums *destination;
int patchcount;
struct diffindex_patch {
struct checksums *frompackages;
char *name;
struct checksums *checksums;
/* safe-guard against cycles */
bool done;
} patches[];
};
void diffindex_free(/*@only@*/struct diffindex *);
retvalue diffindex_read(const char *, /*@out@*/struct diffindex **);
#endif
......@@ -1268,9 +1268,10 @@ to the name of the update rule causing it.
.TP
.B DownloadListsAs
The arguments of this field, which much be elements of the
form \fB.\fP, \fB.gz\fP, \fB.bz2\fP and \fB.lzma\fP specify in
which order reprepro will look for a useable variant of needed
index files in the downloaded Release file.
form \fB.\fP, \fB.gz\fP, \fB.bz2\fP, \fB.lzma\fP and \fB.diff\fP
specify in which order reprepro
will look for a useable variant of needed index files
in the downloaded Release file.
(The default is \fB.lzma .bz2 .gz .\fP, i.e. download .lzma if
listed in the Release file and there is a way to uncompress it,
then .bz2 if useable, then .gz and then uncompressed).
......@@ -1283,7 +1284,8 @@ be downloaded.
As there is no way to see if an uncompressed variant
of the file is available (as the Release file always lists their
checksums, even if not there),
it is usually not adviseable to list '\fB.\fP' not as the last argument.
it is usually not adviseable to list '\fB.\fP' anywhere but
as the last argument.
.SS conf/pulls
This file contains the rules for pulling packages from one
distribution to another.
......
/* This file is part of "reprepro"
* Copyright (C) 2004,2005,2007 Bernhard R. Link
* Copyright (C) 2004,2005,2007,2009 Bernhard R. Link
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
......
......@@ -161,6 +161,7 @@ retvalue files_deletefile(struct database *database, const char *filekey) {
r = RET_ERRNO(en);
if( errno == ENOENT ) {
fprintf(stderr,"%s not found, forgetting anyway\n",filename);
free(filename);
return RET_NOTHING;
} else {
fprintf(stderr, "error %d while unlinking %s: %s\n",
......
This diff is collapsed.
......@@ -37,7 +37,11 @@ struct encoding_preferences {
/* number of preferences, 0 means use default */
unsigned short count;
/* a list of compressions to use */
enum compression requested[3*c_COUNT];
struct compression_preference {
bool diff :1;
bool force :1;
enum compression compression :6;
} requested[3*c_COUNT];
};
struct remote_index *remote_index(struct remote_distribution *, const char *architecture, const char *component, packagetype_t, const struct encoding_preferences *);
......
......@@ -71,6 +71,11 @@ struct modification *patch_getmodifications(struct rred_patch *p) {
return m;
}
const struct modification *patch_getconstmodifications(struct rred_patch *p) {
assert( !p->alreadyinuse );
return p->modifications;
}
static struct modification *modification_freehead(/*@only@*/struct modification *p) {
struct modification *m = p->next;
free(p);
......
......@@ -7,6 +7,7 @@ struct modification;
retvalue patch_load(const char *, off_t, /*@out@*/struct rred_patch **);
void patch_free(/*@only@*/struct rred_patch *);
/*@only@*//*@null@*/struct modification *patch_getmodifications(struct rred_patch *);
/*@null@*/const struct modification *patch_getconstmodifications(struct rred_patch *);
void modification_freelist(/*@only@*/struct modification *);
retvalue combine_patches(/*@out@*/struct modification **, /*@only@*/struct modification *, /*@only@*/struct modification *);
void modification_printaspatch(FILE *, const struct modification *);
......
......@@ -12,6 +12,7 @@ testlayeredupdate.sh \
test.inc \
test.sh \
testincludeextra.sh \
testpackagediff.sh \
testsignatures.sh \
testsnapshotcopyrestore.sh \
testsubcomponents.sh \
......
......@@ -4,6 +4,7 @@ set -e
source $(dirname $0)/test.inc
runtest packagediff
runtest includeextra
runtest atoms
runtest trackingcorruption
......
This diff is collapsed.
/* This file is part of "reprepro"
* Copyright (C) 2003,2004,2005,2006,2007,2008 Bernhard R. Link
* Copyright (C) 2003,2004,2005,2006,2007,2008,2009 Bernhard R. Link
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
......@@ -357,6 +357,7 @@ CFUSETPROC(update_pattern, downloadlistsas) {
this->downloadlistsas_set = true;
r = config_getword(iter, &word);
while( RET_IS_OK(r) ) {
bool force;
if( e >= ARRAYCOUNT(this->downloadlistsas.requested) ) {
fprintf(stderr,
"%s:%d:%d: Ignoring all but first %d entries...\n",
......@@ -368,8 +369,10 @@ CFUSETPROC(update_pattern, downloadlistsas) {
free(word);
break;
}
force = false;
if( strncmp(word, "force.", 6) == 0 ) {
u = word + 5;
// TODO: set force to true once supported
fprintf(stderr,
"%s:%d:%d: forcing not yet supported in this version, treating as normal '%s'\n",
config_filename(iter),
......@@ -385,18 +388,19 @@ CFUSETPROC(update_pattern, downloadlistsas) {
}
}
if( c < c_COUNT ) {
this->downloadlistsas.requested[e++] = c;
this->downloadlistsas.requested[e].compression = c;
this->downloadlistsas.requested[e].diff = false;
this->downloadlistsas.requested[e].force = force;
e++;
free(word);
r = config_getword(iter, &word);
continue;
}
if( strcmp(u, ".diff") == 0 || strcmp(u, "diff") == 0 ) {
fprintf(stderr,
"%s:%d:%d: ignoring '%s', as not yet supported in this version\n",
config_filename(iter),
config_markerline(iter),
config_markercolumn(iter),
word);
this->downloadlistsas.requested[e].compression = c_gzip;
this->downloadlistsas.requested[e].diff = true;
this->downloadlistsas.requested[e].force = force;
e++;
free(word);
r = config_getword(iter, &word);
continue;
......
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