Commit bf603ec0 authored by Bernhard Link's avatar Bernhard Link

add possibility to specify a directory relative to basedir by prepending '+b/' (Closes: 540115)

parent 1769735b
2009-08-06
* command line (and conf/options) options to specify a directory
now treat arguments starting with '+b/', '+c/' or '+o/' as relative
to the basedir, confdir or outdir.
* warn if directories do not start with '/', './' or '+x/'.
2009-08-05
* if a package is not accepted by processincoming because no
distribution is found for it or no distribution allows it, the
......
Updates since 3.11.1:
- warn if directories are relative to the currect directory but do not start
with './'
- directories starting '+b/' '+o/' and '+c/' are relative to basedir, outdir
or confdir.
Updates since 3.11.0:
- new changestool option --create-with-all-fields
- new --morguedir option (or morguedir in conf/options, of course)
......
......@@ -2,6 +2,8 @@ reprepro (3.11.2-0) UNRELEASED; urgency=low
* improve error message when deleteunreferenced
is alled with keepunreferencedfiles in conf/options (Closes: 539509)
* add possibility to specify a directory relative to basedir by
prepending '+b/' (Closes: 540115)
-- Bernhard R. Link <brlink@debian.org> Sat, 01 Aug 2009 18:02:14 +0200
......
......@@ -63,18 +63,25 @@ Sets the base\-dir of the repository to manage, i.e. where the
subdirectory resides. And in which the
.B dists/
directory is placed by default.
If this starts with '\fB+b/\fP', it is relative to basedir.
The default for this is \fIbasedir\fP.
.TP
.B \-\-confdir \fIconfdir\fP
Sets the directory where the configuration is searched in.
If none is given, \fIbasedir\fP\fB/conf\fP will be used.
If this starts with '\fB+b/\fP', it is relative to basedir.
If none is given, \fB+b/conf\fP (i.e. \fIbasedir\fP\fB/conf\fP) will be used.
.TP
.B \-\-distdir \fIdistdir\fP
Sets the directory to generate index files relatively to. (i.e. things like
Packages.gz, Sources.gz and Release.gpg)
If none is given, \fIoutdir\fP\fB/dists\fP is used.
If this starts with '\fB+b/\fP', it is relative to basedir,
if starting with '\fB+o/\fP' relative to outdir.
If none is given, \fB+o/dists\fP (i.e. \fIoutdir\fP\fB/dists\fP) is used.
.B Note:
apt has
......@@ -96,12 +103,20 @@ do an \fBexport\fP with the new one first to have a consistent state.
The directory where files generated by the \fBLog:\fP directive are
stored if they have no absolute path.
If none is given, \fIbasedir\fP\fB/logs\fP is used.
If this starts with '\fB+b/\fP', it is relative to basedir,
if starting with '\fB+o/\fP' relative to outdir,
with '\fB+c/\fP' relative to confdir.
If none is given, \fB+b/logs\fP (i.e. \fIbasedir\fP\fB/logs\fP) is used.
.TP
.B \-\-dbdir \fIdbdir\fP
Sets the directory where reprepro keeps its databases.
If none is given, \fIbasedir\fP\fB/db\fP is used.
If this starts with '\fB+b/\fP', it is relative to basedir,
if starting with '\fB+o/\fP' relative to outdir,
with '\fB+c/\fP' relative to confdir.
If none is given, \fB+b/db\fP (i.e. \fIbasedir\fP\fB/db\fP) is used.
.B Note:
This is permanent data, no cache. One has almost to regenerate the whole
......@@ -112,19 +127,23 @@ Sets the directory where downloads it downloads indices to when importing
from other repositories. This is temporary data and can be safely deleted
when not in an update run.
If none is given, \fIbasedir\fP\fB/lists\fP is used.
If this starts with '\fB+b/\fP', it is relative to basedir,
if starting with '\fB+o/\fP' relative to outdir,
with '\fB+c/\fP' relative to confdir.
If none is given, \fB+b/lists\fP (i.e. \fIbasedir\fP\fB/lists\fP) is used.
.TP
.B \-\-morguedir \fImorguedir\fP
Files deleted from the pool are stored into \fImorguedir\fP.
If this starts with '\fB+b/\fP', it is relative to basedir,
if starting with '\fB+o/\fP' relative to outdir,
with '\fB+c/\fP' relative to confdir.
If none is given, deleted files are just deleted.
.TP
.B \-\-overridedir \fIoverridedir\fP \fR(OBSOLETE)\fP
Sets the directory where specified override\-files will be searched in if
they do not start with a slash.
If none is given, \fIbasedir\fP\fB/override\fP is used.
.br
This will be removed in a future version.
Since reprepro 3.0.0, also the directory given to \-\-confdir is searched
for override files.
This option is obsolete. Do not use.
.TP
.B \-\-methoddir \fImethoddir\fP
Look in \fImethoddir\fP instead of
......
......@@ -3895,6 +3895,61 @@ static void myexit(int status) {
exit(status);
}
static void disallow_plus_prefix(const char *dir, const char *name, const char *allowed) {
if( dir[0] != '+' )
return;
if( dir[1] == '\0' || dir[2] != '/' ) {
fprintf(stderr, "Error: %s starts with +, but does not continue with '+b/'.\n",
name);
myexit(EXIT_FAILURE);
}
if( strchr(allowed, dir[1]) != NULL )
return;
fprintf(stderr, "Error: %s is not allowed to start with '+%c/'.\n"
"(if your directory is named like that, set it to './+%c/')\n",
name, dir[1], dir[1]);
myexit(EXIT_FAILURE);
}
static char *expand_plus_prefix(/*@only@*/char *dir, const char *name, const char *allowed, bool freedir) {
const char *fromdir;
char *newdir;
disallow_plus_prefix(dir, name, allowed);
if( dir[0] == '/' || (dir[0] == '.' && dir[1] == '/') )
return dir;
if( dir[0] != '+' ) {
fprintf(stderr,
"Warning: %s '%s' does not start with '/', './', or '+'.\n"
"This currently means it is relative to the current working directory,\n"
"but that might change in the future or cause an error instead!\n",
name, dir);
return dir;
}
if( dir[1] == 'b' ) {
fromdir = x_basedir;
} else if( dir[1] == 'o' ) {
fromdir = x_outdir;
} else if( dir[1] == 'c' ) {
fromdir = x_confdir;
} else {
abort();
return dir;
}
if( dir[3] == '\0' )
newdir = strdup(fromdir);
else
newdir = calc_dirconcat(fromdir, dir + 3);
if( FAILEDTOALLOC(newdir) ) {
(void)fputs("Out of Memory!\n",stderr);
exit(EXIT_FAILURE);
}
if( freedir )
free(dir);
return newdir;
}
int main(int argc,char *argv[]) {
static struct option longopts[] = {
{"delete", no_argument, &longoption,LO_DELETE},
......@@ -3973,6 +4028,7 @@ int main(int argc,char *argv[]) {
retvalue r;
int c;
struct sigaction sa;
char *tempconfdir;
sigemptyset(&sa.sa_mask);
#if defined(SA_ONESHOT)
......@@ -3994,8 +4050,18 @@ int main(int argc,char *argv[]) {
init_ignores();
config_state = CONFIG_OWNER_CMDLINE;
config_state = CONFIG_OWNER_DEFAULT;
CONFIGDUP(x_basedir, STD_BASE_DIR);
CONFIGDUP(x_confdir, "+b/conf");
CONFIGDUP(x_methoddir, STD_METHOD_DIR);
CONFIGDUP(x_outdir, "+b/");
CONFIGDUP(x_distdir, "+o/dists");
CONFIGDUP(x_dbdir, "+b/db");
CONFIGDUP(x_logdir, "+b/logs");
CONFIGDUP(x_listdir, "+b/lists");
CONFIGDUP(x_overridedir, "+b/override");
config_state = CONFIG_OWNER_CMDLINE;
if( interrupted() )
exit(EXIT_RET(RET_ERROR_INTERRUPTED));
......@@ -4012,25 +4078,32 @@ int main(int argc,char *argv[]) {
/* only for this CONFIG_OWNER_ENVIRONMENT is a bit stupid,
* but perhaps it gets more... */
config_state = CONFIG_OWNER_ENVIRONMENT;
if( x_basedir == NULL && getenv("REPREPRO_BASE_DIR") != NULL ) {
if( getenv("REPREPRO_BASE_DIR") != NULL ) {
CONFIGDUP(x_basedir, getenv("REPREPRO_BASE_DIR"));
}
if( x_confdir == NULL && getenv("REPREPRO_CONFIG_DIR") != NULL ) {
if( getenv("REPREPRO_CONFIG_DIR") != NULL ) {
CONFIGDUP(x_confdir,getenv("REPREPRO_CONFIG_DIR"));
}
if( x_basedir == NULL )
x_basedir = strdup(STD_BASE_DIR);
if( x_confdir == NULL && x_basedir != NULL )
x_confdir = calc_dirconcat(x_basedir, "conf");
if( FAILEDTOALLOC(x_basedir) || FAILEDTOALLOC(x_confdir) ) {
(void)fputs("Out of Memory!\n",stderr);
exit(EXIT_FAILURE);
}
disallow_plus_prefix(x_basedir, "basedir", "");
tempconfdir = expand_plus_prefix(x_confdir, "confdir", "b", false);
config_state = CONFIG_OWNER_FILE;
global.confdir = x_confdir;
optionsfile_parse(longopts, handle_option);
optionsfile_parse(tempconfdir, longopts, handle_option);
if( tempconfdir != x_confdir )
free(tempconfdir);
disallow_plus_prefix(x_basedir, "basedir", "");
disallow_plus_prefix(x_methoddir, "methoddir", "");
x_confdir = expand_plus_prefix(x_confdir, "confdir", "b", true);
x_outdir = expand_plus_prefix(x_outdir, "outdir", "bc", true);
x_logdir = expand_plus_prefix(x_logdir, "logdir", "boc", true);
x_dbdir = expand_plus_prefix(x_dbdir, "dbdir", "boc", true);
x_distdir = expand_plus_prefix(x_distdir, "distdir", "boc", true);
x_listdir = expand_plus_prefix(x_listdir, "listdir", "boc", true);
if( x_morguedir != NULL )
x_morguedir = expand_plus_prefix(x_morguedir, "morguedir",
"boc", true);
if( guessgpgtty && (getenv("GPG_TTY")==NULL) && isatty(0) ) {
static char terminalname[1024];
......@@ -4045,34 +4118,8 @@ int main(int argc,char *argv[]) {
}
}
/* basedir might have changed, so recalculate */
if( owner_x_confdir == CONFIG_OWNER_DEFAULT ) {
free(x_confdir);
x_confdir = calc_dirconcat(x_basedir, "conf");
}
if( delete < D_COPY )
delete = D_COPY;
if( x_methoddir == NULL )
x_methoddir = strdup(STD_METHOD_DIR);
if( x_outdir == NULL )
x_outdir = strdup(x_basedir);
if( x_distdir == NULL && x_outdir != NULL )
x_distdir = calc_dirconcat(x_outdir, "dists");
if( x_dbdir == NULL )
x_dbdir = calc_dirconcat(x_basedir, "db");
if( x_logdir == NULL )
x_logdir = calc_dirconcat(x_basedir, "logs");
if( x_listdir == NULL )
x_listdir = calc_dirconcat(x_basedir, "lists");
if( x_overridedir == NULL )
x_overridedir = calc_dirconcat(x_basedir, "override");
if( FAILEDTOALLOC(x_outdir) || FAILEDTOALLOC(x_distdir) ||
FAILEDTOALLOC(x_dbdir) || FAILEDTOALLOC(x_listdir) ||
FAILEDTOALLOC(x_logdir) || FAILEDTOALLOC(x_confdir) ||
FAILEDTOALLOC(x_overridedir) || FAILEDTOALLOC(x_methoddir) ) {
(void)fputs("Out of Memory!\n",stderr);
exit(EXIT_FAILURE);
}
if( interrupted() )
exit(EXIT_RET(RET_ERROR_INTERRUPTED));
global.basedir = x_basedir;
......@@ -4085,6 +4132,12 @@ int main(int argc,char *argv[]) {
global.listdir = x_listdir;
global.morguedir = x_morguedir;
if( gunzip != NULL && gunzip[0] == '+' )
gunzip = expand_plus_prefix(gunzip, "gunzip", "boc", true);
if( bunzip2 != NULL && bunzip2[0] == '+' )
bunzip2 = expand_plus_prefix(bunzip2, "bunzip2", "boc", true);
if( unlzma != NULL && unlzma[0] == '+' )
unlzma = expand_plus_prefix(unlzma, "unlzma", "boc", true);
uncompressions_check(gunzip, bunzip2, unlzma);
free(gunzip);
free(bunzip2);
......@@ -4104,6 +4157,8 @@ int main(int argc,char *argv[]) {
}
if( gnupghome != NULL ) {
gnupghome = expand_plus_prefix(gnupghome,
"gnupghome", "boc", true);
if( setenv("GNUPGHOME", gnupghome, 1) != 0 ) {
int e = errno;
......
......@@ -26,14 +26,14 @@
#include "names.h"
#include "optionsfile.h"
void optionsfile_parse(const struct option *longopts, void handle_option(int,const char *)) {
void optionsfile_parse(const char *directory, const struct option *longopts, void handle_option(int,const char *)) {
FILE *f;
char *filename;
char buffer[1000];
int linenr = 0;
const struct option *option;
filename = calc_conffile("options");
filename = calc_dirconcat(directory, "options");
if( FAILEDTOALLOC(filename) ) {
(void)fputs("Out of memory!\n", stderr);
exit(EXIT_FAILURE);
......
......@@ -8,6 +8,6 @@
#warning "What's hapening here?"
#endif
void optionsfile_parse(const struct option *longopts, void handle_option(int,const char *));
void optionsfile_parse(const char *directory, const struct option *longopts, void handle_option(int,const char *));
#endif /*REPREPRO_OPTIONSFILE_H*/
......@@ -7,7 +7,7 @@ fi
mkdir conf
cat > conf/options <<EOF
morguedir morgue
morguedir ./morgue
export never
EOF
cat > conf/distributions <<EOF
......@@ -52,7 +52,7 @@ stdout
-d1*=db: 'bla' removed from packages.db(test|main|source).
-v0*=Deleting files no longer referenced...
-v1*=deleting and forgetting pool/main/b/bla/bla_1.7.dsc
-v2*=Created directory "morgue"
-v2*=Created directory "./morgue"
-v2*=removed now empty directory ./pool/main/b/bla
-v2*=removed now empty directory ./pool/main/b
-v2*=removed now empty directory ./pool/main
......@@ -93,7 +93,7 @@ stdout
-v0*=Deleting files no longer referenced...
-v1*=deleting and forgetting pool/main/b/bla/bla_1.7.dsc
stderr
*=error 13 creating morgue-file morgue/bla_1.7.dsc: Permission denied
*=error 13 creating morgue-file ./morgue/bla_1.7.dsc: Permission denied
-v0*=There have been errors!
returns 243
EOF
......@@ -114,7 +114,7 @@ testrun - deleteunreferenced 3<<EOF
stdout
-v1*=deleting and forgetting pool/main/b/bla/bla_1.7.dsc
stderr
*=error 13 creating morgue-file morgue/bla_1.7.dsc: Permission denied
*=error 13 creating morgue-file ./morgue/bla_1.7.dsc: Permission denied
-v0*=There have been errors!
returns 243
EOF
......
......@@ -1926,38 +1926,38 @@ mv db/savedtracking.db db/tracking.db
mv db/savedreferences.db db/references.db
mkdir conf2
testrun - -b . --confdir conf2 update 3<<EOF
testrun - -b . --confdir ./conf2 update 3<<EOF
returns 254
stderr
*=Error opening config file 'conf2/distributions': No such file or directory(2)
*=Error opening config file './conf2/distributions': No such file or directory(2)
=(Have you forgotten to specify a basedir by -b?
=To only set the conf/ dir use --confdir)
-v0*=There have been errors!
EOF
touch conf2/distributions
testrun - -b . --confdir conf2 update 3<<EOF
testrun - -b . --confdir ./conf2 update 3<<EOF
returns 249
stderr
*=No distribution definitions found in conf2/distributions!
*=No distribution definitions found in ./conf2/distributions!
-v0*=There have been errors!
EOF
echo 'Codename: foo' > conf2/distributions
testrun - -b . --confdir conf2 update 3<<EOF
testrun - -b . --confdir ./conf2 update 3<<EOF
stderr
*=Error parsing config file conf2/distributions, line 2:
*=Error parsing config file ./conf2/distributions, line 2:
*=Required field 'Architectures' expected (since line 1).
-v0*=There have been errors!
returns 249
EOF
echo "Architectures: ${FAKEARCHITECTURE} fingers" >> conf2/distributions
testrun - -b . --confdir conf2 update 3<<EOF
*=Error parsing config file conf2/distributions, line 3:
testrun - -b . --confdir ./conf2 update 3<<EOF
*=Error parsing config file ./conf2/distributions, line 3:
*=Required field 'Components' expected (since line 1).
-v0*=There have been errors!
returns 249
EOF
echo 'Components: unneeded bloated i386' >> conf2/distributions
testrun - -b . --confdir conf2 update 3<<EOF
testrun - -b . --confdir ./conf2 update 3<<EOF
*=Error: packages database contains unused 'test1|stupid|${FAKEARCHITECTURE}' database.
*=This either means you removed a distribution, component or architecture from
*=the distributions config file without calling clearvanished, or your config
......@@ -1966,7 +1966,7 @@ testrun - -b . --confdir conf2 update 3<<EOF
-v0*=There have been errors!
returns 255
EOF
testrun - -b . --confdir conf2 --ignore=undefinedtarget update 3<<EOF
testrun - -b . --confdir ./conf2 --ignore=undefinedtarget update 3<<EOF
*=Error: packages database contains unused 'test1|stupid|${FAKEARCHITECTURE}' database.
*=This either means you removed a distribution, component or architecture from
*=the distributions config file without calling clearvanished, or your config
......@@ -1990,7 +1990,7 @@ testrun - -b . --confdir conf2 --ignore=undefinedtarget update 3<<EOF
-v0*=There have been errors!
returns 255
EOF
testrun - -b . --confdir conf2 --ignore=undefinedtarget --ignore=undefinedtracking update 3<<EOF
testrun - -b . --confdir ./conf2 --ignore=undefinedtarget --ignore=undefinedtracking update 3<<EOF
*=Error: packages database contains unused 'test1|stupid|${FAKEARCHITECTURE}' database.
*=This either means you removed a distribution, component or architecture from
*=the distributions config file without calling clearvanished, or your config
......@@ -2011,12 +2011,12 @@ testrun - -b . --confdir conf2 --ignore=undefinedtarget --ignore=undefinedtracki
*=Error: packages database contains unused 'test2|ugly|${FAKEARCHITECTURE}' database.
*=Error: packages database contains unused 'test2|ugly|coal' database.
*=Error: packages database contains unused 'test2|ugly|source' database.
*=Error opening config file 'conf2/updates': No such file or directory(2)
*=Error opening config file './conf2/updates': No such file or directory(2)
-v0*=There have been errors!
returns 254
EOF
touch conf2/updates
testrun - -b . --confdir conf2 --ignore=undefinedtarget --ignore=undefinedtracking --noskipold update 3<<EOF
testrun - -b . --confdir ./conf2 --ignore=undefinedtarget --ignore=undefinedtracking --noskipold update 3<<EOF
stderr
*=Error: packages database contains unused 'test1|stupid|${FAKEARCHITECTURE}' database.
*=This either means you removed a distribution, component or architecture from
......
......@@ -892,14 +892,14 @@ fi
rm -r -f db2
cp -a db db2
echo tracking is $tracking
testrun - --keepunreferenced --dbdir db2 -b . removesrc a unknown 3<<EOF
testrun - --keepunreferenced --dbdir ./db2 -b . removesrc a unknown 3<<EOF
stderr
-t1*=Nothing about source package 'unknown' found in the tracking data of 'a'!
-t1*=This either means nothing from this source in this version is there,
-t1*=or the tracking information might be out of date.
stdout
EOF
testrun - --keepunreferenced --dbdir db2 -b . removesrc a ab 3-1 3<<EOF
testrun - --keepunreferenced --dbdir ./db2 -b . removesrc a ab 3-1 3<<EOF
stdout
-v1*=removing 'ab-addons' from 'a|all|${FAKEARCHITECTURE}'...
-d1*=db: 'ab-addons' removed from packages.db(a|all|${FAKEARCHITECTURE}).
......@@ -931,7 +931,7 @@ EOF
fi
rm -r db2
cp -a db db2
testrun - --keepunreferenced --dbdir db2 -b . removesrc a ab 3<<EOF
testrun - --keepunreferenced --dbdir ./db2 -b . removesrc a ab 3<<EOF
stdout
-v1*=removing 'ab-addons' from 'a|all|${FAKEARCHITECTURE}'...
-d1*=db: 'ab-addons' removed from packages.db(a|all|${FAKEARCHITECTURE}).
......@@ -961,7 +961,7 @@ DATESTR remove a deb all ${FAKEARCHITECTURE} ab-addons 3-1
DATESTR remove a dsc all source ab 3-1
EOF
fi
testout "" --keepunreferenced --dbdir db2 dumppull
testout "" --keepunreferenced --dbdir ./db2 dumppull
cat > results.expected <<EOF
Updates needed for 'b|all|${FAKEARCHITECTURE}':
keep 'aa' '1-3' '1-3'
......@@ -969,7 +969,7 @@ keep 'aa-addons' '1-3' '1-3'
keep 'ab' '3-1' unavailable
EOF
dodiff results.expected results
testrun - --keepunreferenced --dbdir db2 -b . removefilter b "Version (== 1-3), Package (>> aa)" 3<<EOF
testrun - --keepunreferenced --dbdir ./db2 -b . removefilter b "Version (== 1-3), Package (>> aa)" 3<<EOF
stdout
-v1*=removing 'aa-addons' from 'b|all|${FAKEARCHITECTURE}'...
-d1*=db: 'aa-addons' removed from packages.db(b|all|${FAKEARCHITECTURE}).
......@@ -980,7 +980,7 @@ EOF
checklog logab <<EOF
DATESTR remove b deb all ${FAKEARCHITECTURE} aa-addons 1-3
EOF
testout "" --keepunreferenced --dbdir db2 dumppull
testout "" --keepunreferenced --dbdir ./db2 dumppull
cat > results.expected <<EOF
Updates needed for 'b|all|${FAKEARCHITECTURE}':
keep 'aa' '1-3' '1-3'
......
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