Commit 4b3801af authored by Bernhard Link's avatar Bernhard Link

delete all .new files on export error, do not list Release.new in error...

delete all .new files on export error, do not list Release.new in error message command suggestion that was already deleted, add --keeptemporaries to not delete those files (include Release, that was already deleted in older versions)
parent 9c7266de
2009-02-21
* add --keeptemporaries and without it delete all .new files when
exporting fails (and not only Release) and with it keep all
(including Release). Also fix gpg error message to not suggest trying
it with a file that later will be deleted.
2009-02-20
* add 'warning' flag for FilterList files
......
reprepro (3.8.3-0) UNRELEASED; urgency=low
* fix hint to get gpg error message in case libgpgme returns generic error
to not list files deleted later, delete all .new files on error unless
new --keeptemporaries is specified (Closes: 516395)
-- Bernhard R. Link <brlink@debian.org> Sat, 21 Feb 2009 16:31:59 +0100
reprepro (3.8.2-1) unstable; urgency=low
* add conf/distribution ReadOnly: option (Closes: 515030)
......
......@@ -225,6 +225,11 @@ have been removed from them.
do not want to be pestered with warnings about errors to remove them,
or have a buggy rmdir call deleting non-empty directories.)
.TP
.B \-\-keeptemporaries
If an export of an distribution fails,
this option causes reprepro to not delete the temporary \fB.new\fP files
in the \fBdists/\fP directory, so one can look at the partial result.
.TP
.B \-\-ask\-passphrase
Ask for passphrases when signing things and one is needed. This is a quick
and dirty implementation using the obsolete \fBgetpass(3)\fP function
......
......@@ -106,9 +106,9 @@ _reprepro()
brokensignatures uploaders missingfile'
noargoptions='--delete --nodelete --help -h --verbose -v\
--nothingiserror --nolistsdownload --keepunreferencedfiles --keepunusednewfiles\
--keepdirectories\
--keepdirectories --keeptemporaries\
--ask-passphrase --nonothingiserror --listsdownload\
--nokeepunreferencesfiles --nokeepdirectories\
--nokeepunreferencesfiles --nokeepdirectories --nokeeptemporaries\
--noask-passphrase --skipold --noskipold --nooldfilesdb --oldfilesdb'
options='-b -i --basedir --outdir --ignore --unignore --methoddir --distdir --dbdir\
--listdir --overridedir --confdir --section -S --priority -P --component -C\
......
......@@ -307,6 +307,7 @@ _arguments \
'(--nokeepunreferencedfiles)--keepunreferencedfiles[Do not delete files that are no longer used]' \
'(--nokeepunusednewfiles)--keepunusednewfiles[Do not delete newly added files that later were found to not be used]' \
'(--nokeepdirectories)--keepdirectories[Do not remove directories when they get emtpy]' \
'(--nokeeptemporaries)--keeptemporaries[When exporting fail do not remove temporary files]' \
'(--noask-passphrase)--ask-passphrase[Ask for passphrases (insecure)]' \
'(--nonoskipold --skipold)--noskipold[Do not ignore parts where no new index file is available]' \
'(--guessgpgtty --nonoguessgpgtty)--noguessgpgtty[Do not set GPG_TTY variable even when unset and stdin is a tty]' \
......
......@@ -78,6 +78,7 @@ extern struct global_config {
const char *overridedir;
/* flags: */
bool keepdirectories;
bool keeptemporaries;
} global;
enum compression { c_none, c_gzip, c_bzip2, c_lzma, c_COUNT };
......
......@@ -128,7 +128,7 @@ static off_t reservedotherspace = 1024*1024;
* to change something owned by lower owners. */
enum config_option_owner config_state,
#define O(x) owner_ ## x = CONFIG_OWNER_DEFAULT
O(fast), O(x_outdir), O(x_basedir), O(x_distdir), O(dbdir), O(x_listdir), O(x_confdir), O(x_logdir), O(x_overridedir), O(x_methoddir), O(x_section), O(x_priority), O(x_component), O(x_architecture), O(x_packagetype), O(nothingiserror), O(nolistsdownload), O(keepunusednew), O(keepunreferenced), O(keepdirectories), O(askforpassphrase), O(skipold), O(export), O(waitforlock), O(spacecheckmode), O(reserveddbspace), O(reservedotherspace), O(guessgpgtty), O(verbosedatabase), O(oldfilesdb), O(gunzip), O(bunzip2), O(unlzma), O(gnupghome);
O(fast), O(x_outdir), O(x_basedir), O(x_distdir), O(dbdir), O(x_listdir), O(x_confdir), O(x_logdir), O(x_overridedir), O(x_methoddir), O(x_section), O(x_priority), O(x_component), O(x_architecture), O(x_packagetype), O(nothingiserror), O(nolistsdownload), O(keepunusednew), O(keepunreferenced), O(keeptemporaries), O(keepdirectories), O(askforpassphrase), O(skipold), O(export), O(waitforlock), O(spacecheckmode), O(reserveddbspace), O(reservedotherspace), O(guessgpgtty), O(verbosedatabase), O(oldfilesdb), O(gunzip), O(bunzip2), O(unlzma), O(gnupghome);
#undef O
#define CONFIGSET(variable,value) if(owner_ ## variable <= config_state) { \
......@@ -3158,6 +3158,7 @@ LO_NOTHINGISERROR,
LO_NOLISTDOWNLOAD,
LO_ASKPASSPHRASE,
LO_KEEPDIRECTORIES,
LO_KEEPTEMPORARIES,
LO_FAST,
LO_SKIPOLD,
LO_GUESSGPGTTY,
......@@ -3169,6 +3170,7 @@ LO_NONOTHINGISERROR,
LO_LISTDOWNLOAD,
LO_NOASKPASSPHRASE,
LO_NOKEEPDIRECTORIES,
LO_NOKEEPTEMPORARIES,
LO_NOFAST,
LO_NOSKIPOLD,
LO_NOGUESSGPGTTY,
......@@ -3332,6 +3334,12 @@ static void handle_option(int c, const char *argument) {
"Warning: --nokeepuneededlists no longer exists.\n"
"Use cleanlists to clean manually.\n");
break;
case LO_KEEPTEMPORARIES:
CONFIGGSET(keeptemporaries, true);
break;
case LO_NOKEEPTEMPORARIES:
CONFIGGSET(keeptemporaries, false);
break;
case LO_KEEPDIRECTORIES:
CONFIGGSET(keepdirectories, true);
break;
......@@ -3609,6 +3617,7 @@ int main(int argc,char *argv[]) {
{"keepunusednewfiles", no_argument, &longoption, LO_KEEPUNUSEDNEW},
{"keepunneededlists", no_argument, &longoption, LO_KEEPUNNEEDEDLISTS},
{"keepdirectories", no_argument, &longoption, LO_KEEPDIRECTORIES},
{"keeptemporaries", no_argument, &longoption, LO_KEEPTEMPORARIES},
{"ask-passphrase", no_argument, &longoption, LO_ASKPASSPHRASE},
{"nonothingiserror", no_argument, &longoption, LO_NONOTHINGISERROR},
{"nonolistsdownload", no_argument, &longoption, LO_LISTDOWNLOAD},
......@@ -3617,6 +3626,7 @@ int main(int argc,char *argv[]) {
{"nokeepunusednewfiles", no_argument, &longoption, LO_NOKEEPUNUSEDNEW},
{"nokeepunneededlists", no_argument, &longoption, LO_NOKEEPUNNEEDEDLISTS},
{"nokeepdirectories", no_argument, &longoption, LO_NOKEEPDIRECTORIES},
{"nokeeptemporaries", no_argument, &longoption, LO_NOKEEPTEMPORARIES},
{"noask-passphrase", no_argument, &longoption, LO_NOASKPASSPHRASE},
{"guessgpgtty", no_argument, &longoption, LO_GUESSGPGTTY},
{"noguessgpgtty", no_argument, &longoption, LO_NOGUESSGPGTTY},
......
......@@ -86,11 +86,13 @@ void release_free(struct release *release) {
free(e->relativefilename);
checksums_free(e->checksums);
free(e->fullfinalfilename);
if( !global.keeptemporaries && e->fulltemporaryfilename != NULL)
unlink(e->fulltemporaryfilename);
free(e->fulltemporaryfilename);
free(e);
}
if( release->signedfile != NULL )
signedfile_free(release->signedfile);
signedfile_free(release->signedfile, !global.keeptemporaries);
if( release->cachedb != NULL ) {
table_close(release->cachedb);
}
......@@ -1281,9 +1283,10 @@ retvalue release_prepare(struct release *release, struct distribution *distribut
writechar('\n');
}
}
r = signedfile_prepare(release->signedfile, distribution->signwith);
r = signedfile_prepare(release->signedfile, distribution->signwith,
!global.keeptemporaries);
if( RET_WAS_ERROR(r) ) {
signedfile_free(release->signedfile);
signedfile_free(release->signedfile, !global.keeptemporaries);
release->signedfile = NULL;
return r;
}
......@@ -1311,6 +1314,8 @@ retvalue release_finish(/*@only@*/struct release *release, struct distribution *
e, file->fulltemporaryfilename,
strerror(e));
}
free(file->fulltemporaryfilename);
file->fulltemporaryfilename = NULL;
} else if( file->fulltemporaryfilename != NULL ) {
e = rename(file->fulltemporaryfilename,
file->fullfinalfilename);
......@@ -1328,8 +1333,11 @@ retvalue release_finish(/*@only@*/struct release *release, struct distribution *
return r;
}
RET_UPDATE(result,r);
} else
} else {
somethingwasdone = true;
free(file->fulltemporaryfilename);
file->fulltemporaryfilename = NULL;
}
}
}
r = signedfile_finalize(release->signedfile, &somethingwasdone);
......
......@@ -329,7 +329,7 @@ retvalue signature_check(const struct strlist *requirements, const char *release
#endif /* HAVE_LIBGPGME */
}
static retvalue signature_sign(const char *options, const char *filename, const char *signaturename) {
static retvalue signature_sign(const char *options, const char *filename, const char *signaturename, bool willcleanup) {
retvalue r;
int ret, e;
#ifdef HAVE_LIBGPGME
......@@ -425,27 +425,45 @@ static retvalue signature_sign(const char *options, const char *filename, const
signresult = gpgme_op_sign_result(context);
if( signresult == NULL ) {
fprintf(stderr,
if( willcleanup)
fprintf(stderr,
"Error: gpgme returned NULL unexpectedly for gpgme_op_sign_result\n"
"This most likely means gpg is confused or produces some error libgpgme is\n"
"not able to understand. Try running gpg %s%s --output 'some-other-file' --detach-sign 'some-file'\n"
"for hints what this error might have been.\n",
(options==NULL)?"":"-u ",
(options==NULL)?"":options);
else
fprintf(stderr,
"Error: gpgme returned NULL unexpectedly for gpgme_op_sign_result\n"
"This most likely means gpg is confused or produces some error libgpgme is\n"
"not able to understand. Try running gpg %s%s --output '%s' --detach-sign '%s'\n"
"for hints what this error might have been.\n",
(options==NULL)?"":"-u ",
(options==NULL)?"":options,
signaturename, filename);
(options==NULL)?"":"-u ",
(options==NULL)?"":options,
signaturename, filename);
gpgme_data_release(dh_gpg);
return RET_ERROR_GPGME;
}
if( signresult->signatures == NULL ) {
fprintf(stderr,
if( willcleanup)
fprintf(stderr,
"Error: gpgme created no signature!\n"
"This most likely means gpg is confused or produces some error libgpgme is\n"
"not able to understand. Try running gpg %s%s --output 'some-other-file' --detach-sign 'some-file'\n"
"for hints what this error might have been.\n",
(options==NULL)?"":"-u ",
(options==NULL)?"":options);
else
fprintf(stderr,
"Error: gpgme created no signature for '%s'!\n"
"This most likely means gpg is confused or produces some error libgpgme is\n"
"not able to understand. Try running gpg %s%s --output '%s' --detach-sign '%s'\n"
"for hints what this error might have been.\n",
filename,
(options==NULL)?"":"-u ",
(options==NULL)?"":options,
signaturename, filename);
filename,
(options==NULL)?"":"-u ",
(options==NULL)?"":options,
signaturename, filename);
gpgme_data_release(dh_gpg);
return RET_ERROR_GPGME;
}
......@@ -948,17 +966,19 @@ static retvalue newpossiblysignedfile(const char *directory, const char *basefil
return RET_OK;
}
void signedfile_free(struct signedfile *f) {
void signedfile_free(struct signedfile *f, bool cleanup) {
if( f == NULL )
return;
assert( f->fd < 0 );
if( f->newplainfilename != NULL ) {
(void)unlink(f->newplainfilename);
if( cleanup )
(void)unlink(f->newplainfilename);
free(f->newplainfilename);
}
free(f->plainfilename);
if( f->newsignfilename != NULL ) {
(void)unlink(f->newsignfilename);
if( cleanup )
(void)unlink(f->newsignfilename);
free(f->newsignfilename);
}
free(f->signfilename);
......@@ -1013,7 +1033,8 @@ void signedfile_write(struct signedfile *f, const void *data, size_t len) {
}
// push into signing object...
}
retvalue signedfile_prepare(struct signedfile *f, const char *options) {
retvalue signedfile_prepare(struct signedfile *f, const char *options, bool willcleanup) {
if( f->fd >= 0 ) {
int ret;
......@@ -1048,7 +1069,7 @@ retvalue signedfile_prepare(struct signedfile *f, const char *options) {
r = signature_sign(options,
f->newplainfilename,
f->newsignfilename);
f->newsignfilename, willcleanup);
if( RET_WAS_ERROR(r) )
return r;
}
......
......@@ -21,11 +21,11 @@ retvalue signature_startsignedfile(const char *directory, const char *basename,
retvalue signature_startunsignedfile(const char *directory, const char *basename, /*@out@*/struct signedfile **);
void signedfile_write(struct signedfile *, const void *, size_t);
/* generate signature in temporary file */
retvalue signedfile_prepare(struct signedfile *, const char *options);
retvalue signedfile_prepare(struct signedfile *, const char *options, bool willcleanup);
/* move temporary files to final places */
retvalue signedfile_finalize(struct signedfile *, bool *toolate);
/* may only be called after signedfile_prepare */
void signedfile_free(/*@only@*/struct signedfile *);
void signedfile_free(/*@only@*/struct signedfile *, bool cleanup);
void signatures_done(void);
......
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