summaryrefslogtreecommitdiff
path: root/src/database.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2008-04-22 06:04:20 +0000
committerTimo Teras <timo.teras@iki.fi>2008-04-22 06:04:20 +0000
commit384c2f1d94282ff5564a5f6c5ab9e51c975f83a6 (patch)
tree30c7225064e95641e31b8e3ce5934773678253ee /src/database.c
parent823283edca0d8403742999917a4ff0698ad641cb (diff)
downloadapk-tools-384c2f1d94282ff5564a5f6c5ab9e51c975f83a6.tar.gz
apk-tools-384c2f1d94282ff5564a5f6c5ab9e51c975f83a6.tar.bz2
apk-tools-384c2f1d94282ff5564a5f6c5ab9e51c975f83a6.tar.xz
apk-tools-384c2f1d94282ff5564a5f6c5ab9e51c975f83a6.zip
Preserve uid and gid. Quiet flag to print dots on progress.
Diffstat (limited to 'src/database.c')
-rw-r--r--src/database.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/database.c b/src/database.c
index fa3f8c6..174b6f6 100644
--- a/src/database.c
+++ b/src/database.c
@@ -108,8 +108,10 @@ static struct apk_db_dir *apk_db_dir_ref(struct apk_database *db,
if (dir->parent != NULL)
apk_db_dir_ref(db, dir->parent, create_dir);
db->installed.stats.dirs++;
- if (create_dir && dir->mode)
+ if (create_dir && dir->mode) {
mkdir(dir->dirname, dir->mode);
+ chown(dir->dirname, dir->uid, dir->gid);
+ }
}
dir->refs++;
@@ -666,6 +668,7 @@ static int apk_db_install_archive_entry(struct apk_archive_entry *ae,
struct apk_database *db = ctx->db;
struct apk_package *pkg = ctx->pkg;
apk_blob_t name = APK_BLOB_STR(ae->name);
+ struct apk_db_dir *dir;
struct apk_db_file *file;
const char *p;
int r = 0, type;
@@ -722,7 +725,10 @@ static int apk_db_install_archive_entry(struct apk_archive_entry *ae,
} else {
if (name.ptr[name.len-1] == '/')
name.len--;
- apk_db_dir_get(db, name)->mode = 0777 & ae->mode;
+ dir = apk_db_dir_get(db, name);
+ dir->mode = ae->mode & 07777;
+ dir->uid = ae->uid;
+ dir->gid = ae->gid;
}
return r;
@@ -817,9 +823,12 @@ int apk_db_install_pkg(struct apk_database *db,
r = apk_pkg_run_script(newpkg, db->root,
(oldpkg == NULL) ?
APK_SCRIPT_POST_INSTALL : APK_SCRIPT_POST_UPGRADE);
- if (r != 0)
+ if (r != 0) {
apk_error("%s-%s: Failed to execute post-install/upgrade script",
newpkg->name->name, newpkg->version);
+ } else if (apk_quiet) {
+ write(STDOUT_FILENO, ".", 1);
+ }
return r;
err_close: