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.
19 #include <sys/cdefs.h>
20 __FBSDID("$FreeBSD$");
30 #define SEPARATORS " \t"
32 extern char **environ;
35 main(int argc, char **argv)
38 char buffer[FILENAME_MAX], *cp, *verstr;
41 if (getenv("PKG_NOWRAP") != NULL)
43 f = fopen(PKG_WRAPCONF_FNAME, "r");
46 cp = fgets(buffer, 256, f);
51 if (cp[len - 1] == '\n')
53 while (strchr(SEPARATORS, *cp) != NULL)
56 cp = strpbrk(cp, SEPARATORS);
60 for (cp = verstr; *cp != '\0'; cp++)
61 if (isdigit(*cp) == 0)
63 if (atoi(verstr) < PKG_INSTALL_VERSION)
66 while (*cp != '\0' && strchr(SEPARATORS, *cp) != NULL)
70 bcopy(cp, buffer, strlen(cp) + 1);
71 cp = strpbrk(buffer, SEPARATORS);
76 cp = strrchr(argv[0], '/');
81 strlcat(buffer, "/", sizeof(buffer));
82 strlcat(buffer, cp, sizeof(buffer));
83 setenv("PKG_NOWRAP", "1", 1);
84 execve(buffer, argv, environ);
87 unsetenv("PKG_NOWRAP");
88 return(real_main(argc, argv));