From 3bcb98c1002bcb1661165679e2df945d690667c3 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Thu, 11 May 2023 05:03:38 -0400 Subject: opk/write: Add root directories to inner archives --- 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; } -- cgit v0.9.1