1993-08-26 01:19:55 +00:00
|
|
|
#ifndef lint
|
1993-09-18 03:38:48 +00:00
|
|
|
static const char *rcsid = "$Id: extract.c,v 1.4 1993/09/06 23:26:21 jkh Exp $";
|
1993-08-26 01:19:55 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FreeBSD install - a package for the installation and maintainance
|
|
|
|
* of non-core utilities.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* Jordan K. Hubbard
|
|
|
|
* 18 July 1993
|
|
|
|
*
|
|
|
|
* This is the package extraction code for the add module.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "lib.h"
|
|
|
|
#include "add.h"
|
|
|
|
|
|
|
|
void
|
|
|
|
extract_plist(char *home, Package *pkg)
|
|
|
|
{
|
|
|
|
PackingList p = pkg->head;
|
|
|
|
char *last_file;
|
|
|
|
|
|
|
|
/* Reset the world */
|
|
|
|
Owner = NULL;
|
|
|
|
Group = NULL;
|
|
|
|
Mode = NULL;
|
|
|
|
last_file = NULL;
|
|
|
|
Directory = home;
|
|
|
|
|
|
|
|
/* Do it */
|
|
|
|
while (p) {
|
1993-09-18 03:38:48 +00:00
|
|
|
char cmd[FILENAME_MAX];
|
|
|
|
|
1993-08-26 01:19:55 +00:00
|
|
|
switch(p->type) {
|
|
|
|
case PLIST_NAME:
|
|
|
|
PkgName = p->name;
|
|
|
|
if (Verbose)
|
|
|
|
printf("extract: Package name is %s\n", p->name);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PLIST_FILE:
|
|
|
|
last_file = p->name;
|
|
|
|
if (Verbose)
|
|
|
|
printf("extract: %s/%s\n", Directory, p->name);
|
|
|
|
if (!Fake) {
|
1993-09-05 04:53:51 +00:00
|
|
|
char try[FILENAME_MAX];
|
|
|
|
|
|
|
|
/* first try to rename it into place */
|
|
|
|
sprintf(try, "%s/%s", Directory, p->name);
|
|
|
|
if (rename(p->name, try) == FAIL)
|
|
|
|
copy_hierarchy(Directory, p->name, TRUE);
|
1993-08-26 01:19:55 +00:00
|
|
|
apply_perms(Directory, p->name);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PLIST_CWD:
|
|
|
|
if (Verbose)
|
|
|
|
printf("extract: CWD to %s\n", p->name);
|
|
|
|
if (strcmp(p->name, ".")) {
|
|
|
|
if (!Fake && make_hierarchy(p->name) == FAIL)
|
|
|
|
barf("Unable make directory '%s'.", p->name);
|
|
|
|
Directory = p->name;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Directory = home;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PLIST_CMD:
|
1993-09-18 03:38:48 +00:00
|
|
|
format_cmd(cmd, p->name, Directory, last_file);
|
1993-08-26 01:19:55 +00:00
|
|
|
if (Verbose)
|
1993-09-18 03:38:48 +00:00
|
|
|
printf("extract: execute '%s'\n", cmd);
|
|
|
|
if (!Fake && system(cmd))
|
|
|
|
whinge("Command '%s' failed.", cmd);
|
1993-08-26 01:19:55 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PLIST_CHMOD:
|
|
|
|
Mode = p->name;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PLIST_CHOWN:
|
|
|
|
Owner = p->name;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PLIST_CHGRP:
|
|
|
|
Group = p->name;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PLIST_COMMENT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PLIST_IGNORE:
|
|
|
|
p = p->next;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
p = p->next;
|
|
|
|
}
|
|
|
|
}
|