summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2023-05-11 05:03:38 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2023-05-11 05:03:38 (EDT)
commit3bcb98c1002bcb1661165679e2df945d690667c3 (patch)
tree97d77d4de592292ce54a7064d45ea3299c9d85e2
parent7b3313e21cf2011761a4d8658713a95659540318 (diff)
opk/write: Add root directories to inner archives
-rw-r--r--src/opk/write.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/opk/write.c b/src/opk/write.c
index 2ef052f..44629db 100644
--- a/src/opk/write.c
+++ b/src/opk/write.c
@@ -257,6 +257,11 @@ _opkg_opk_opk_build_inner_archive(struct opkg_opk_opk *opk,
{
FILE *fp;
struct opkg_opk_dirent dirent;
+ struct stat st;
+ uid_t uid;
+ char *uname;
+ gid_t gid;
+ char *gname;
size_t written;
char *buffer;
size_t size;
@@ -296,6 +301,21 @@ _opkg_opk_opk_build_inner_archive(struct opkg_opk_opk *opk,
} else {
strcpy(opk->path, opk->data_dir);
}
+ if (stat(opk->path, &st) != 0) {
+ fprintf(stderr, _("Error: Failed to stat \"%s\"\n"), opk->path);
+ goto err3;
+ }
+ uid = st.st_uid;
+ uname = getpwuid(uid)->pw_name;
+ gid = st.st_gid;
+ gname = getgrgid(gid)->gr_name;
+ if (opkg_opk_ustar_write_header(opk->inner_ustar, &dirent,
+ st.st_mode & 0777, uid, uname, gid, gname, 0,
+ opk->mtime, 'd', NULL) != OPKG_OPK_OK) {
+ fputs(_("Error: Failed to write header\n"),
+ stderr);
+ goto err3;
+ }
if (_opkg_opk_opk_write_dir_read(opk, &dirent) != OPKG_OPK_OK) {
goto err3;
}