2 * FreeBSD install - a package for the installation and maintenance
3 * of non-core utilities.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
17 * $FreeBSD: src/usr.sbin/pkg_install/lib/pkgwrap.c,v 1.1 2002/09/09 19:43:30 sobomax Exp $
18 * $DragonFly: src/usr.sbin/pkg_install/lib/Attic/pkgwrap.c,v 1.2 2004/07/30 04:46:13 dillon Exp $
29 #define SEPARATORS " \t"
31 extern char **environ;
34 main(int argc, char **argv)
37 char buffer[FILENAME_MAX], *cp, *verstr;
40 if (getenv("PKG_NOWRAP") != NULL)
42 f = fopen(PKG_WRAPCONF_FNAME, "r");
45 cp = fgets(buffer, 256, f);
50 if (cp[len - 1] == '\n')
52 while (strchr(SEPARATORS, *cp) != NULL)
55 cp = strpbrk(cp, SEPARATORS);
59 for (cp = verstr; *cp != '\0'; cp++)
60 if (isdigit(*cp) == 0)
62 if (atoi(verstr) < PKG_INSTALL_VERSION)
65 while (*cp != '\0' && strchr(SEPARATORS, *cp) != NULL)
69 bcopy(cp, buffer, strlen(cp) + 1);
70 cp = strpbrk(buffer, SEPARATORS);
75 cp = strrchr(argv[0], '/');
80 strlcat(buffer, "/", sizeof(buffer));
81 strlcat(buffer, cp, sizeof(buffer));
82 setenv("PKG_NOWRAP", "1", 1);
83 execve(buffer, argv, environ);
86 unsetenv("PKG_NOWRAP");
87 return(real_main(argc, argv));