1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-14 10:09:48 +00:00

- pkg_create: new flag -S (clean room installation)

- pkg_create: checksum meta files too

PR:		66032
This commit is contained in:
Oliver Eikemeier 2004-06-29 18:56:59 +00:00
parent d13e5a4065
commit 9c762229f3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=131277
5 changed files with 74 additions and 33 deletions

View File

@ -34,6 +34,7 @@ extern char *PostDeInstall;
extern char *Contents;
extern char *Require;
extern char *SrcDir;
extern char *BaseDir;
extern char *ExcludeFrom;
extern char *Mtree;
extern char *Pkgdeps;
@ -47,6 +48,7 @@ extern int PlistOnly;
enum zipper {NONE, GZIP, BZIP, BZIP2 };
extern enum zipper Zipper;
void add_cksum(Package *, PackingList, const char *);
void check_list(const char *, Package *);
int pkg_perform(char **);
void copy_plist(const char *, Package *);

View File

@ -16,12 +16,13 @@ __FBSDID("$FreeBSD$");
#include "lib.h"
#include "create.h"
static char Options[] = "YNOhjvyzf:p:P:C:c:d:i:I:k:K:r:t:X:D:m:s:o:b:";
static char Options[] = "YNOhjvyzf:p:P:C:c:d:i:I:k:K:r:t:X:D:m:s:S:o:b:";
char *Prefix = NULL;
char *Comment = NULL;
char *Desc = NULL;
char *SrcDir = NULL;
char *BaseDir = NULL;
char *Display = NULL;
char *Install = NULL;
char *PostInstall = NULL;
@ -75,6 +76,10 @@ main(int argc, char **argv)
SrcDir = optarg;
break;
case 'S':
BaseDir = optarg;
break;
case 'f':
Contents = optarg;
break;
@ -199,12 +204,13 @@ main(int argc, char **argv)
static void
usage()
{
fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n",
"usage: pkg_create [-YNOhvy] [-P pkgs] [-C conflicts] [-p prefix] [-f contents] ",
fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
"usage: pkg_create [-YNOhvyz] [-P pkgs] [-C conflicts] [-p prefix] ",
" [-i iscript] [-I piscript] [-k dscript] [-K pdscript] ",
" [-r rscript] [-t template] [-X excludefile] ",
" [-D displayfile] [-m mtreefile] [-o origin] ",
" [-s srcdir] [-S basedir] ",
" -c comment -d description -f packlist pkg-filename",
" pkg_create [-YNhvy] -b pkg-name [pkg-filename]");
" pkg_create [-YNhvyz] -b pkg-name [pkg-filename]");
exit(1);
}

View File

