Date: Fri, 8 Mar 2002 05:20:02 -0800 (PST) From: Mark Hannon <markhannon@optushome.com.au> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/34007: pkg_create -b forgets to include install scripts Message-ID: <200203081320.g28DK2G66202@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/34007; it has been noted by GNATS.
From: Mark Hannon <markhannon@optushome.com.au>
To: freebsd-gnats-submit@FreeBSD.org, olgeni@uli.it
Cc:
Subject: Re: bin/34007: pkg_create -b forgets to include install scripts
Date: Sat, 09 Mar 2002 00:19:35 +1100
This is a multi-part message in MIME format.
--------------5C0AF1159856F2BC17D7793D
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Please try these patches. /mark
--------------5C0AF1159856F2BC17D7793D
Content-Type: text/plain; charset=us-ascii;
name="pkg_install.3"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="pkg_install.3"
Index: lib/lib.h
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/lib/lib.h,v
retrieving revision 1.29.2.9
diff -c -r1.29.2.9 lib.h
*** lib/lib.h 2001/10/24 10:06:56 1.29.2.9
--- lib/lib.h 2002/03/08 13:17:11
***************
*** 112,118 ****
typedef struct _plist *PackingList;
struct _pack {
! struct _plist *head, *tail;
int fmtver_maj, fmtver_mnr;
};
typedef struct _pack Package;
--- 112,118 ----
typedef struct _plist *PackingList;
struct _pack {
! struct _plist *current, *head, *tail;
int fmtver_maj, fmtver_mnr;
};
typedef struct _pack Package;
***************
*** 174,179 ****
--- 174,180 ----
PackingList new_plist_entry(void);
PackingList last_plist(Package *);
PackingList find_plist(Package *, plist_t);
+ PackingList find_plist_next(Package *, plist_t);
char *find_plist_option(Package *, const char *name);
void plist_delete(Package *, Boolean, plist_t, const char *);
void free_plist(Package *);
Index: lib/plist.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/lib/plist.c,v
retrieving revision 1.29.2.6
diff -c -r1.29.2.6 plist.c
*** lib/plist.c 2001/10/24 10:06:56 1.29.2.6
--- lib/plist.c 2002/03/08 13:17:12
***************
*** 84,98 ****
}
/* Find a given item in a packing list and, if so, return it (else NULL) */
! PackingList
find_plist(Package *pkg, plist_t type)
{
PackingList p = pkg->head;
while (p) {
! if (p->type == type)
return p;
p = p->next;
}
return NULL;
}
--- 84,127 ----
}
/* Find a given item in a packing list and, if so, return it (else NULL) */
! PackingList
find_plist(Package *pkg, plist_t type)
{
PackingList p = pkg->head;
while (p) {
! if (p->type == type){
! pkg->current = p;
return p;
+ }
p = p->next;
+ }
+ return NULL;
+ }
+
+ /*
+ * Find the next given item in a packing list and, if so, return it (else NULL)
+ * Unlike the previous function, this version pre-increments the current pointer
+ * before returning a value, this means that the function may be called several
+ * times and it will continue to return a valid value for each matching plist_t
+ *
+ * This function MAY ONLY be called immediately after getting a non NULL result
+ * from a call to find_plist, ie call find_plist to initialize and then iterate
+ * with find_plist_next.
+ */
+ PackingList
+ find_plist_next(Package *pkg, plist_t type)
+ {
+ PackingList p;
+
+ p = pkg->current;
+
+ while (p) {
+ p = p->next;
+ if (p && p->type == type){
+ pkg->current = p;
+ return p;
+ }
}
return NULL;
}
--------------5C0AF1159856F2BC17D7793D
Content-Type: text/plain; charset=us-ascii;
name="pkg_install.4"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="pkg_install.4"
Index: create/create.h
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/create/create.h,v
retrieving revision 1.15.2.4
diff -c -r1.15.2.4 create.h
*** create/create.h 2001/10/23 09:16:03 1.15.2.4
--- create/create.h 2002/03/08 13:16:07
***************
*** 47,51 ****
void check_list(const char *, Package *);
int pkg_perform(char **);
void copy_plist(const char *, Package *);
-
#endif /* _INST_CREATE_H_INCLUDE */
--- 47,50 ----
Index: create/perform.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/create/perform.c,v
retrieving revision 1.49.2.11
diff -c -r1.49.2.11 perform.c
*** create/perform.c 2002/01/18 08:37:46 1.49.2.11
--- create/perform.c 2002/03/08 13:16:08
***************
*** 37,45 ****
--- 37,53 ----
static void sanity_check(void);
static void make_dist(const char *, const char *, const char *, Package *);
static int create_from_installed(const char *, const char *);
+ static void is_a_special_file(const char *name);
static char *home;
+ char *Display;
+ char *Install;
+ char *PostInstall;
+ char *DeInstall;
+ char *PostDeInstall;
+ char *Mtree;
+
int
pkg_perform(char **pkgs)
{
***************
*** 413,418 ****
--- 421,427 ----
{
FILE *fp;
Package plist;
+ PackingList plistp;
char homedir[MAXPATHLEN], log_dir[FILENAME_MAX];
snprintf(log_dir, sizeof(log_dir), "%s/%s", LOG_DIR, InstalledPkg);
***************
*** 436,443 ****
--- 445,503 ----
read_plist(&plist, fp);
fclose(fp);
+ /*
+ * Given that we are building the package in-situ we need
+ * to check the package contents definition of the installed
+ * package instead of relying upon command line arguments
+ * for install, post-install etc. scripts.
+ */
+
+ if ( (plistp = find_plist(&plist, PLIST_FILE)) != NULL ){
+ is_a_special_file(plistp->name);
+ while ( (plistp = find_plist_next(&plist, PLIST_FILE)) != NULL ){
+ is_a_special_file(plistp->name);
+ }
+ }
+
make_dist(homedir, pkg, suf, &plist);
free_plist(&plist);
return TRUE;
+ }
+
+ /*
+ * Check the filename received from the plist and check if
+ * it matches one of the 'special' files. If so, then set
+ * the appropriate variable to a non-NULL pointer value
+ */
+
+ void
+ is_a_special_file(const char *filename){
+
+ char fake_argument[10]; /* To provide a ptr to pass */
+
+ if ( strcmp(INSTALL_FNAME, filename) == 0
+ && Install == NULL)
+ Install = fake_argument;
+ if ( strcmp(POST_INSTALL_FNAME, filename) == 0
+ && PostInstall == NULL)
+ PostInstall = fake_argument;
+ if ( strcmp(DEINSTALL_FNAME, filename) == 0
+ && DeInstall == NULL)
+ DeInstall = fake_argument;
+ if ( strcmp(POST_DEINSTALL_FNAME, filename) == 0
+ && PostDeInstall == NULL )
+ PostDeInstall = fake_argument;
+ if ( strcmp(REQUIRE_FNAME, filename) == 0
+ && Require == NULL )
+ Require = fake_argument;
+ if ( strcmp(DISPLAY_FNAME, filename) == 0
+ && Display == NULL )
+ Display = fake_argument;
+ if ( strcmp(MTREE_FNAME, filename) == 0
+ && Mtree == NULL )
+ Mtree = fake_argument;
+
+ return;
+
}
--------------5C0AF1159856F2BC17D7793D--
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200203081320.g28DK2G66202>
