Bug#318877: udpkg: Avoid error message on first run
Package: udpkg
Version: 1.01
Tags: patch
If I am not mistaken, udpkg will issue a warning when it is running
for the first time, because the status file is missing. Here is a
patch to try to create the status file on the first run, and only
report an error if this failed.
I wrote this patch a long time ago, but never found time to test it.
Sending it here to make sure it isn't lost.
Index: status.c
===================================================================
--- status.c (revisjon 29314)
+++ status.c (arbeidskopi)
@@ -1,11 +1,16 @@
/* $Id$ */
#include "udpkg.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <search.h>
#include <debian-installer.h>
+#include <error.h>
+#include <errno.h>
/* Status file handling routines
*
@@ -210,7 +217,22 @@
FILE *f;
void *status = 0;
struct package_t *m = 0, *p = 0, *t = 0;
+ struct stat statbuf;
+ /* Try to create file if it is missing */
+ if (0 > stat(STATUSFILE, &statbuf) && ENOENT == errno)
+ {
+ f = fopen(STATUSFILE, "w");
+ if (NULL != f)
+ fclose(f);
+ else
+ {
+ error(0, errno, "Unable to create status file %s",
+ STATUSFILE);
+ return 0;
+ }
+ }
+
if ((f = fopen(STATUSFILE, "r")) == NULL)
{
perror(STATUSFILE);
Reply to: