Commit 45952288 authored by Bernhard Link's avatar Bernhard Link

new pull and checkpull actions

parent a4990cb6
2006-05-03 Bernhard R. Link <brlink@debian.org>
* add new pull and checkpull actions
2006-04-29 Bernhard R. Link <brlink@debian.org>
* fix some minor memory leaks
......
......@@ -6,8 +6,8 @@ bin_PROGRAMS = reprepro
AM_CPPFLAGS = -D_GNU_SOURCE=1 -Wall
reprepro_SOURCES = guesscomponent.c files.c md5.c md5sum.c dirs.c chunks.c reference.c packages.c binaries.c sources.c names.c dpkgversions.c release.c mprintf.c updates.c strlist.c signature.c distribution.c extractcontrol.c checkindeb.c checkindsc.c checkin.c copyfile.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
noinst_HEADERS = guesscomponent.h md5.h md5sum.h dirs.h files.h chunks.h reference.h packages.h binaries.h sources.h names.h release.h error.h mprintf.h updates.h strlist.h signature.h distribution.h extractcontrol.h checkindeb.h checkindsc.h copyfile.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
reprepro_SOURCES = guesscomponent.c files.c md5.c md5sum.c dirs.c chunks.c reference.c packages.c binaries.c sources.c names.c dpkgversions.c release.c mprintf.c updates.c strlist.c signature.c distribution.c extractcontrol.c checkindeb.c checkindsc.c checkin.c copyfile.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
noinst_HEADERS = guesscomponent.h md5.h md5sum.h dirs.h files.h chunks.h reference.h packages.h binaries.h sources.h names.h release.h error.h mprintf.h updates.h strlist.h signature.h distribution.h extractcontrol.h checkindeb.h checkindsc.h copyfile.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
MAINTAINERCLEANFILES = Makefile.in configure install-sh stamp-h.in aclocal.m4 config.h.in mkinstalldirs config.guess config.sub missing
......
......@@ -3,6 +3,10 @@ Updates since 0.8.2:
distributions. (Now every distribution processed
without errors is exported by default, with options
for always, never or only export it when changed)
- added pull and checkpull actions.
Those are roughly equivalent to upgrade rules with
file:/path/to/basedir Method, but faster and a bit
more limited (files cannot change components)
Updates since 0.8.1:
- mark process list files and only skip those not marked
......
/* This file is part of "reprepro"
* Copyright (C) 2003,2004,2005 Bernhard R. Link
* Copyright (C) 2003,2004,2005,2006 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.
......@@ -58,6 +58,7 @@ retvalue distribution_free(struct distribution *distribution) {
strlist_done(&distribution->architectures);
strlist_done(&distribution->components);
strlist_done(&distribution->updates);
strlist_done(&distribution->pulls);
exportmode_done(&distribution->dsc);
exportmode_done(&distribution->deb);
exportmode_done(&distribution->udeb);
......@@ -174,6 +175,7 @@ static const char * const allowedfields[] = {
"Architectures", "Components", "Update", "SignWith", "DebOverride",
"UDebOverride", "DscOverride", "Tracking", "NotAutomatic",
"UDebComponents", "DebIndices", "DscIndices", "UDebIndices",
"Pull",
NULL};
assert( chunk !=NULL && distribution != NULL );
......@@ -249,6 +251,11 @@ NULL};
(void)distribution_free(r);
return ret;
}
ret = chunk_getwordlist(chunk,"Pull",&r->pulls);
if( RET_WAS_ERROR(ret) ) {
(void)distribution_free(r);
return ret;
}
getpossibleemptyfield("SignWith",signwith);
getpossibleemptyfield("DebOverride",deb_override);
getpossibleemptyfield("UDebOverride",udeb_override);
......
......@@ -30,6 +30,8 @@ struct distribution {
struct strlist architectures,components;
/* which update rules to use */
struct strlist updates;
/* which rules to use to pull packages from other distributions */
struct strlist pulls;
/* the key to sign with, may be NULL: */
/*@null@*/char *signwith;
/* the override file to use by default */
......
.TH REPREPRO 1 "11 April, 2006" "reprepro" REPREPRO
.TH REPREPRO 1 "03 May, 2006" "reprepro" REPREPRO
.SH NAME
reprepro \- produce, manage and sync a local repository of debian packages
.SH SYNOPSIS
......@@ -128,7 +128,7 @@ Overrides the priority of inclusions. (Also override possible override files)
.TP
.BR \-\-export= ( never | changed | normal | force )
This option specify weather and how the high level actions
(e.g. install, update, delete)
(e.g. install, update, pull, delete)
should export the index files of the distributions they work with.
.TP
.BR \-\-export=normal " (default)"
......@@ -246,7 +246,7 @@ description of
.B conf/updates
below.
.TP
.BR iteratedupdate " [ " \fIcodenames\fP " ]"
.BR iteratedupdate " [ " \fIcodenames\fP " ] (EXPERIMENTAL!)"
This is an experimental variant of update, that processes
the distributions and targets within them one by one,
resulting in much lower memory consumption for an update
......@@ -254,7 +254,19 @@ of multiple distributions.
.TP
.BR checkupdate " [ " \fIcodenames\fP " ]"
Same like
.B update,
.BR update ,
but will show what it will change instead of actually changing it.
.TP
.BR pull " [ " \fIcodenames\fP " ]"
pull in newer packages into the specified distributions (all if none given)
from other distributions in the same repository.
See the description of
.B conf/pulls
below.
.TP
.BR checkpull " [ " \fIcodenames\fP " ]"
Same like
.BR pull ,
but will show what it will change instead of actually changing it.
.TP
.B includedeb \fIcodename\fP \fI.deb-filename\fP
......@@ -491,6 +503,13 @@ When this field is present, it describes which update rules are used
for this distribution. There also can be a magic rule minus ("\-"),
see below.
.TP
.B Pull
When this field is present, it describes which pull rules are used
for this distribution.
Pull rules are like Update rules,
but get their stuff from other distributions and not from external sources.
See the description for \fBconf/pulls\fP.
.TP
.B SignWith
When this field is present, a Release.gpg file will be generated.
If the value is "yes" and "default", the default key
......@@ -666,6 +685,46 @@ If this is given, it is executed for all downloaded index files
with the downloaded list as first and a filename that will
be used instead of this. (e.g. "ListHook: /bin/cp" works
but does nothing.)
.SS conf/pulls
This file contains the rules for pulling packages from one
distribution to another.
While this can also be done with update rules using the file
or copy method and using the exported indices of that other
distribution, this way is faster.
It also ensures the current files are used and no copies
are made.
(This also leads to the limitation that pulling from one
component to another is not possible.)
Each rule consists out of the following fields:
.TP
.B Name
The name of this pull rule as it can be used in the
.B Pull
field in conf/distributions.
.TP
.B From
The codename of the distribution to pull packages from.
.TP
.B Components
The components of the distribution to get from.
Unknown items are ignored to ease rule reusal.
If there are no items, all components from distribution are taken.
(Use some non existing like "none", if you want none).
.TP
.B Architectures
The architectures to update.
If omitted all from the distribution to pull from.
.TP
.B UDebComponents
Like
.B Components
but for the udebs.
.TP
.B FilterFormula
.TP
.B FilterList
The same as with update rules.
.SH "OVERRIDE FILES"
Override files are yet only used when things are manually added,
not when imported while updating from an external source.
......@@ -856,7 +915,7 @@ and without errors while deleting it should already be forgotten, otherwise
a \fBdeleteunreferenced\fP or even some \fB__forget\fP might help.)
.SS The magic delete rule ("\-").
A minus as a single word in the
.B Updates:
.B Update:
line of an distribution marks everything to be deleted. The mark causes later rules
to get packages even if they have (strict) lower versions. The mark will
get removed if a later rule sets the package on hold (hold is not yet implemented,
......@@ -864,12 +923,12 @@ in case you might wonder) or would get a package with the same version
(Which it will not, see above). If the mark is still there at the end of the processing,
the package will get removed.
.P
Thus the line "Updates: \-
Thus the line "Update: \-
.I rules
" will cause all packages to be exactly the
highest Version found in
.I rules.
The line "Updates:
The line "Update:
.I near
\-
.I rules
......
......@@ -43,6 +43,7 @@
#include "release.h"
#include "aptmethod.h"
#include "updates.h"
#include "pull.h"
#include "upgradelist.h"
#include "signature.h"
#include "extractcontrol.h"
......@@ -821,7 +822,100 @@ ACTION_N(checkupdate) {
return result;
}
/***********************migrate*******************************/
ACTION_D(pull) {
retvalue result,r;
struct pull_rule *rules;
struct pull_distribution *p;
struct distribution *distributions,
/* list of distributions only source but not target of a replication: */
*sourceonly = NULL;
if( argc < 1 ) {
fprintf(stderr,"reprepro pull [<distributions>]\n");
return RET_ERROR;
}
result = distribution_getmatched(confdir,argc-1,argv+1,&distributions);
assert( result != RET_NOTHING );
if( RET_WAS_ERROR(result) )
return result;
result = pull_getrules(confdir,&rules);
if( RET_WAS_ERROR(result) ) {
r = distribution_freelist(distributions);
RET_ENDUPDATE(result,r);
return result;
}
assert( RET_IS_OK(result) );
result = pull_prepare(confdir,rules,distributions,&p,&sourceonly);
if( RET_WAS_ERROR(result) ) {
pull_freerules(rules);
r = distribution_freelist(distributions);
RET_ENDUPDATE(result,r);
return result;
}
result = pull_update(dbdir,filesdb,references,p,force,dereferenced);
pull_freerules(rules);
pull_freedistributions(p);
r = distribution_freelist(sourceonly);
RET_ENDUPDATE(result,r);
r = distribution_exportandfreelist(export,distributions,
confdir,dbdir,distdir);
RET_ENDUPDATE(result,r);
return result;
}
ACTION_N(checkpull) {
retvalue result,r;
struct pull_rule *rules;
struct pull_distribution *p;
struct distribution *distributions,
/* list of distributions only source but not target of a replication: */
*sourceonly = NULL;
if( argc < 1 ) {
fprintf(stderr,"reprepro checkpull [<distributions>]\n");
return RET_ERROR;
}
result = distribution_getmatched(confdir,argc-1,argv+1,&distributions);
assert( result != RET_NOTHING );
if( RET_WAS_ERROR(result) )
return result;
result = pull_getrules(confdir,&rules);
if( RET_WAS_ERROR(result) ) {
r = distribution_freelist(distributions);
RET_ENDUPDATE(result,r);
return result;
}
assert( RET_IS_OK(result) );
result = pull_prepare(confdir,rules,distributions,&p,&sourceonly);
if( RET_WAS_ERROR(result) ) {
pull_freerules(rules);
r = distribution_freelist(distributions);
RET_ENDUPDATE(result,r);
return result;
}
result = pull_checkupdate(dbdir,p,force);
pull_freerules(rules);
pull_freedistributions(p);
r = distribution_freelist(sourceonly);
RET_ENDUPDATE(result,r);
r = distribution_freelist(distributions);
RET_ENDUPDATE(result,r);
return result;
}
/***********************rereferencing*************************/
struct data_binsrcreref { /*@temp@*/const struct distribution *distribution; /*@temp@*/references refs;};
......@@ -1619,6 +1713,8 @@ static const struct action {
{"update", A_D(update)},
{"iteratedupdate", A_D(iteratedupdate)},
{"checkupdate", A_N(checkupdate)},
{"pull", A_D(pull)},
{"checkpull", A_N(checkpull)},
{"includedeb", A_D(includedeb)},
{"includeudeb", A_D(includedeb)},
{"includedsc", A_D(includedsc)},
......
/* This file is part of "reprepro"
* Copyright (C) 2003,2004,2005 Bernhard R. Link
* Copyright (C) 2003,2004,2005,2006 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.
......@@ -711,3 +711,65 @@ retvalue calc_parsefileline(const char *fileline,char **filename,char **md5sum)
char *calc_trackreferee(const char *codename,const char *sourcename,const char *sourceversion) {
return mprintf("%s %s %s",codename,sourcename,sourceversion);
}
retvalue splitlist(struct strlist *from,
struct strlist *into,
const struct strlist *list) {
retvalue r;
int i;
r = strlist_init(from);
if( RET_WAS_ERROR(r) ) {
return r;
}
r = strlist_init(into);
if( RET_WAS_ERROR(r) ) {
strlist_done(from);
return r;
}
/* * Iterator over components to update * */
r = RET_NOTHING;
for( i = 0 ; i < list->count ; i++ ) {
const char *item,*seperator;
char *origin,*destination;
item = list->values[i];
// TODO: isn't this broken for the !*(dest+1) case ?
if( (seperator = strchr(item,'>')) == NULL ) {
destination = strdup(item);
origin = strdup(item);
} else if( seperator == item ) {
destination = strdup(seperator+1);
origin = strdup(seperator+1);
} else if( *(seperator+1) == '\0' ) {
destination = strndup(item,seperator-item);
origin = strndup(item,seperator-item);
} else {
origin = strndup(item,seperator-item);
destination = strdup(seperator+1);
}
if( origin == NULL || destination == NULL ) {
free(origin);free(destination);
strlist_done(from);
strlist_done(into);
return RET_ERROR_OOM;
}
r = strlist_add(from,origin);
if( RET_WAS_ERROR(r) ) {
free(destination);
strlist_done(from);
strlist_done(into);
return r;
}
r = strlist_add(into,destination);
if( RET_WAS_ERROR(r) ) {
strlist_done(from);
strlist_done(into);
return r;
}
r = RET_OK;
}
return r;
}
......@@ -47,4 +47,11 @@ retvalue propercodename(const char *codename);
retvalue properarchitectures(const struct strlist *architectures);
retvalue propercomponents(const struct strlist *components);
/* create two stringlists out of one,
* from[i]=into[i]=list[i] if list[i] contains no '>'
* from[i] '>' into[i] = list[i] when list[i] contains a '>'
*/
retvalue splitlist(/*@out@*/struct strlist *from,
/*@out@*/struct strlist *into,
const struct strlist *list);
#endif
This diff is collapsed.
#ifndef REPREPRO_PULLS_H
#define REPREPRO_PULLS_H
#ifndef REPREPRO_ERROR_H
#include "error.h"
#warning "What's hapening here?"
#endif
#ifndef REPREPRO_REFERENCES_H
#include "reference.h"
#endif
#ifndef REPREPRO_RELEASE_H
#include "release.h"
#endif
#ifndef REPREPRO_DISTRIBUTION_H
#include "distribution.h"
#endif
#ifndef REPREPRO_STRLIST_H
#include "strlist.h"
#endif
struct pull_rule;
struct pull_distribution;
retvalue pull_getrules(const char *confdir,/*@out@*/struct pull_rule **rules);
void pull_freerules(/*@only@*/struct pull_rule *p);
void pull_freedistributions(/*@only@*/struct pull_distribution *p);
retvalue pull_prepare(const char *confdir,struct pull_rule *rules,struct distribution *,/*@out@*/struct pull_distribution **,struct distribution **alsoneeded);
retvalue pull_update(const char *dbdir,filesdb filesdb,references refs,struct pull_distribution *distributions,int force,struct strlist *dereferencedfilekeys);
retvalue pull_checkupdate(const char *dbdir,struct pull_distribution *distributions,int force);
#endif
......@@ -77,7 +77,6 @@ retvalue target_closepackagesdb(struct target *target);
retvalue target_addpackage(struct target *target,references refs,const char *name,const char *version,const char *control,const struct strlist *filekeys,bool_t downgrade,/*@null@*/struct strlist *dereferencedfilekeys,/*@null@*/struct trackingdata *,enum filetype);
retvalue target_removepackage(struct target *target,references refs,const char *name, /*@null@*/struct strlist *dereferencedfilekeys,struct trackingdata *);
retvalue target_writeindices(const char *dirofdist,struct target *target,int force,bool_t onlyneeded);
retvalue target_check(struct target *target,filesdb filesdb,references refsdb,int force);
retvalue target_rereference(struct target *target,references refs,int force);
retvalue target_retrack(struct target *target,trackingdb tracks,references refs,int force);
......
......@@ -264,67 +264,6 @@ static inline retvalue newupdatetarget(struct update_target **ts,/*@dependent@*/
return RET_OK;
}
static retvalue splitlist(struct strlist *from,
struct strlist *into,
const struct strlist *list) {
retvalue r;
int i;
r = strlist_init(from);
if( RET_WAS_ERROR(r) ) {
return r;
}
r = strlist_init(into);
if( RET_WAS_ERROR(r) ) {
strlist_done(from);
return r;
}
/* * Iterator over components to update * */
r = RET_NOTHING;
for( i = 0 ; i < list->count ; i++ ) {
const char *item,*seperator;
char *origin,*destination;
item = list->values[i];
// TODO: isn't this broken for the !*(dest+1) case ?
if( (seperator = strchr(item,'>')) == NULL ) {
destination = strdup(item);
origin = strdup(item);
} else if( seperator == item ) {
destination = strdup(seperator+1);
origin = strdup(seperator+1);
} else if( *(seperator+1) == '\0' ) {
destination = strndup(item,seperator-item);
origin = strndup(item,seperator-item);
} else {
origin = strndup(item,seperator-item);
destination = strdup(seperator+1);
}
if( origin == NULL || destination == NULL ) {
free(origin);free(destination);
strlist_done(from);
strlist_done(into);
return RET_ERROR_OOM;
}
r = strlist_add(from,origin);
if( RET_WAS_ERROR(r) ) {
free(destination);
strlist_done(from);
strlist_done(into);
return r;
}
r = strlist_add(into,destination);
if( RET_WAS_ERROR(r) ) {
strlist_done(from);
strlist_done(into);
return r;
}
r = RET_OK;
}
return r;
}
inline static retvalue parse_pattern(const char *confdir,const char *chunk, struct update_pattern **pattern) {
struct update_pattern *update;
struct strlist componentslist,architectureslist;
......
/* This file is part of "reprepro"
* Copyright (C) 2004,2005 Bernhard R. Link
* Copyright (C) 2004,2005,2006 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.
......@@ -289,7 +289,7 @@ static retvalue upgradelist_trypackage(void *data,const char *chunk){
free(version);
return RET_ERROR_OOM;
}
assert(upgrade->currentaptmethod!=NULL);
// assert(upgrade->currentaptmethod!=NULL);
new->deleted = FALSE; //to be sure...
new->aptmethod = upgrade->currentaptmethod;
new->name = packagename;
......@@ -367,6 +367,7 @@ static retvalue upgradelist_trypackage(void *data,const char *chunk){
* so we keep the old one for sake of speed. */
// TODO: add switch to force reimport of everything...
current->deleted = FALSE;
// TODO: if it was deleted, set new_version here
free(version);
free(packagename);
return RET_NOTHING;
......@@ -382,6 +383,7 @@ static retvalue upgradelist_trypackage(void *data,const char *chunk){
if( vcmp == 0 ) {
current->deleted = FALSE;
current->version = current->version_in_use;
// TODO: if it was deleted, set new_version here
free(version);
free(packagename);
return RET_NOTHING;
......@@ -403,7 +405,7 @@ static retvalue upgradelist_trypackage(void *data,const char *chunk){
free(current->new_version);
current->new_version = version;
current->version = version;
assert(upgrade->currentaptmethod!=NULL);
// assert(upgrade->currentaptmethod!=NULL);
current->aptmethod = upgrade->currentaptmethod;
strlist_move(&current->new_filekeys,&files);
strlist_move(&current->new_md5sums,&md5sums);
......@@ -424,6 +426,28 @@ retvalue upgradelist_update(struct upgradelist *upgrade,struct aptmethod *method
return chunk_foreach(filename,upgradelist_trypackage,upgrade,force,FALSE);
}
static retvalue try(void *data,UNUSED(const char *package),const char *chunk) {
return upgradelist_trypackage(data,chunk);
}
retvalue upgradelist_pull(struct upgradelist *upgrade,struct target *source,upgrade_decide_function *predecide,void *decide_data,int force,const char *dbdir) {
retvalue result,r;
upgrade->last = NULL;
upgrade->currentaptmethod = NULL;
upgrade->predecide = predecide;
upgrade->predecide_data = decide_data;
r = target_initpackagesdb(source,dbdir);
if( RET_WAS_ERROR(r) )
return r;
result = packages_foreach(source->packages,try,upgrade,force);
r = target_closepackagesdb(source);
RET_UPDATE(result,r);
return result;
}
/* mark all packages as deleted, so they will vanis unless readded or reholded */
retvalue upgradelist_deleteall(struct upgradelist *upgrade) {
struct package_data *pkg;
......
......@@ -33,6 +33,9 @@ retvalue upgradelist_listmissing(struct upgradelist *upgrade,filesdb files);
/* Take all items in 'filename' into account, and remember them coming from 'method' */
retvalue upgradelist_update(struct upgradelist *upgrade,/*@dependent@*/struct aptmethod *method,const char *filename,upgrade_decide_function *predecide,void *decide_data,int force);
/* Take all items in source into account */
retvalue upgradelist_pull(struct upgradelist *upgrade,struct target *source,upgrade_decide_function *predecide,void *decide_data,int force, const char *dbdir);
/* mark all packages as deleted, so they will vanis unless readded or reholded */
retvalue upgradelist_deleteall(struct upgradelist *upgrade);
......
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