36 fprintf(stdout,
"Checking extension ...");
42 package, strerror(
errno));
51 fscanf(f,
"%[<GRASS extension package>] ", tmp);
52 if (strcmp(
"<GRASS extension package>", tmp)) {
62 f = fopen(
"version",
"r");
70 error = sscanf(tmp,
"%i.%i.%i", major, minor, revision);
74 "invalid or missing version information.\n");
95 fprintf(stdout,
"Uncompressing files...");
98 strcpy(
TMPDIR,
"/tmp/grass.extension.XXXXXX");
100 fd = open(
TMPDIR, O_CREAT, 0777);
103 "could not create temp directory name: %s",
109 fprintf(stdout,
"\nUncompressing to: %s.\n",
TMPDIR);
125 "could not copy extension files to temp dir.\n");
133 (
"file name not '.tar.gz', '.tgz', '.tar.bz2', '.tbz' or '.zip'. Assuming '.tgz'.\n");
181 "could not extract files using 'tar' and 'gzip'. \n \
182 Extract manually using 'tar -xzvf %s'.\n", package);
186 Extract manually using 'tar -xjvf %s'.\n",
191 Extract manually using 'unzip %s'.\n",
202 int revision,
char *short_name,
char *invocation,
212 package, strerror(
errno));
215 fprintf(stdout,
"\nExtension '%s', version %i.%i.%i\n\n", name, major,
220 dump_ascii(
"headers",
"Header files provided");
223 sprintf(tmp,
"../%s", package);
227 fprintf(stdout,
"Type '%s -d %s' to see more detailed information.\n",
228 invocation, org_name);
229 fprintf(stdout,
"Type '%s -l %s' to see copyright information.\n",
230 invocation, org_name);
247 fp = fopen(
"config.msg",
"r");
249 fprintf(stdout,
"\nResult of configuration: \n");
251 fprintf(stdout,
"%s", line);
253 fprintf(stdout,
"\n");
257 remove(
"config.msg");
264 int pkg_major,
int pkg_minor,
int pkg_revision,
279 char *grass_revision;
280 int major, minor, revision;
283 error =
stat(gisbase, &buf);
294 sprintf(tmp,
"%s/include", gisbase);
298 sprintf(tmp,
"%s/lib", gisbase);
306 verstr = strdup(grass_version);
307 grass_major = strtok(verstr,
".");
308 grass_minor = strtok(
NULL,
".");
309 grass_revision = strtok(
NULL,
".");
310 major = strtol(grass_major,
NULL, 10);
311 minor = strtol(grass_minor,
NULL, 10);
312 revision = strtol(grass_revision,
NULL, 10);
324 "extension files in '%s' not accessible: %s\n", package,
330 fprintf(stdout,
"Running configure script:\n");
332 error = system(sysstr);
335 fprintf(stdout,
"Configuring...");
338 error = system(sysstr);
354 sprintf(tmp,
"%i.%i.%i", pkg_major, pkg_minor, pkg_revision);
382 fprintf(stdout,
"Running '%s':\n",
MAKE_CMD);
384 error = system(sysstr);
387 fprintf(stdout,
"Compiling...");
389 error = system(sysstr);
394 "could not run '%s' do you have make tools installed?\n",
400 Run again with option -v to see what is causing trouble.\n");
404 fprintf(stdout,
"Installing...");
407 f = fopen(
"../uninstall",
"r");
410 Uninstalling this extension may leave orphaned files on your system", strerror(
errno));
415 sprintf(tmp,
"cp -vf ../uninstall %s/etc/uninstall.%s ;", gisbase,
420 sprintf(tmp,
"cp -f ../uninstall %s/etc/uninstall.%s &> %s ;",
433 if ((major == 6) && (minor < 1)) {
444 fprintf(stdout,
"Running '%s install':\n",
MAKE_CMD);
445 sprintf(install_cmd,
"%s -f Makefile install ; \
446 cp -vf %s %s/etc/extensions.db ; chmod -v a+r %s/etc/extensions.db ;",
MAKE_CMD,
TMPDB, gisbase, gisbase);
449 sprintf(install_cmd,
"%s -f Makefile -s install &> %s ; \
456 sprintf(post_cmd,
"sh ../post");
476 char *pkg_short_name,
int pkg_major,
int pkg_minor,
477 int pkg_revision,
char *grass_version)
490 char *grass_revision;
491 int major, minor, revision;
494 error =
stat(gisbase, &buf);
505 sprintf(tmp,
"%s/include", gisbase);
509 sprintf(tmp,
"%s/lib", gisbase);
517 verstr = strdup(grass_version);
518 grass_major = strtok(verstr,
".");
519 grass_minor = strtok(
NULL,
".");
520 grass_revision = strtok(
NULL,
".");
521 major = strtol(grass_major,
NULL, 10);
522 minor = strtol(grass_minor,
NULL, 10);
523 revision = strtol(grass_revision,
NULL, 10);
535 "extension file binaries in '%s' not accessible: %s\n",
536 package, strerror(
errno));
543 sprintf(tmp,
"%i.%i.%i", pkg_major, pkg_minor, pkg_revision);
569 fprintf(stdout,
"Installing...");
572 f = fopen(
"../uninstall",
"r");
575 Uninstalling this extension may leave orphaned files on your system", strerror(
errno));
580 sprintf(tmp,
"cp -vf ../uninstall %s/etc/uninstall.%s ;", gisbase,
585 sprintf(tmp,
"cp -f ../uninstall %s/etc/uninstall.%s &> %s ;",
597 if ((major == 6) && (minor < 1)) {
609 fprintf(stdout,
"Running '%s install':\n",
MAKE_CMD);
610 sprintf(install_cmd,
"bin/%s -f Makefile install ; \
611 cp -vf %s %s/etc/extensions.db ; chmod -v a+r %s/etc/extensions.db ;",
MAKE_CMD,
TMPDB, gisbase, gisbase);
614 sprintf(install_cmd,
"bin/%s -f Makefile -s install &> %s ; \
620 sprintf(post_cmd,
"sh ../post");
637 int pkg_major,
int pkg_minor,
int pkg_revision,
651 char *grass_revision;
652 int major, minor, revision;
655 error =
stat(gisbase, &buf);
666 sprintf(tmp,
"%s/include", gisbase);
670 sprintf(tmp,
"%s/lib", gisbase);
678 verstr = strdup(grass_version);
679 grass_major = strtok(verstr,
".");
680 grass_minor = strtok(
NULL,
".");
681 grass_revision = strtok(
NULL,
".");
682 major = strtol(grass_major,
NULL, 10);
683 minor = strtol(grass_minor,
NULL, 10);
684 revision = strtol(grass_revision,
NULL, 10);
695 "extension files in '%s' not accessible: %s\n", package,
701 fprintf(stdout,
"Running configure script:\n");
703 error = system(sysstr);
706 fprintf(stdout,
"Configuring...");
709 error = system(sysstr);
725 sprintf(tmp,
"%i.%i.%i", pkg_major, pkg_minor, pkg_revision);
753 fprintf(stdout,
"Running '%s':\n",
MAKE_CMD);
755 error = system(sysstr);
759 fprintf(stdout,
"Compiling...");
761 error = system(sysstr);
766 "could not run '%s' do you have make tools installed?\n",
772 Run again with option -v to see what is causing trouble.\n");
776 fprintf(stdout,
"Installing...");
779 f = fopen(
"../uninstall",
"r");
782 Uninstalling this extension may leave orphaned files on your system", strerror(
errno));
793 if ((major == 6) && (minor < 1)) {
802 fprintf(stdout,
"(skipping '%s install')...",
MAKE_CMD);
824 char *grass_revision;
825 int major, minor, revision;
827 fprintf(stdout,
"Un-installing...");
834 verstr = strdup(grass_version);
835 grass_major = strtok(verstr,
".");
836 grass_minor = strtok(
NULL,
".");
837 grass_revision = strtok(
NULL,
".");
838 major = strtol(grass_major,
NULL, 10);
839 minor = strtol(grass_minor,
NULL, 10);
840 revision = strtol(grass_revision,
NULL, 10);
851 if ((major == 6) && (minor < 1)) {
854 print_warning(
"GIS Manager menu entries could not be removed.\n");
858 print_warning(
"no entries found to remove from GIS Manager.\n");
870 sprintf(script,
"%s/etc/uninstall.%s", gisbase, pkg_short_name);
872 error =
stat(script, &buf);
874 print_warning(
"no uninstall script available for this extension.\n \
875 Unneeded files may have been left on your system.\n");
880 Uninstalling this extension may leave orphaned files on your system", strerror(
errno));
885 sprintf(tmp,
"sh %s ; rm -vf %s ; \
886 rm -vrf %s/docs/extensions/%s ; rm -vf %s/etc/dm/gem-entries/%s ; \
887 cp -vf %s %s/etc/extensions.db ; chmod -v a+r %s/etc/extensions.db ;", script, script, gisbase, pkg_short_name, gisbase, pkg_short_name,
TMPDB, gisbase, gisbase);
891 sprintf(tmp,
"sh %s &> %s ; rm -vf %s &> %s ; \
892 rm -vrf %s/docs/extensions/%s &> %s ; rm -vf %s/etc/dm/gem-entries/%s &> %s ; \
893 cp -vf %s %s/etc/extensions.db &> %s ; chmod -v a+r %s/etc/extensions.db &> %s ;", script,
TMP_NULL, script,
TMP_NULL, gisbase, pkg_short_name,
TMP_NULL, gisbase, pkg_short_name,
TMP_NULL,
TMPDB, gisbase,
TMP_NULL, gisbase,
TMP_NULL);
923 fprintf(stdout,
"Running '%s clean':\n",
MAKE_CMD);
925 error = system(sysstr);
928 fprintf(stdout,
"Cleaning up...");
930 error = system(sysstr);
935 "could not run '%s clean' do you have make tools installed?\n",
943 system(
"sh ../post");
960 char *grass_revision;
961 int major, minor, revision;
965 verstr = strdup(grass_version);
966 grass_major = strtok(verstr,
".");
967 grass_minor = strtok(
NULL,
".");
968 grass_revision = strtok(
NULL,
".");
969 major = strtol(grass_major,
NULL, 10);
970 minor = strtol(grass_minor,
NULL, 10);
971 revision = strtol(grass_revision,
NULL, 10);
974 fprintf(stdout,
"Restoring...");
977 if ((major == 6) && (minor < 1)) {
980 fprintf(stdout,
"\nRestored entries for GIS Manager: %i\n",
987 fprintf(stdout,
"\nRestored links in index.hml: %i\n", num_restored);
990 if (num_restored > 0) {
994 "cp -f %s %s/etc/dm/menu.tcl ; chmod a+r %s/etc/dm/menu.tcl ; \
995 cp -f %s %s/docs/html/index.html ; chmod a+r %s/docs/html/index.html",
1000 "cp -f %s %s/etc/dm/menu.tcl ; chmod a+r %s/etc/dm/menu.tcl &> %s ; \
1001 cp -f %s %s/docs/html/index.html ; chmod a+r %s/docs/html/index.html",
1010 if (num_restored == 0) {
1027 fprintf(stdout,
"\nExtensions in '%s' (name, version, type, depends):\n",
1031 sprintf(file,
"%s/etc/extensions.db", gisbase);
1032 f_in = fopen(file,
"r");
1034 if (
errno == ENOENT) {
1036 fprintf(stderr,
"NONE.\n");
1086 if (gisbase !=
NULL) {
void query_extension(char *package, char *name, int major, int minor, int revision, char *short_name, char *invocation, char *org_name)
void register_extension(char *gisbase, char *bins, char *pkg_short_name, int pkg_major, int pkg_minor, int pkg_revision)
void source_install(char *package, char *gisbase, char *pkg_short_name, int pkg_major, int pkg_minor, int pkg_revision, char *grass_version)
int restore_entries_gisman(char *gisbase)
EXTERN char GINSTALL_LIB[MAXSTR]
void list_extensions(char *gisbase)
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
EXTERN char INSTALL_TYPE[MAXSTR]
void bin_install(char *package, char *gisbase, char *bins, char *pkg_short_name, int pkg_major, int pkg_minor, int pkg_revision, char *grass_version)
EXTERN char GEM_VERBOSE[MAXSTR]
EXTERN char GEM_EXT_BUGS[MAXSTR]
EXTERN char CONFIG_OPTS[MAXSTR]
EXTERN char CONFIG_CMD[MAXSTR]
EXTERN char TMPDIR[MAXSTR]
EXTERN char GISMAN2_CMD[MAXSTR]
EXTERN char TMP_NULL[MAXSTR]
EXTERN char GEM_EXT_INFO[MAXSTR]
void print_error(int err_code, char *msg,...)
void uninstall(char *package, char *pkg_short_name, char *gisbase, char *grass_version)
EXTERN char TMP_HTML[MAXSTR]
void test_install(char *package, char *gisbase, char *pkg_short_name, int pkg_major, int pkg_minor, int pkg_revision, char *grass_version)
EXTERN char GEM_ACTION[MAXSTR]
void deregister_html(char *pkg_short_name, char *gisbase)
EXTERN char GEM_EXT_DESCR[MAXSTR]
void unpack_extension(char *package)
void deregister_extension(char *package, char *pkg_short_name, char *gisbase)
EXTERN char UNINSTALL_CMD[MAXSTR]
EXTERN char GEM_EXT_DEPS[MAXSTR]
int deregister_entries_gisman(char *pkg_short_name, char *gisbase)
void register_entries_gisman(char *pkg_short_name, char *gisbase)
EXTERN char TMP_AUTHORS[MAXSTR]
#define ERR_CONFIGURE_EXT
EXTERN char TMP_BUGS[MAXSTR]
EXTERN char HTML_CMD[MAXSTR]
EXTERN char GINSTALL_DST[MAXSTR]
void check_extension(char *package, char *name, int *major, int *minor, int *revision)
EXTERN char UNINSTALL_BASE[MAXSTR]
void register_html(char *pkg_short_name, char *gisbase, int major, int minor, int revision)
EXTERN char GEM_EXT_NAME[MAXSTR]
EXTERN char TMP_DESCR[MAXSTR]
void deregister_entries_gisman2(char *pkg_short_name, char *gisbase)
#define ERR_NO_ACCESS_EXT
EXTERN char TMPDB[MAXSTR]
void restore(char *gisbase, char *grass_version)
void run_post(char *package, int action, char *bins, char *gisbase)
EXTERN char MAKE_CMD[MAXSTR]
EXTERN char GEM_EXT_AUTHORS[MAXSTR]
void print_warning(char *msg,...)
EXTERN char GEM_GUI[MAXSTR]
EXTERN char EXT_BASE[MAXSTR]
EXTERN char GINSTALL_INC[MAXSTR]
EXTERN char TMP_INFO[MAXSTR]
EXTERN char INSTALL_BASE[MAXSTR]
EXTERN char GEM_FORCE[MAXSTR]
void register_entries_gisman2(char *pkg_short_name, char *gisbase)
EXTERN char TMP_DEPS[MAXSTR]
EXTERN char GEM_GRASS_DIR[MAXSTR]
int source_clean(char *package)
int restore_html(char *gisbase)
EXTERN char GEM_EXT_VERSION[MAXSTR]
EXTERN char GISMAN_CMD[MAXSTR]
void check_dependencies(char *package, char *gisbase, char *grass_version)
EXTERN char TMP_GISMAN[MAXSTR]