From fbf80e90c2b9595edf7857e5f19f2b64b4931508 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Mon, 13 Jan 2003 07:14:58 +0000 Subject: don't substitute PRODUCTNAME at build time and instead read it from /.buildstamp at runtime --- loader2/Makefile | 2 +- loader2/cdinstall.c | 12 ++++++------ loader2/hdinstall.c | 2 +- loader2/lang.c | 2 +- loader2/loader.c | 27 ++++++++++++++++++++++++--- loader2/loader.h | 1 + loader2/nfsinstall.c | 6 +++--- loader2/urlinstall.c | 3 ++- loader2/urls.c | 4 ++-- 9 files changed, 41 insertions(+), 18 deletions(-) diff --git a/loader2/Makefile b/loader2/Makefile index 3cbebd46c..2a66ec581 100644 --- a/loader2/Makefile +++ b/loader2/Makefile @@ -31,7 +31,7 @@ HWLIBS = -lkudzu_loader -lpci DEBUG = -ggdb COPTS = $(DEBUG) -Os -Wall -DVERSION='"$(VERSION)"' -CFLAGS = $(COPTS) -ffunction-sections -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DHAVE_LIBIO_H -DPRODUCTNAME='$(PRODUCTNAME)' +CFLAGS = $(COPTS) -ffunction-sections -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DHAVE_LIBIO_H STATIC = -static ifeq (1, $(USEDIET)) diff --git a/loader2/cdinstall.c b/loader2/cdinstall.c index 0fa8c5901..189290195 100644 --- a/loader2/cdinstall.c +++ b/loader2/cdinstall.c @@ -135,8 +135,8 @@ static char * mediaCheckCdrom(char *cddriver) { static void wrongCDMessage(void) { char *buf = sdupprintf(_("The %s CD was not found " "in any of your CDROM drives. Please insert " - "the %s CD and press %s to retry."), PRODUCTNAME, - PRODUCTNAME, _("OK")); + "the %s CD and press %s to retry."), getProductName(), + getProductName(), _("OK")); newtWinMessage(_("Error"), _("OK"), buf, _("OK")); free(buf); } @@ -342,13 +342,13 @@ char * setupCdrom(char * location, if (foundinvalid) buf = sdupprintf(_("No %s CD was found which matches your " "boot media. Please insert the %s CD " - "and press %s to retry."), PRODUCTNAME, - PRODUCTNAME, _("OK")); + "and press %s to retry."), getProductName(), + getProductName(), _("OK")); else buf = sdupprintf(_("The %s CD was not found in any of your " "CDROM drives. Please insert the %s CD " - "and press %s to retry."), PRODUCTNAME, - PRODUCTNAME, _("OK")); + "and press %s to retry."), getProductName(), + getProductName(), _("OK")); rc = newtWinChoice(_("CD Not Found"), _("OK"), _("Back"), buf, _("OK")); diff --git a/loader2/hdinstall.c b/loader2/hdinstall.c index 026baf19d..f68414dd6 100644 --- a/loader2/hdinstall.c +++ b/loader2/hdinstall.c @@ -386,7 +386,7 @@ char * mountHardDrive(struct installMethod * method, "partition hold the CD (iso9660) images " "for %s? If you don't see the disk drive " "you're using listed here, press F2 " - "to configure additional devices."), PRODUCTNAME); + "to configure additional devices."), getProductName()); text = newtTextboxReflowed(-1, -1, buf, 62, 5, 5, 0); free(buf); diff --git a/loader2/lang.c b/loader2/lang.c index 18ce36c46..62425fc26 100644 --- a/loader2/lang.c +++ b/loader2/lang.c @@ -246,7 +246,7 @@ static int setupLanguage(int choice, int flags) { buf[i] = ' '; newtDrawRootText(0, 0, buf); - buf = sdupprintf(_(topLineWelcome), PRODUCTNAME); + buf = sdupprintf(_(topLineWelcome), getProductName()); newtDrawRootText(0, 0, buf); free(buf); newtPopHelpLine(); diff --git a/loader2/loader.c b/loader2/loader.c index 9d4eca5b7..c4a716782 100644 --- a/loader2/loader.c +++ b/loader2/loader.c @@ -163,7 +163,7 @@ void doSuspend(void) { void startNewt(int flags) { if (!newtRunning) { - char *buf = sdupprintf(_("Welcome to %s"), PRODUCTNAME); + char *buf = sdupprintf(_("Welcome to %s"), getProductName()); newtInit(); newtCls(); newtDrawRootText(0, 0, buf); @@ -182,6 +182,27 @@ void stopNewt(void) { newtRunning = 0; } +char * getProductName(void) { + static char * productName = NULL; + FILE *f; + + if (!productName) { + f = fopen("/.buildstamp", "r"); + if (!f) { + productName = strdup("anaconda"); + } else { + productName = malloc(256); + fgets(productName, 256, f); /* stamp time */ + fgets(productName, 256, f); /* product name */ + return productName; + } + } else { + return productName; + } + + return NULL; +} + void initializeConsole(moduleList modLoaded, moduleDeps modDeps, moduleInfoSet modInfo, int flags) { if (!FL_NOFB(flags)) @@ -546,7 +567,7 @@ static void checkForRam(int flags) { if (totalMemory() < MIN_RAM) { char *buf; buf = sdupprintf(_("You do not have enough RAM to install %s " - "on this machine."), PRODUCTNAME); + "on this machine."), getProductName()); startNewt(flags); newtWinMessage(_("Error"), _("OK"), buf); free(buf); @@ -1146,7 +1167,7 @@ int main(int argc, char ** argv) { closeLog(); if (!FL_TESTING(flags)) { - char *buf = sdupprintf(_("Running anaconda, the %s system installer - please wait...\n"), PRODUCTNAME); + char *buf = sdupprintf(_("Running anaconda, the %s system installer - please wait...\n"), getProductName()); printf("%s", buf); execv(anacondaArgs[0], anacondaArgs); perror("exec"); diff --git a/loader2/loader.h b/loader2/loader.h index 43e98ebe4..f58fcc4e5 100644 --- a/loader2/loader.h +++ b/loader2/loader.h @@ -72,6 +72,7 @@ void startNewt(int flags); void stopNewt(); +char * getProductName(void); /* JKFIXME: I don't like all of the _set attribs, but without them, diff --git a/loader2/nfsinstall.c b/loader2/nfsinstall.c index 5caffdd40..e760936b8 100644 --- a/loader2/nfsinstall.c +++ b/loader2/nfsinstall.c @@ -48,7 +48,7 @@ int nfsGetSetup(char ** hostptr, char ** dirptr) { entries[1].flags = NEWT_FLAG_SCROLL; entries[2].text = NULL; entries[2].value = NULL; - buf = sdupprintf(_(netServerPrompt), "NFS", PRODUCTNAME); + buf = sdupprintf(_(netServerPrompt), "NFS", getProductName()); rc = newtWinEntries(_("NFS Setup"), buf, 60, 5, 15, 24, entries, _("OK"), _("Back"), NULL); free(buf); @@ -208,11 +208,11 @@ char * mountNfsImage(struct installMethod * method, if (foundinvalid) buf = sdupprintf(_("The %s installation tree in that " "directory does not seem to match " - "your boot media."), PRODUCTNAME); + "your boot media."), getProductName()); else buf = sdupprintf(_("That directory does not seem to " "contain a %s installation tree."), - PRODUCTNAME); + getProductName()); newtWinMessage(_("Error"), _("OK"), buf); break; } else { diff --git a/loader2/urlinstall.c b/loader2/urlinstall.c index 453b3e80c..72f45f13c 100644 --- a/loader2/urlinstall.c +++ b/loader2/urlinstall.c @@ -104,7 +104,8 @@ static int loadUrlImages(struct iurlinfo * ui, int flags) { char * buf; buf = sdupprintf(_("The %s installation tree in that directory does " - "not seem to match your boot media."), PRODUCTNAME); + "not seem to match your boot media."), + getProductName()); newtWinMessage(_("Error"), _("OK"), buf); diff --git a/loader2/urls.c b/loader2/urls.c index c5d1de2fe..b3d5ad678 100644 --- a/loader2/urls.c +++ b/loader2/urls.c @@ -249,12 +249,12 @@ int urlMainSetupPanel(struct iurlinfo * ui, urlprotocol protocol, switch (protocol) { case URL_METHOD_FTP: - buf = sdupprintf(_(netServerPrompt), "FTP", PRODUCTNAME); + buf = sdupprintf(_(netServerPrompt), "FTP", getProductName()); reflowedText = newtReflowText(buf, 47, 5, 5, &width, &height); free(buf); break; case URL_METHOD_HTTP: - buf = sdupprintf(_(netServerPrompt), "Web", PRODUCTNAME); + buf = sdupprintf(_(netServerPrompt), "Web", getProductName()); reflowedText = newtReflowText(buf, 47, 5, 5, &width, &height); free(buf); break; -- cgit