Avoid trying to set "<<none>>" file context.
[platform/upstream/rpm.git] / lib / trb.c
1 #include "system.h"
2 #include "rpmcli.h"
3 #include "misc.h"
4
5 #include "debug.h"
6
7 #define UP2DATEGLOB     "/var/spool/up2date/*.rpm"
8
9 static struct poptOption optionsTable[] = {
10  { "verbose", 'v', 0, 0, 'v',
11         N_("provide more detailed output"), NULL},
12  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmInstallPoptTable, 0,
13         N_("Install/Upgrade/Erase options:"),
14         NULL },
15    POPT_AUTOHELP
16    POPT_TABLEEND
17 };
18
19 int
20 main(int argc, const char *argv[])
21 {
22     poptContext optCon;
23     struct rpmInstallArguments_s * ia = &rpmIArgs;
24     int arg;
25     int ec = 0;
26
27 #if HAVE_MCHECK_H && HAVE_MTRACE
28     mtrace();   /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
29 #endif
30     setprogname(argv[0]);       /* Retrofit glibc __progname */
31
32     /* set up the correct locale */
33     (void) setlocale(LC_ALL, "" );
34
35     bindtextdomain(PACKAGE, LOCALEDIR);
36     textdomain(PACKAGE);
37
38     rpmSetVerbosity(RPMMESS_NORMAL);
39
40     optCon = poptGetContext(argv[0], argc, argv, optionsTable, 0);
41     (void) poptReadConfigFile(optCon, LIBRPMALIAS_FILENAME);
42     (void) poptReadDefaultConfig(optCon, 1);
43     poptSetExecPath(optCon, RPMCONFIGDIR, 1);
44
45     while ((arg = poptGetNextOpt(optCon)) > 0) {
46         switch(arg) {
47         case 'v':
48             rpmIncreaseVerbosity();
49             break;
50         default:
51             break;
52         }
53     }
54
55     if (ia->rbtid == 0) {
56         fprintf(stderr, "--rollback <timestamp> is required\n");
57         exit(1);
58     }
59
60     if (rpmReadConfigFiles(NULL, NULL))
61         exit(1);
62
63     ec = rpmRollback(ia, NULL);
64
65     optCon = poptFreeContext(optCon);
66     rpmFreeMacros(NULL);
67
68 #if HAVE_MCHECK_H && HAVE_MTRACE
69     muntrace();   /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
70 #endif
71
72     return ec;
73 }