-
Notifications
You must be signed in to change notification settings - Fork 0
/
hooks.c
62 lines (55 loc) · 2.12 KB
/
hooks.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* This file is part of "reprepro"
* Copyright (C) 2007,2012 Bernhard R. Link
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1301 USA
*/
/* general helpers infrastructure for all hooks: */
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "error.h"
#include "hooks.h"
void sethookenvironment(const char *causing_file, const char *causing_rule, const char *suite_from, const char *exitcode) {
if (exitcode != NULL)
setenv("REPREPRO_EXIT_CODE", exitcode, true);
else
unsetenv("REPREPRO_EXIT_CODE");
if (causing_file != NULL)
setenv("REPREPRO_CAUSING_FILE", causing_file, true);
else
unsetenv("REPREPRO_CAUSING_FILE");
if (causing_rule != NULL)
setenv("REPREPRO_CAUSING_RULE", causing_rule, true);
else
unsetenv("REPREPRO_CAUSING_RULE");
if (suite_from != NULL)
setenv("REPREPRO_FROM", suite_from, true);
else
unsetenv("REPREPRO_FROM");
if (atom_defined(causingcommand))
setenv("REPREPRO_CAUSING_COMMAND",
atoms_commands[causingcommand],
true);
else
unsetenv("REPREPRO_CAUSING_COMMAND");
setenv("REPREPRO_BASE_DIR", global.basedir, true);
setenv("REPREPRO_OUT_DIR", global.outdir, true);
setenv("REPREPRO_CONF_DIR", global.confdir, true);
setenv("REPREPRO_CONFIG_DIR", global.confdir, true);
setenv("REPREPRO_DIST_DIR", global.distdir, true);
setenv("REPREPRO_LOG_DIR", global.logdir, true);
}
/* global variables to denote current state */
const char *causingfile = NULL; /* only valid while being called */
command_t causingcommand = atom_unknown; /* valid till end of program */