xbps-bin: improve def unpack cb to print more meaningful messages.
This commit is contained in:
parent
b4f202f89f
commit
5e0b06dc00
@ -34,12 +34,11 @@ unpack_progress_cb_verbose(const struct xbps_unpack_cb_data *xpd, void *cbdata)
|
|||||||
{
|
{
|
||||||
(void)cbdata;
|
(void)cbdata;
|
||||||
|
|
||||||
if (xpd->entry == NULL || xpd->entry_is_metadata)
|
if (xpd->entry == NULL || xpd->entry_total_count <= 0)
|
||||||
return;
|
|
||||||
else if (xpd->entry_size <= 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
printf("Extracted %sfile `%s' (%" PRIi64 " bytes)\n",
|
printf("%s: unpacked %sfile `%s' (%" PRIi64 " bytes)\n",
|
||||||
|
xpd->pkgver,
|
||||||
xpd->entry_is_conf ? "configuration " : "", xpd->entry,
|
xpd->entry_is_conf ? "configuration " : "", xpd->entry,
|
||||||
xpd->entry_size);
|
xpd->entry_size);
|
||||||
}
|
}
|
||||||
@ -49,11 +48,10 @@ unpack_progress_cb(const struct xbps_unpack_cb_data *xpd, void *cbdata)
|
|||||||
{
|
{
|
||||||
(void)cbdata;
|
(void)cbdata;
|
||||||
|
|
||||||
if (xpd->entry == NULL || xpd->entry_is_metadata)
|
if (xpd->entry_total_count <= 0)
|
||||||
return;
|
|
||||||
else if (xpd->entry_size <= 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
printf("Extracting `%s'...\n", xpd->entry);
|
printf("%s: unpacked %zd of %zd files...\n",
|
||||||
|
xpd->pkgver, xpd->entry_extract_count, xpd->entry_total_count);
|
||||||
printf("\033[1A\033[K");
|
printf("\033[1A\033[K");
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
*/
|
*/
|
||||||
#define XBPS_PKGINDEX_VERSION "1.4"
|
#define XBPS_PKGINDEX_VERSION "1.4"
|
||||||
|
|
||||||
#define XBPS_API_VERSION "20120506"
|
#define XBPS_API_VERSION "20120506-1"
|
||||||
#define XBPS_VERSION "0.16"
|
#define XBPS_VERSION "0.16"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -403,6 +403,12 @@ struct xbps_fetch_cb_data {
|
|||||||
* The \a cookie member can be used to pass user supplied data.
|
* The \a cookie member can be used to pass user supplied data.
|
||||||
*/
|
*/
|
||||||
struct xbps_unpack_cb_data {
|
struct xbps_unpack_cb_data {
|
||||||
|
/**
|
||||||
|
* @var pkgver
|
||||||
|
*
|
||||||
|
* Package name/version string of package being unpacked.
|
||||||
|
*/
|
||||||
|
const char *pkgver;
|
||||||
/**
|
/**
|
||||||
* @var entry
|
* @var entry
|
||||||
*
|
*
|
||||||
@ -427,12 +433,6 @@ struct xbps_unpack_cb_data {
|
|||||||
* Total number of entries in package.
|
* Total number of entries in package.
|
||||||
*/
|
*/
|
||||||
ssize_t entry_total_count;
|
ssize_t entry_total_count;
|
||||||
/**
|
|
||||||
* @var entry_is_metadata
|
|
||||||
*
|
|
||||||
* If true "entry" is a metadata file.
|
|
||||||
*/
|
|
||||||
bool entry_is_metadata;
|
|
||||||
/**
|
/**
|
||||||
* @var entry_is_conf
|
* @var entry_is_conf
|
||||||
*
|
*
|
||||||
|
@ -185,8 +185,6 @@ void HIDDEN xbps_set_cb_fetch(off_t, off_t, off_t, const char *,
|
|||||||
bool, bool, bool);
|
bool, bool, bool);
|
||||||
void HIDDEN xbps_set_cb_state(xbps_state_t, int, const char *,
|
void HIDDEN xbps_set_cb_state(xbps_state_t, int, const char *,
|
||||||
const char *, const char *, ...);
|
const char *, const char *, ...);
|
||||||
void HIDDEN xbps_set_cb_unpack(const char *, int64_t, ssize_t,
|
|
||||||
ssize_t, bool, bool);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
|
@ -99,26 +99,3 @@ xbps_set_cb_state(xbps_state_t state,
|
|||||||
if (buf != NULL)
|
if (buf != NULL)
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HIDDEN
|
|
||||||
xbps_set_cb_unpack(const char *entry,
|
|
||||||
int64_t entry_size,
|
|
||||||
ssize_t entry_extract_count,
|
|
||||||
ssize_t entry_total_count,
|
|
||||||
bool entry_is_metadata,
|
|
||||||
bool entry_is_conf)
|
|
||||||
{
|
|
||||||
const struct xbps_handle *xhp = xbps_handle_get();
|
|
||||||
struct xbps_unpack_cb_data xucd;
|
|
||||||
|
|
||||||
if (xhp->unpack_cb == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
xucd.entry = entry;
|
|
||||||
xucd.entry_size = entry_size;
|
|
||||||
xucd.entry_extract_count = entry_extract_count;
|
|
||||||
xucd.entry_total_count = entry_total_count;
|
|
||||||
xucd.entry_is_metadata = entry_is_metadata;
|
|
||||||
xucd.entry_is_conf = entry_is_conf;
|
|
||||||
(*xhp->unpack_cb)(&xucd, xhp->unpack_cb_data);
|
|
||||||
}
|
|
||||||
|
@ -240,9 +240,9 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
|||||||
* Prepare unpack callback ops.
|
* Prepare unpack callback ops.
|
||||||
*/
|
*/
|
||||||
if (xucd != NULL) {
|
if (xucd != NULL) {
|
||||||
|
xucd->pkgver = pkgver;
|
||||||
xucd->entry = entry_pname;
|
xucd->entry = entry_pname;
|
||||||
xucd->entry_size = archive_entry_size(entry);
|
xucd->entry_size = archive_entry_size(entry);
|
||||||
xucd->entry_is_metadata = false;
|
|
||||||
xucd->entry_is_conf = false;
|
xucd->entry_is_conf = false;
|
||||||
}
|
}
|
||||||
if (strcmp("./INSTALL", entry_pname) == 0) {
|
if (strcmp("./INSTALL", entry_pname) == 0) {
|
||||||
@ -275,11 +275,6 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
nmetadata++;
|
nmetadata++;
|
||||||
if (xucd != NULL) {
|
|
||||||
xucd->entry_is_metadata = true;
|
|
||||||
xucd->entry_extract_count++;
|
|
||||||
(*xhp->unpack_cb)(xucd, xhp->unpack_cb_data);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
} else if (strcmp("./REMOVE", entry_pname) == 0) {
|
} else if (strcmp("./REMOVE", entry_pname) == 0) {
|
||||||
@ -289,11 +284,6 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
|||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
nmetadata++;
|
nmetadata++;
|
||||||
if (xucd != NULL) {
|
|
||||||
xucd->entry_is_metadata = true;
|
|
||||||
xucd->entry_extract_count++;
|
|
||||||
(*xhp->unpack_cb)(xucd, xhp->unpack_cb_data);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
} else if (strcmp("./files.plist", entry_pname) == 0) {
|
} else if (strcmp("./files.plist", entry_pname) == 0) {
|
||||||
@ -308,11 +298,6 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
nmetadata++;
|
nmetadata++;
|
||||||
if (xucd != NULL) {
|
|
||||||
xucd->entry_is_metadata = true;
|
|
||||||
xucd->entry_extract_count++;
|
|
||||||
(*xhp->unpack_cb)(xucd, xhp->unpack_cb_data);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
} else if (strcmp("./props.plist", entry_pname) == 0) {
|
} else if (strcmp("./props.plist", entry_pname) == 0) {
|
||||||
@ -328,11 +313,6 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
nmetadata++;
|
nmetadata++;
|
||||||
if (xucd != NULL) {
|
|
||||||
xucd->entry_is_metadata = true;
|
|
||||||
xucd->entry_extract_count++;
|
|
||||||
(*xhp->unpack_cb)(xucd, xhp->unpack_cb_data);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -360,10 +340,10 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
|||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Compute total entries in progress data, if set.
|
* Compute total entries in progress data, if set.
|
||||||
* total_entries = metadata + files + conf_files + links.
|
* total_entries = files + conf_files + links.
|
||||||
*/
|
*/
|
||||||
if (xucd != NULL) {
|
if (xucd != NULL) {
|
||||||
xucd->entry_total_count = nmetadata;
|
xucd->entry_total_count = 0;
|
||||||
array = prop_dictionary_get(filesd, "files");
|
array = prop_dictionary_get(filesd, "files");
|
||||||
xucd->entry_total_count +=
|
xucd->entry_total_count +=
|
||||||
(ssize_t)prop_array_count(array);
|
(ssize_t)prop_array_count(array);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user