35#include "xbps_api_impl.h"
48 const char *tmpdir, *version;
49 const char *shells[] = {
55 char pkgname[XBPS_NAME_SIZE], *fpath;
63 xbps_dbg_printf(
"%s: not executing %s "
64 "install/remove action.\n", pkgver, action);
68 if (strcmp(xhp->
rootdir,
"/") == 0) {
69 tmpdir = getenv(
"TMPDIR");
75 fpath = strdup(
".xbps-script-XXXXXX");
79 if (chdir(xhp->
rootdir) == -1) {
85 if ((fd = mkstemp(fpath)) == -1) {
87 xbps_dbg_printf(
"%s: mkstemp %s\n",
88 __func__, strerror(errno));
92 ret = write(fd, blob, blobsiz);
95 xbps_dbg_printf(
"%s: write %s\n",
96 __func__, strerror(errno));
116 for (i = 0; shells[i] != NULL; i++) {
117 if (access(shells[i], X_OK) == 0) {
121 if (shells[i] != NULL) {
122 rv = xbps_file_exec(xhp, shells[i], fpath, action, pkgname, version,
123 update ?
"yes" :
"no",
125 }
else if (access(
"/bin/busybox", X_OK) == 0) {
126 rv = xbps_file_exec(xhp,
"/bin/busybox",
"sh", fpath, action, pkgname, version,
127 update ?
"yes" :
"no",
129 }
else if (access(
"/bin/busybox.static", X_OK) == 0) {
130 rv = xbps_file_exec(xhp,
"/bin/busybox.static",
"sh", fpath, action, pkgname, version,
131 update ?
"yes" :
"no",
153 const char *pkgver = NULL;
161 data = xbps_dictionary_get(d, script);
165 xbps_dictionary_get_cstring_nocopy(d,
"pkgver", &pkgver);
167 buf = xbps_data_data_nocopy(data);
168 buflen = xbps_data_size(data);
char rootdir[XBPS_MAXPATH]
Generic XBPS structure handler for initialization.
int xbps_pkg_exec_buffer(struct xbps_handle *xhp, const void *blob, const size_t blobsiz, const char *pkgver, const char *action, bool update)
int xbps_pkg_exec_script(struct xbps_handle *xhp, xbps_dictionary_t d, const char *script, const char *action, bool update)
char * xbps_xasprintf(const char *fmt,...) __attribute__((format(printf
bool xbps_pkg_name(char *dst, size_t len, const char *pkg)
const char * xbps_pkg_version(const char *pkg)