diff -r -u epm-4.1.old/Makefile.in epm-4.1/Makefile.in --- epm-4.1.old/Makefile.in 2006-11-30 22:59:27.000000000 +0100 +++ epm-4.1/Makefile.in 2007-11-06 12:11:15.000000000 +0100 @@ -68,7 +68,7 @@ # Rules... # -.SILENT: +#.SILENT: .SUFFIXES: .c .cxx .h .o .c.o: diff -r -u epm-4.1.old/aix.c epm-4.1/aix.c --- epm-4.1.old/aix.c 2007-01-14 21:55:33.000000000 +0100 +++ epm-4.1/aix.c 2007-11-06 10:31:16.000000000 +0100 @@ -201,7 +201,8 @@ printf("%s -> %s...\n", file->src, filename); if (copy_file(filename, file->src, file->mode, pwd ? pwd->pw_uid : 0, - grp ? grp->gr_gid : 0)) + grp ? grp->gr_gid : 0, + strstr(file->options, "expand(")!=NULL)) return (1); break; case 'i' : @@ -218,7 +219,8 @@ printf("%s -> %s...\n", file->src, filename); if (copy_file(filename, file->src, file->mode, - pwd ? pwd->pw_uid : 0, grp ? grp->gr_gid : 0)) + pwd ? pwd->pw_uid : 0, grp ? grp->gr_gid : 0, + strstr(file->options, "expand(")!=NULL)) return (1); snprintf(filename, sizeof(filename), @@ -230,7 +232,8 @@ printf("%s -> %s...\n", file->src, filename); if (copy_file(filename, file->src, file->mode, - pwd ? pwd->pw_uid : 0, grp ? grp->gr_gid : 0)) + pwd ? pwd->pw_uid : 0, grp ? grp->gr_gid : 0, + strstr(file->options, "expand(")!=NULL)) return (1); } break; @@ -882,9 +885,9 @@ snprintf(filename, sizeof(filename), "%s/lpp.README", directory); if (dist->license[0]) - copy_file(filename, dist->license, 0644, 0, 0); + copy_file(filename, dist->license, 0644, 0, 0, 0); else if (dist->readme[0]) - copy_file(filename, dist->readme, 0644, 0, 0); + copy_file(filename, dist->readme, 0644, 0, 0, 0); else if ((fp = fopen(filename, "w")) != NULL) fclose(fp); else diff -r -u epm-4.1.old/bsd.c epm-4.1/bsd.c --- epm-4.1.old/bsd.c 2006-04-05 17:08:08.000000000 +0200 +++ epm-4.1/bsd.c 2007-11-06 10:31:32.000000000 +0100 @@ -362,7 +362,8 @@ printf("%s -> %s...\n", file->src, filename); if (copy_file(filename, file->src, file->mode, pwd ? pwd->pw_uid : 0, - grp ? grp->gr_gid : 0)) + grp ? grp->gr_gid : 0, + strstr(file->options, "expand(")!=NULL)) return (1); break; case 'i' : @@ -373,7 +374,8 @@ printf("%s -> %s...\n", file->src, filename); if (copy_file(filename, file->src, file->mode, pwd ? pwd->pw_uid : 0, - grp ? grp->gr_gid : 0)) + grp ? grp->gr_gid : 0, + strstr(file->options, "expand(")!=NULL)) return (1); break; case 'd' : diff -r -u epm-4.1.old/deb.c epm-4.1/deb.c --- epm-4.1.old/deb.c 2006-08-17 23:00:25.000000000 +0200 +++ epm-4.1/deb.c 2007-11-06 10:31:47.000000000 +0100 @@ -534,7 +534,8 @@ printf("%s -> %s...\n", file->src, filename); if (copy_file(filename, file->src, file->mode, pwd ? pwd->pw_uid : 0, - grp ? grp->gr_gid : 0)) + grp ? grp->gr_gid : 0, + strstr(file->options, "expand(")!=NULL)) return (1); break; case 'i' : @@ -545,7 +546,8 @@ printf("%s -> %s...\n", file->src, filename); if (copy_file(filename, file->src, file->mode, pwd ? pwd->pw_uid : 0, - grp ? grp->gr_gid : 0)) + grp ? grp->gr_gid : 0, + strstr(file->options, "expand(")!=NULL)) return (1); break; case 'd' : diff -r -u epm-4.1.old/dist.c epm-4.1/dist.c --- epm-4.1.old/dist.c 2007-11-06 10:37:22.000000000 +0100 +++ epm-4.1/dist.c 2007-11-06 10:34:42.000000000 +0100 @@ -88,6 +88,19 @@ #define SKIP_IFSAT 16 /* Set if an #if statement has been satisfied */ #define SKIP_MASK 7 /* Bits to look at */ +int expand_variables(char *buffer, size_t bufsize) +{ + char *expand; + + expand = strdup(buffer); + if(expand == NULL) return -1; + + expand_name(buffer, expand, bufsize); + + free(expand); + + return 0; +} /* * 'add_command()' - Add a command to the distribution... diff -r -u epm-4.1.old/epm.h epm-4.1/epm.h --- epm-4.1.old/epm.h 2007-11-06 10:37:22.000000000 +0100 +++ epm-4.1/epm.h 2007-11-06 10:16:59.000000000 +0100 @@ -259,7 +259,8 @@ extern file_t *add_file(dist_t *dist, const char *subpkg); extern char *add_subpackage(dist_t *dist, const char *subpkg); extern int copy_file(const char *dst, const char *src, - mode_t mode, uid_t owner, gid_t group); + mode_t mode, uid_t owner, gid_t group, int expand); +int expand_variables(char *buffer, size_t bufsize); extern char *find_subpackage(dist_t *dist, const char *subpkg); extern void free_dist(dist_t *dist); extern const char *get_option(file_t *file, const char *name, const char *defval); diff -r -u epm-4.1.old/file.c epm-4.1/file.c --- epm-4.1.old/file.c 2006-08-29 18:43:09.000000000 +0200 +++ epm-4.1/file.c 2007-11-06 12:28:58.000000000 +0100 @@ -41,7 +41,8 @@ const char *src, /* I - Source file */ mode_t mode, /* I - Permissions */ uid_t owner, /* I - Owner ID */ - gid_t group) /* I - Group ID */ + gid_t group, /* I - Group ID */ + int expand) /* expand environment variables */ { FILE *dstfile, /* Destination file */ *srcfile; /* Source file */ @@ -88,18 +89,50 @@ * Copy from src to dst... */ - while ((bytes = fread(buffer, 1, sizeof(buffer), srcfile)) > 0) - if (fwrite(buffer, 1, bytes, dstfile) < bytes) + if(expand) + { + while(fgets(buffer, sizeof(buffer), srcfile) != NULL) { - fprintf(stderr, "epm: Unable to write to \"%s\" -\n %s\n", dst, - strerror(errno)); - - fclose(srcfile); - fclose(dstfile); - unlink(dst); - - return (-1); + if(expand_variables(buffer, sizeof(buffer)) < 0) + { + fprintf(stderr, + "epm: Unable to expand variables to \"%s\" -\n %s\n", dst, + strerror(errno)); + + fclose(srcfile); + fclose(dstfile); + unlink(dst); + + return (-1); + } + if (fputs(buffer, dstfile) < 0) + { + fprintf(stderr, "epm: Unable to write to \"%s\" -\n %s\n", dst, + strerror(errno)); + + fclose(srcfile); + fclose(dstfile); + unlink(dst); + + return (-1); + } } + } + else + { + while ((bytes = fread(buffer, 1, sizeof(buffer), srcfile)) > 0) + if (fwrite(buffer, 1, bytes, dstfile) < bytes) + { + fprintf(stderr, "epm: Unable to write to \"%s\" -\n %s\n", dst, + strerror(errno)); + + fclose(srcfile); + fclose(dstfile); + unlink(dst); + + return (-1); + } + } /* * Close files, change permissions, and return... diff -r -u epm-4.1.old/osx.c epm-4.1/osx.c --- epm-4.1.old/osx.c 2006-08-21 23:04:23.000000000 +0200 +++ epm-4.1/osx.c 2007-11-06 10:33:06.000000000 +0100 @@ -117,7 +117,7 @@ snprintf(filename, sizeof(filename), "%s/MetaResources/License%s", directory, ext); - copy_file(filename, dist->license, 0644, 0, 0); + copy_file(filename, dist->license, 0644, 0, 0, 0); } if (dist->readme[0]) @@ -127,7 +127,7 @@ snprintf(filename, sizeof(filename), "%s/MetaResources/ReadMe%s", directory, ext); - copy_file(filename, dist->readme, 0644, 0, 0); + copy_file(filename, dist->readme, 0644, 0, 0, 0); } if (setup && (ext = strrchr(setup, '.')) != NULL && @@ -135,7 +135,7 @@ { snprintf(filename, sizeof(filename), "%s/MetaResources/background%s", directory, ext); - copy_file(filename, setup, 0644, 0, 0); + copy_file(filename, setup, 0644, 0, 0, 0); } snprintf(filename, sizeof(filename), "%s/MetaResources/Welcome.rtf", @@ -405,7 +405,7 @@ snprintf(filename, sizeof(filename), "%s/%s/Resources/License%s", directory, prodfull, ext); - copy_file(filename, dist->license, 0644, 0, 0); + copy_file(filename, dist->license, 0644, 0, 0, 0); } if (dist->readme[0]) @@ -415,7 +415,7 @@ snprintf(filename, sizeof(filename), "%s/%s/Resources/ReadMe%s", directory, prodfull, ext); - copy_file(filename, dist->readme, 0644, 0, 0); + copy_file(filename, dist->readme, 0644, 0, 0, 0); } if (setup && (ext = strrchr(setup, '.')) != NULL && @@ -423,7 +423,7 @@ { snprintf(filename, sizeof(filename), "%s/%s/Resources/background%s", directory, prodfull, ext); - copy_file(filename, setup, 0644, 0, 0); + copy_file(filename, setup, 0644, 0, 0, 0); } snprintf(filename, sizeof(filename), "%s/%s/Resources/Welcome.rtf", @@ -616,7 +616,8 @@ printf("%s -> %s...\n", file->src, filename); if (copy_file(filename, file->src, file->mode, pwd ? pwd->pw_uid : 0, - grp ? grp->gr_gid : 0)) + grp ? grp->gr_gid : 0, + strstr(file->options, "expand(")!=NULL)) return (1); break; case 'i' : @@ -628,7 +629,8 @@ printf("%s -> %s...\n", file->src, filename); if (copy_file(filename, file->src, file->mode, pwd ? pwd->pw_uid : 0, - grp ? grp->gr_gid : 0)) + grp ? grp->gr_gid : 0, + strstr(file->options, "expand(")!=NULL)) return (1); snprintf(filename, sizeof(filename), diff -r -u epm-4.1.old/portable.c epm-4.1/portable.c --- epm-4.1.old/portable.c 2007-03-20 18:44:24.000000000 +0100 +++ epm-4.1/portable.c 2007-11-06 10:33:27.000000000 +0100 @@ -1433,14 +1433,16 @@ if (dist->license[0]) { snprintf(filename, sizeof(filename), "%s/%s.license", directory, prodfull); - if (copy_file(filename, dist->license, 0444, getuid(), getgid())) + if (copy_file(filename, dist->license, 0444, getuid(), getgid(), + strstr(file->options, "expand(")!=NULL)) return (1); } if (dist->readme[0]) { snprintf(filename, sizeof(filename), "%s/%s.readme", directory, prodfull); - if (copy_file(filename, dist->readme, 0444, getuid(), getgid())) + if (copy_file(filename, dist->readme, 0444, getuid(), getgid(), + strstr(file->options, "expand(")!=NULL)) return (1); } diff -r -u epm-4.1.old/rpm.c epm-4.1/rpm.c --- epm-4.1.old/rpm.c 2007-11-06 10:37:22.000000000 +0100 +++ epm-4.1/rpm.c 2007-11-06 10:28:48.000000000 +0100 @@ -197,7 +197,8 @@ printf("%s -> %s...\n", file->src, filename); if (copy_file(filename, file->src, file->mode, pwd ? pwd->pw_uid : 0, - grp ? grp->gr_gid : 0)) + grp ? grp->gr_gid : 0, + strstr(file->options, "expand(")!=NULL)) return (1); break; case 'i' : @@ -209,7 +210,8 @@ printf("%s -> %s...\n", file->src, filename); if (copy_file(filename, file->src, file->mode, pwd ? pwd->pw_uid : 0, - grp ? grp->gr_gid : 0)) + grp ? grp->gr_gid : 0, + strstr(file->options, "expand(")!=NULL)) return (1); break; case 'd' : diff -r -u epm-4.1.old/setld.c epm-4.1/setld.c --- epm-4.1.old/setld.c 2006-04-05 17:08:08.000000000 +0200 +++ epm-4.1/setld.c 2007-11-06 10:28:58.000000000 +0100 @@ -380,7 +380,8 @@ printf("%s -> %s...\n", file->src, filename); if (copy_file(filename, file->src, file->mode, pwd ? pwd->pw_uid : 0, - grp ? grp->gr_gid : 0)) + grp ? grp->gr_gid : 0, + strstr(file->options, "expand(")!=NULL)) return (1); break; diff -r -u epm-4.1.old/slackware.c epm-4.1/slackware.c --- epm-4.1.old/slackware.c 2006-04-05 17:08:08.000000000 +0200 +++ epm-4.1/slackware.c 2007-11-06 10:29:09.000000000 +0100 @@ -173,7 +173,8 @@ printf("F %s -> %s...\n", file->src, filename); if (copy_file(filename, file->src, file->mode, pwd ? pwd->pw_uid : 0, - grp ? grp->gr_gid : 0)) + grp ? grp->gr_gid : 0, + strstr(file->options, "expand(")!=NULL)) return (1); break; @@ -185,7 +186,8 @@ printf("I %s -> %s...\n", file->src, filename); if (copy_file(filename, file->src, file->mode, pwd ? pwd->pw_uid : 0, - grp ? grp->gr_gid : 0)) + grp ? grp->gr_gid : 0, + strstr(file->options, "expand(")!=NULL)) return (1); break;