6 #define _RPMRUBY_INTERNAL
66 def ack(cmd, expected)\n\
70 print(\"NACK: ack(\"+cmd.to_s+\")\tcaught '\"+\"#{$!}\"+\"'\n\")\n\
73 if (actual != expected && expected != nil)\n\
74 print(\"NACK: ack(\"+cmd.to_s+\")\tgot '\"+actual.to_s+\"' not '\"+expected.to_s+\"'\n\")\n\
76 print(\" ack(\"+cmd.to_s+\")\tgot '\"+actual.to_s+\"'\n\")\n\
84 const char * result = NULL;
90 str =
rpmExpand(pre,
"load(\"", fn,
"\");", NULL);
92 fprintf(stderr,
"\trunning:%s%s\n", (*pre ?
"\n" :
" "), str);
95 if (result != NULL && *result !=
'\0')
96 fprintf(stdout,
"%s\n", result);
104 const char * pre = NULL;
113 i = norder *
sizeof(*order);
114 order = memset(
alloca(i), 0, i);
119 sprintf(dstr,
"%d",
_debug);
122 "$loglvl = ", lstr,
";\n",
128 (void)
rpmrubyRun(NULL,
"puts \"loading RPM classes.\";", &result);
130 for (i = 0, tbl = classTable; i <
nclassTable; i++, tbl++) {
133 order[tbl->
ix & (norder - 1)] = i + 1;
134 if (tbl->
init != NULL)
135 (void) (*tbl->
init) ();
139 for (i = 0; i < norder; i++) {
146 tbl = &classTable[ix];
148 if (
Stat(fn, &sb) == 0) {
160 {
"debug",
'd', POPT_ARG_VAL, &
_debug, -1, NULL, NULL },
161 {
"test",
't', POPT_ARG_VAL, &
_test, -1, NULL, NULL },
164 N_(
"Common options for all rpm executables:"), NULL },
173 poptContext optCon =
rpmcliInit(argc, argv, optionsTable);
174 ARGV_t av = poptGetArgs(optCon);
179 if (!
_test && ac < 1) {
180 poptPrintUsage(optCon, stderr, 0);
192 while ((fn = *av++) != NULL) {
struct rpmrbClassTable_s * rpmrbClassTable
rpmruby _rpmrubyI
Current (global) interpreter instance.
char * rpmGetPath(const char *path,...)
Return (malloc'ed) expanded, canonicalized, file path.
struct poptOption rpmcliAllPoptTable[]
Popt option table for options shared by all modes and executables.
int Stat(const char *path, struct stat *st)
stat(2) clone.
static size_t nclassTable
poptContext rpmcliInit(int argc, char *const argv[], struct poptOption *optionsTable)
Initialize most everything needed by an rpm CLI executable context.
static const char tscripts[]
int main(int argc, char *argv[])
int _rpmruby_debug
Triggers printing of debugging information.
int argvCount(const ARGV_t argv)
Return no.
void Init_rpm(void)
Defines the "RPM" Ruby module and makes it known to the Interpreter.
Ruby bindings to the RPM Transaction Set API.
static void rpmrbLoadClasses(void)
static struct poptOption optionsTable[]
static rpmRC rpmrbLoadFile(rpmruby rb, const char *pre, const char *fn)
char * rpmExpand(const char *arg,...)
Return (malloc'ed) concatenated macro expansion(s).
Embedded Ruby interpreter.
struct rpmruby_s * rpmruby
RPM Ruby bindings "RPM" module.
enum rpmRC_e rpmRC
RPM return codes.
static struct rpmrbClassTable_s classTable[]
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
rpmRC rpmrubyRun(rpmruby ruby, const char *str, const char **resultp)
Evaluates Ruby code stored in a string.
Ruby bindings to RPM's macro context facility.
poptContext rpmcliFini(poptContext optCon)
Destroy most everything needed by an rpm CLI executable context.
static const char * _acknack