PERFORCE change 129667 for review
Garrett Cooper
gcooper at FreeBSD.org
Tue Nov 27 18:15:42 PST 2007
http://perforce.freebsd.org/chv.cgi?CH=129667
Change 129667 by gcooper at shiina-ibook on 2007/11/28 02:14:59
Some style(9) changes.
Affected files ...
.. //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/libpkg/pkg_db.c#2 edit
.. //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/libpkg/pkg_db_freebsd.c#2 edit
Differences ...
==== //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/libpkg/pkg_db.c#2 (text+ko) ====
@@ -63,9 +63,8 @@
struct stat sb;
db = malloc(sizeof(struct pkg_db));
- if (!db) {
+ if (!db)
return NULL;
- }
/* Make a relative path into an absolute path */
if (base == NULL) {
@@ -151,17 +150,14 @@
pkg_db_install_pkg_action(struct pkg_db *db, struct pkg *pkg,
const char *prefix, int reg, int scripts, int fake, pkg_db_action *action)
{
- if (!db) {
+ if (db == NULL)
return -1;
- }
- if (!pkg) {
+ if (pkg == NULL)
return -1;
- }
- if (!db->pkg_install) {
- return -1;
- }
+ if (db->pkg_install == NULL)
+ return -1;
if (action == NULL)
return -1;
@@ -176,13 +172,11 @@
int
pkg_db_is_installed(struct pkg_db *db, struct pkg *pkg)
{
- if (!db) {
+ if (db == NULL)
return -1;
- }
- if (!db->pkg_is_installed) {
+ if (db->pkg_is_installed == NULL)
return -1;
- }
return db->pkg_is_installed(db, pkg);
}
@@ -291,11 +285,10 @@
int
pkg_db_free(struct pkg_db *db)
{
- if (!db) {
+ if (db == NULL)
return -1;
- }
- if (db->db_base)
+ if (db->db_base != NULL)
free(db->db_base);
free(db);
@@ -353,7 +346,7 @@
file = pkg_get_next_file(pkg);
while (file != NULL) {
- if (strcmp((const char *)filename, pkgfile_get_name(file)) ==0){
+ if (strcmp((const char *)filename, pkgfile_get_name(file)) == 0) {
pkgfile_free(file);
return 0;
}
@@ -365,4 +358,4 @@
/**
* @}
- */+ */
==== //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/libpkg/pkg_db_freebsd.c#2 (text+ko) ====
@@ -172,7 +172,8 @@
* @param pkg The package to install
* @param prefix If non-NULL this will override the packages prefix
* @param reg If true register the package in the database
- * @param scripts If true will run the packafes scripts
+ * @param exec_pkg_scripts If true will execute the package scripts
+ * specified by the pkg_script_pre and pkg_script_post variables.
* @param fake Should we actually install the package or
* just report what would have happened
* @param pkg_action A function to call when an action takes place
@@ -182,7 +183,7 @@
*/
static int
freebsd_install_pkg_action(struct pkg_db *db, struct pkg *pkg,
- const char *prefix, int reg, int scripts, int fake,
+ const char *prefix, int reg, int exec_pkg_scripts, int fake,
pkg_db_action *pkg_action)
{
struct pkg_install_data install_data;
@@ -192,8 +193,9 @@
assert(pkg != NULL);
assert(pkg_action != NULL);
- if (getwd(cwd) == NULL)
+ if (getwd(cwd) == NULL) {
return -1;
+ }
/* Set the package environment */
if (prefix == NULL) {
@@ -210,7 +212,7 @@
/* Run +REQUIRE */
pkg_action(PKG_DB_INFO, "Running ... for %s..", pkg_get_name(pkg));
- if (!fake) {
+ if (fake == 0) {
/** @todo Check if the force flag is set */
if (pkg_run_script(pkg, prefix, pkg_script_require) != 0) {
chdir(cwd);
@@ -219,10 +221,10 @@
}
/* Run Pre-install */
- pkg_action(PKG_DB_INFO, "Running pre-install for %s..",
+ pkg_action(PKG_DB_INFO, "Running pre-install script for %s..",
pkg_get_name(pkg));
- if (!fake && scripts)
+ if (fake == 0 && exec_pkg_scripts != 0)
pkg_run_script(pkg, prefix, pkg_script_pre);
/* Do the Install */
@@ -231,6 +233,7 @@
install_data.last_dir = NULL;
install_data.last_file[0] = '\0';
install_data.directory[0] = '\0';
+
if (pkg_install(pkg, prefix, reg, pkg_action, &install_data,
freebsd_do_chdir, freebsd_install_file, freebsd_do_exec,
freebsd_register) != 0) {
@@ -241,17 +244,24 @@
/* Extract the +MTREE */
pkg_action(PKG_DB_INFO, "Running mtree for %s..", pkg_get_name(pkg));
- if (!fake)
+ if (fake == 0)
pkg_run_script(pkg, prefix, pkg_script_mtree);
/* Run post-install */
- pkg_action(PKG_DB_INFO, "Running post-install for %s..",
+ pkg_action(PKG_DB_INFO, "Running post-install script for %s..",
pkg_get_name(pkg));
- if (!fake && scripts)
+ if (fake == 0 && exec_pkg_scripts != 0)
pkg_run_script(pkg, prefix, pkg_script_post);
- /** @todo Display contents of \@display */
+ /*
+ * Andrew Turner: @todo Display contents of \@display
+ *
+ * Garrett Cooper: Looking at the original pkg_install,
+ * this doesn't appear to be implemented other than just
+ * as a printf statement. What is the purpose of this
+ * directive?
+ */
chdir(cwd);
return 0;
@@ -273,9 +283,9 @@
assert(pkg != NULL);
asprintf(&dir, "%s" DB_LOCATION "/%s", db->db_base, pkg_get_name(pkg));
- if (!dir) {
- return -1;
- }
+ if (dir == 0)
+ return -1;
+
pkg_remove_extra_slashes(dir);
is_installed = -1;
@@ -290,13 +300,20 @@
/* Does the package have an origin and if so is that origin installed */
if (pkg_get_origin(pkg) != NULL) {
+
pkgs = freebsd_get_installed_match(db, pkg_match_by_origin,
0, (const void *)pkg_get_origin(pkg));
- if (pkgs != NULL && pkgs[0] != NULL)
+
+ if (pkgs != NULL && pkgs[0] != NULL) {
is_installed = 0;
+ }
+
pkg_list_free(pkgs);
+
}
+
return is_installed;
+
}
/**
@@ -319,13 +336,16 @@
assert(db->db_base != NULL);
asprintf(&dir, "%s" DB_LOCATION, db->db_base);
- if (!dir)
- return NULL;
+
+ if (dir == NULL)
+ return NULL;
+
pkg_remove_extra_slashes(dir);
d = opendir(dir);
free(dir);
- if (!d)
- return NULL;
+
+ if (d == NULL)
+ return NULL;
packages_size = sizeof(char *);
packages = malloc(packages_size);
@@ -340,12 +360,15 @@
if (de->d_name[0] == '.' || de->d_type != DT_DIR)
continue;
+
asprintf(&dir, "%s" DB_LOCATION "/%s",
db->db_base, de->d_name);
pkg_remove_extra_slashes(dir);
pkg = pkg_new_freebsd_installed(de->d_name, dir);
+
if (match(pkg, data) == 0) {
+
packages_size += sizeof(char *);
packages = realloc(packages, packages_size);
packages[packages_pos] = pkg;
@@ -355,6 +378,7 @@
/* Stop after count packages */
if (count != 0 && packages_pos == count + 1)
break;
+
} else
pkg_free(pkg);
free(dir);
@@ -383,7 +407,7 @@
* @return -1 on fatal error
*/
static int
-freebsd_deinstall_pkg(struct pkg_db *db, struct pkg *the_pkg, int scripts,
+freebsd_deinstall_pkg(struct pkg_db *db, struct pkg *the_pkg, int exec_pkg_scripts,
int fake, int force, int clean_dirs, pkg_db_action *pkg_action)
{
struct pkg_install_data deinstall_data;
@@ -393,8 +417,8 @@
assert(db != NULL);
assert(the_pkg != NULL);
- /* Get the real package. The one supplyed may be an empty one */
- /** @todo Check if the package suplyed is a valid package or not */
+ /* Get the real package. The one supplied may be an empty one */
+ /** @todo Check if the package supplied is valid or not */
real_pkg = freebsd_get_package(db, pkg_get_name(the_pkg));
/* Check if the package is installed */
if (real_pkg == NULL) {
@@ -440,7 +464,7 @@
* There is a sligntly different
* message when the force flag is set
*/
- if (force) {
+ if (force != 0) {
pkg_action(PKG_DB_INFO,
"package '%s' is required by these other packages "
"and may not be deinstalled (but I'll delete it "
@@ -454,11 +478,11 @@
free(buf);
/* Only return when the not being forced to */
- if (!force)
+ if (force != 0)
return -1;
}
- if (!fake && scripts) {
+ if (fake == 0 && exec_pkg_scripts != NULL) {
if (pkg_run_script(real_pkg, NULL,
pkg_script_require_deinstall) != 0 && !force) {
/* XXX */
@@ -511,7 +535,7 @@
return -1;
}
- if (!fake && scripts) {
+ if (fake == 0 && exec_pkg_scripts == 1) {
/** @todo Run +POST-DEINSTALL <pkg-name>/+DEINSTALL <pkg-name> POST-DEINSTALL */
if (pkg_run_script(real_pkg, NULL, pkg_script_post_deinstall)
!= 0 && !force) {
More information about the p4-projects
mailing list