@ -222,45 +222,54 @@ pkg_perform(char **pkgs)
write_file(COMMENT_FNAME, Comment);
add_plist(&plist, PLIST_IGNORE, NULL);
add_plist(&plist, PLIST_FILE, COMMENT_FNAME);
add_cksum(&plist, plist.tail, COMMENT_FNAME);
write_file(DESC_FNAME, Desc);
add_plist(&plist, PLIST_IGNORE, NULL);
add_plist(&plist, PLIST_FILE, DESC_FNAME);
add_cksum(&plist, plist.tail, DESC_FNAME);
if (Install) {
copy_file(home, Install, INSTALL_FNAME);
add_plist(&plist, PLIST_IGNORE, NULL);
add_plist(&plist, PLIST_FILE, INSTALL_FNAME);
add_cksum(&plist, plist.tail, INSTALL_FNAME);
}
if (PostInstall) {
copy_file(home, PostInstall, POST_INSTALL_FNAME);
add_plist(&plist, PLIST_IGNORE, NULL);
add_plist(&plist, PLIST_FILE, POST_INSTALL_FNAME);
add_cksum(&plist, plist.tail, POST_INSTALL_FNAME);
}
if (DeInstall) {
copy_file(home, DeInstall, DEINSTALL_FNAME);
add_plist(&plist, PLIST_IGNORE, NULL);
add_plist(&plist, PLIST_FILE, DEINSTALL_FNAME);
add_cksum(&plist, plist.tail, DEINSTALL_FNAME);
}
if (PostDeInstall) {
copy_file(home, PostDeInstall, POST_DEINSTALL_FNAME);
add_plist(&plist, PLIST_IGNORE, NULL);
add_plist(&plist, PLIST_FILE, POST_DEINSTALL_FNAME);
add_cksum(&plist, plist.tail, POST_DEINSTALL_FNAME);
}
if (Require) {
copy_file(home, Require, REQUIRE_FNAME);
add_plist(&plist, PLIST_IGNORE, NULL);
add_plist(&plist, PLIST_FILE, REQUIRE_FNAME);
add_cksum(&plist, plist.tail, REQUIRE_FNAME);
}
if (Display) {
copy_file(home, Display, DISPLAY_FNAME);
add_plist(&plist, PLIST_IGNORE, NULL);
add_plist(&plist, PLIST_FILE, DISPLAY_FNAME);
add_cksum(&plist, plist.tail, DISPLAY_FNAME);
add_plist(&plist, PLIST_DISPLAY, DISPLAY_FNAME);
}
if (Mtree) {
copy_file(home, Mtree, MTREE_FNAME);
add_plist(&plist, PLIST_IGNORE, NULL);
add_plist(&plist, PLIST_FILE, MTREE_FNAME);
add_cksum(&plist, plist.tail, MTREE_FNAME);
add_plist(&plist, PLIST_MTREE, MTREE_FNAME);
}
@ -384,6 +393,8 @@ make_dist(const char *homedir, const char *pkg, const char *suff, Package *plist
for (p = plist->head; p; p = p->next) {
if (p->type == PLIST_FILE)
fprintf(totar, "%s\n", p->name);
else if (p->type == PLIST_CWD && BaseDir && p->name && p->name[0] == '/')
fprintf(totar, "-C\n%s%s\n", BaseDir, p->name);
else if (p->type == PLIST_CWD || p->type == PLIST_SRC)
fprintf(totar, "-C\n%s\n", p->name);
else if (p->type == PLIST_IGNORE)

View File

@ -23,7 +23,7 @@
.\" [jkh] Took John's changes back and made some additional extensions for
.\" better integration with FreeBSD's new ports collection.
.\"
.Dd April 21, 1995
.Dd June 29, 2004
.Dt PKG_CREATE 1
.Os
.Sh NAME
@ -35,13 +35,13 @@
.Op Fl C Ar conflicts
.Op Fl P Ar pkgs
.Op Fl p Ar prefix
.Op Fl f Ar contents
.Op Fl i Ar iscript
.Op Fl I Ar piscript
.Op Fl k Ar dscript
.Op Fl K Ar pdscript
.Op Fl r Ar rscript
.Op Fl s Ar srcdir
.Op Fl S Ar basedir
.Op Fl t Ar template
.Op Fl X Ar excludefile
.Op Fl D Ar displayfile
@ -224,6 +224,11 @@ are passed respectively, along with the package's name.
will override the value of
.Cm @cwd
during package creation.
.It Fl S Ar basedir
.Ar basedir
will be prefixed to all
.Cm @cwd
during package creation.
.It Fl t Ar template
Use
.Ar template
@ -544,7 +549,8 @@ command first appeared in
.Sh AUTHORS
.An Jordan Hubbard
.Sh CONTRIBUTORS
.An John Kohl Aq jtk@rational.com
.An John Kohl Aq jtk@rational.com ,
.An Oliver Eikemeier Aq eik@FreeBSD.org
.Sh BUGS
Hard links between files in a distribution must be bracketed by
.Cm @cwd

View File

@ -27,13 +27,43 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <md5.h>
/* Add an MD5 checksum entry for a file or link */
void
add_cksum(Package *pkg, PackingList p, const char *fname)
{
char *cp = NULL, buf[33];
if (issymlink(fname)) {
int len;
char lnk[FILENAME_MAX];
if ((len = readlink(fname, lnk, FILENAME_MAX)) > 0)
cp = MD5Data((unsigned char *)lnk, len, buf);
} else if (isfile(fname)) {
/* Don't record MD5 checksum for device nodes and such */
cp = MD5File(fname, buf);
}
if (cp != NULL) {
PackingList tmp = new_plist_entry();
tmp->name = copy_string(strconcat("MD5:", cp));
tmp->type = PLIST_COMMENT;
tmp->next = p->next;
tmp->prev = p;
p->next = tmp;
if (pkg->tail == p)
pkg->tail = tmp;
}
}
/* Check a list for files that require preconversion */
void
check_list(const char *home, Package *pkg)
{
const char *where = home;
const char *there = NULL;
char *cp, name[FILENAME_MAX], buf[33];
char name[FILENAME_MAX];
PackingList p;
for (p = pkg->head; p != NULL; p = p->next)
@ -51,31 +81,13 @@ check_list(const char *home, Package *pkg)
break;
case PLIST_FILE:
cp = NULL;
sprintf(name, "%s/%s", there ? there : where, p->name);
if (issymlink(name)) {
int len;
char lnk[FILENAME_MAX];
if (there)
snprintf(name, sizeof(name), "%s/%s", there, p->name);
else
snprintf(name, sizeof(name), "%s%s/%s",
BaseDir && where && where[0] == '/' ? BaseDir : "", where, p->name);
if ((len = readlink(name, lnk, FILENAME_MAX)) > 0)
cp = MD5Data((unsigned char *)lnk, len, buf);
} else if (isfile(name)) {
/* Don't record MD5 checksum for device nodes and such */
cp = MD5File(name, buf);
}
if (cp != NULL) {
PackingList tmp = new_plist_entry();
tmp->name = copy_string(strconcat("MD5:", cp));
tmp->type = PLIST_COMMENT;
tmp->next = p->next;
tmp->prev = p;
p->next = tmp;
if (pkg->tail == p)
pkg->tail = tmp;
p = tmp;
}
add_cksum(pkg, p, name);
break;
default:
break;
@ -217,7 +229,11 @@ copy_plist(const char *home, Package *plist)
if (p->name[0] == '/')
mythere = root;
else mythere = there;
sprintf(fn, "%s/%s", mythere ? mythere : where, p->name);
if (mythere)
snprintf(fn, sizeof(fn), "%s/%s", mythere, p->name);
else
snprintf(fn, sizeof(fn), "%s%s/%s",
BaseDir && where && where[0] == '/' ? BaseDir : "", where, p->name);
if (lstat(fn, &stb) == 0 && stb.st_dev == curdir &&
S_ISREG(stb.st_mode)) {
/*