mirror of https://github.com/dirtbags/moth.git
Possibly working directory auto-detection
This commit is contained in:
parent
44e41c48e5
commit
91e946bc05
|
@ -363,17 +363,25 @@ my_snprintf(char *buf, size_t buflen, char *fmt, ...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ctf_chdir()
|
ctf_chdir()
|
||||||
{
|
{
|
||||||
char const *ctf_base = getenv("CTF_BASE");
|
static int initialized = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (initialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
initialized = 1;
|
||||||
|
|
||||||
|
/* chdir to $CTF_BASE */
|
||||||
|
{
|
||||||
|
char const *ctf_base = getenv("CTF_BASE");
|
||||||
|
|
||||||
if (ctf_base) {
|
if (ctf_base) {
|
||||||
/* chdir to CTF_BASE */
|
|
||||||
chdir(ctf_base);
|
chdir(ctf_base);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Keep going up one directory until there's a packages directory */
|
/* Keep going up one directory until there's a packages directory */
|
||||||
for (i = 0; i < 5; i += 1) {
|
for (i = 0; i < 5; i += 1) {
|
||||||
|
@ -395,17 +403,13 @@ mkpath(char const *type, char const *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
char relpath[PATH_MAX];
|
char relpath[PATH_MAX];
|
||||||
static char path[PATH_MAX];
|
static char path[PATH_MAX];
|
||||||
char const *var = getenv("CTF_BASE");
|
|
||||||
|
|
||||||
|
ctf_chdir();
|
||||||
vsnprintf(relpath, sizeof(relpath) - 1, fmt, ap);
|
vsnprintf(relpath, sizeof(relpath) - 1, fmt, ap);
|
||||||
relpath[sizeof(relpath) - 1] = '\0';
|
relpath[sizeof(relpath) - 1] = '\0';
|
||||||
|
|
||||||
if (! var) {
|
|
||||||
var = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
/* $CTF_BASE/type/relpath */
|
/* $CTF_BASE/type/relpath */
|
||||||
my_snprintf(path, sizeof(path), "%s/%s/%s", var, type, relpath);
|
my_snprintf(path, sizeof(path), "%s/%s", type, relpath);
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
TANKS_PKGDIR = $(TARGET)/tanks
|
TANKS_PKGDIR = $(TARGET)/tanks
|
||||||
TANKS_CACHE = $(CACHE)/tanks.git
|
TANKS_CACHE = $(CACHE)/tanks.git
|
||||||
TANKS_BUILDDIR = $(BUILD)/tanks
|
TANKS_BUILDDIR = $(BUILD)/tanks
|
||||||
TANKS_URL = "http://dirtbags.net/projects/tanks"
|
TANKS_URL = "http://woozle.org/~neale/g.cgi/tanks"
|
||||||
|
|
||||||
$(TANKS_CACHE):
|
$(TANKS_CACHE):
|
||||||
git clone --bare $(TANKS_URL) $@
|
git clone --bare $(TANKS_URL) $@
|
||||||
|
|
Loading…
Reference in New Issue