Skip to content

Commit

Permalink
Support PKG_INSTALL_DIR and redo pkg_install setup.
Browse files Browse the repository at this point in the history
Bring in the latest pkgdb.c from pkg_install and greatly simplify it so
that we only have functions for setting and getting the PKG_DBDIR path.
None of the other database functions were ever used and could have
caused issues depending on if db185 was present.

Add a new setup_pkg_install() which configures pkg_install, and
determine PKG_DBDIR only from pkg_admin, removing the possibility of
defaulting to a compiled-in default that could be completely wrong.

Add support for a PKG_INSTALL_DIR environment variable that allows a
different pkg_install suite to be used.  This is primarily useful for
the pkgin test suite.
  • Loading branch information
Jonathan Perkin committed Apr 25, 2018
1 parent f3b9d98 commit 84dddcf
Show file tree
Hide file tree
Showing 11 changed files with 130 additions and 374 deletions.
5 changes: 1 addition & 4 deletions Makefile.in
Expand Up @@ -6,7 +6,7 @@ VERSION= @PACKAGE_VERSION@
SRCS= main.c summary.c tools.c pkgindb.c depends.c actions.c \
pkglist.c download.c order.c impact.c autoremove.c fsops.c \
pkgindb_queries.c pkg_str.c sqlite_callbacks.c selection.c \
pkg_check.c pkg_infos.c preferred.c
pkg_check.c pkg_infos.c pkg_install.c preferred.c
# included from libinstall
SRCS+= automatic.c dewey.c fexec.c global.c opattern.c pkgdb.c var.c
SRCS+= xwrapper.c
Expand Down Expand Up @@ -36,7 +36,6 @@ LOCALBASE?= @prefix@
BINDIR?= ${LOCALBASE}/bin
PKG_SYSCONFDIR?= ${LOCALBASE}/etc
VARBASE?= /var
PKG_DBDIR?= ${VARBASE}/db/pkg
.if !defined(PKGMANDIR)
MANDIR= ${LOCALBASE}/share/man
.endif
Expand Down Expand Up @@ -78,8 +77,6 @@ CPPFLAGS+= -g

CPPFLAGS+= -DLOCALBASE=\"${LOCALBASE}\" \
-DPKG_SYSCONFDIR=\"${PKG_SYSCONFDIR}\" \
-DPKG_DBDIR="\"${PKG_DBDIR}\"" \
-DDEF_LOG_DIR="\"${PKG_DBDIR}\"" \
-DPKGIN_DBDIR=\"${PKGIN_DBDIR}\" \
-DPKGTOOLS=\"${PKGTOOLS}\"

Expand Down
6 changes: 3 additions & 3 deletions actions.c
Expand Up @@ -250,7 +250,7 @@ do_pkg_remove(Plisthead *removehead)
#ifndef DEBUG
if (!verbosity)
log_tag(MSG_REMOVING, premove->depend);
if (fexec(PKG_DELETE, verb_flag("-f"), premove->depend, NULL)
if (fexec(pkg_delete, verb_flag("-f"), premove->depend, NULL)
!= EXIT_SUCCESS)
err_count++;
#endif
Expand Down Expand Up @@ -299,7 +299,7 @@ do_pkg_install(Plisthead *installhead)
/* there was a previous version, record +PRESERVE path */
if (pinstall->old != NULL)
snprintf(preserve, BUFSIZ, "%s/%s/%s",
PKG_DBDIR, pinstall->old, PRESERVE_FNAME);
pkgdb_get_dir(), pinstall->old, PRESERVE_FNAME);

/* are we upgrading pkg_install ? */
if (pi_upgrade) { /* set in order.c */
Expand All @@ -320,7 +320,7 @@ do_pkg_install(Plisthead *installhead)
/* every other package */
pflags = verb_flag("-D");

if (fexec(PKG_ADD, pflags, pkgpath, NULL) == EXIT_FAILURE)
if (fexec(pkg_add, pflags, pkgpath, NULL) == EXIT_FAILURE)
rc = EXIT_FAILURE;
#endif
} /* installation loop */
Expand Down
2 changes: 1 addition & 1 deletion autoremove.c
Expand Up @@ -84,7 +84,7 @@ pkgin_autoremove()
}
}
snprintf(preserve, BUFSIZ, "%s/%s/%s",
PKG_DBDIR, pkglist->full, PRESERVE_FNAME);
pkgdb_get_dir(), pkglist->full, PRESERVE_FNAME);
/* is or a dependency or a preserved package */
if (is_keep_dep || access(preserve, F_OK) != -1)
continue;
Expand Down
14 changes: 2 additions & 12 deletions external/lib.h
Expand Up @@ -422,18 +422,8 @@ void append_plist(package_t *, FILE *);
int delete_package(Boolean, Boolean, package_t *, Boolean);

/* Package Database */
int pkgdb_open(int);
void pkgdb_close(void);
int pkgdb_store(const char *, const char *);
char *pkgdb_retrieve(const char *);
int pkgdb_dump(void);
int pkgdb_remove(const char *);
int pkgdb_remove_pkg(const char *);
char *pkgdb_refcount_dir(void);
char *_pkgdb_getPKGDB_FILE(char *, unsigned);
const char *_pkgdb_getPKGDB_DIR(void);
void _pkgdb_setPKGDB_DIR(const char *);

const char *pkgdb_get_dir(void);
void pkgdb_set_dir(const char *, int);
char *pkgdb_pkg_file(const char *, const char *);

/* List of packages functions */
Expand Down

0 comments on commit 84dddcf

Please sign in to comment.