45 f_deps = fopen(file,
"r");
47 if (
errno == ENOENT) {
61 if (strlen(line) > 0) {
62 error = sscanf(line,
"%s", short_name);
63 if ((error > 0) && (strcmp(
"GRASS", short_name))) {
66 strcat(str, short_name);
71 strcat(str, short_name);
88 int pkg_major,
int pkg_minor,
int pkg_revision)
103 int major, minor, revision;
108 sprintf(file,
"%s/etc/extensions.db", gisbase);
109 f_in = fopen(file,
"r");
111 if (
errno == ENOENT) {
119 file, strerror(
errno));
126 strcpy(
TMPDB,
"/tmp/grass.extensions.db.XXXXXX");
129 f_out = fopen(
TMPDB,
"w+");
132 "could not create temp file '%s': %s\n \
133 Make sure that directory /tmp exists on your system and you have write permission.\n",
TMPDB, strerror(
errno));
146 sscanf(str,
"%s\t%i.%i.%i\t%s\t%s", short_name, &major, &minor,
147 &revision, inst_bins, deps);
149 if (!strcmp(short_name, pkg_short_name)) {
154 vercmp(major, minor, revision, pkg_major, pkg_minor,
160 "Extension '%s' with lower version (%i.%i.%i) already installed. You can use -f to overwrite this version, if you know what you are doing.\n",
161 pkg_short_name, major, minor, revision);
165 "Extension '%s' with same or higher version (%i.%i.%i) already installed. You can use -f to overwrite this version, if you know what you are doing.\n",
166 pkg_short_name, major, minor, revision);
193 fprintf(f_out,
"%s\t%i.%i.%i\t%s\t%s\n", pkg_short_name,
194 pkg_major, pkg_minor, pkg_revision, bins, deps);
199 fprintf(f_out,
"%s\t%i.%i.%i\t%s\t%s\n", short_name,
200 pkg_major, pkg_minor, pkg_revision, inst_bins, deps);
208 if ((n_lines == 0) || (!db_exists)) {
211 strcpy(
TMPDB,
"/tmp/grass.extensions.db.XXXXXX");
214 f_out = fopen(
TMPDB,
"w+");
217 "could not create temp db '%s': %s\n \
218 Make sure that directory /tmp exists on your system and you have write permission.\n", file, strerror(
errno));
224 fprintf(f_out,
"%s\t%i.%i.%i\t%s\t%s\n", pkg_short_name, pkg_major,
225 pkg_minor, pkg_revision, bins, deps);
248 int major, minor, revision;
253 sprintf(file,
"%s/etc/extensions.db", gisbase);
254 f_in = fopen(file,
"r");
260 "could not deregister: no extensions installed\n");
267 "checking for file '%s': %s\n", file,
280 strcpy(
TMPDB,
"/tmp/grass.extensions.db.XXXXXX");
283 f_out = fopen(
TMPDB,
"w+");
286 "could not create temp db '%s': %s\n \
287 Make sure that directory /tmp exists on your system and you have write permission.\n", file, strerror(
errno));
302 sscanf(str,
"%s\t%i.%i.%i\t%s\t%s", short_name, &major,
303 &minor, &revision, inst_bins, deps);
306 if (!strcmp(pkg_short_name, short_name)) {
312 if ((strstr(deps, pkg_short_name)) && (!
FORCE)) {
314 "cannot uninstall extension '%s' it is needed by '%s'.\n",
315 pkg_short_name, short_name);
323 if (found_ext == 0) {
325 "no extension '%s' registered/installed in '%s'.\n",
326 pkg_short_name, gisbase);
351 int major, minor, revision;
352 char dep_short_name[
MAXSTR];
353 int dep_major, dep_minor, dep_revision;
360 f_deps = fopen(
"../depends",
"r");
361 if (f_deps ==
NULL) {
362 if (
errno == ENOENT) {
364 fprintf(stderr,
"\n%s/depends ENOENT\n", package);
377 sprintf(file,
"%s/etc/extensions.db", gisbase);
378 f_db = fopen(file,
"r");
380 if (
errno == ENOENT) {
402 sscanf(str,
"%s\t%i.%i.%i", dep_short_name, &dep_major,
403 &dep_minor, &dep_revision);
405 if (!strcmp(dep_short_name,
"GRASS")) {
407 sscanf(grass_version,
"%i.%i.%i", &major, &minor, &revision);
409 (major, minor, revision, dep_major, dep_minor,
412 "installed version (%s) of GRASS is too low. Required version is %i.%i.%i\n",
413 grass_version, dep_major, dep_minor,
428 sscanf(dbstr,
"%s\t%i.%i.%i", short_name, &major,
431 if (!strcmp(short_name, dep_short_name)) {
435 (major, minor, revision, dep_major,
436 dep_minor, dep_revision) < 0) {
438 "installed version %i.%i.%i of required extension '%s' is too low.\n \
439 Required version is %i.%i.%i\n",
440 major, minor, revision, dep_short_name, dep_major, dep_minor,
450 "required extension '%s' not found in '%s'.\n",
451 dep_short_name, gisbase);
void register_extension(char *gisbase, char *bins, char *pkg_short_name, int pkg_major, int pkg_minor, int pkg_revision)
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
char * depstr(char *package, char *gisbase)
void print_error(int err_code, char *msg,...)
void deregister_extension(char *package, char *pkg_short_name, char *gisbase)
EXTERN char TMPDB[MAXSTR]
#define ERR_DEREGISTER_EXT
void check_dependencies(char *package, char *gisbase, char *grass_version)