From 9fbdefb99586f584cbfe44c97d81cef8988769c2 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Thu, 9 Jul 2015 21:04:45 -0400 Subject: [PATCH] dpkg: Fallback to rename(2) instead of link(2) for systems not supporting hard linking (android m) --- packages/dpkg/archives_dont_chown.patch | 22 ++++++++++++++++------ packages/dpkg/lib-dpkg-atomic-file.c.patch | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 packages/dpkg/lib-dpkg-atomic-file.c.patch diff --git a/packages/dpkg/archives_dont_chown.patch b/packages/dpkg/archives_dont_chown.patch index f30911494..cc45f03d0 100644 --- a/packages/dpkg/archives_dont_chown.patch +++ b/packages/dpkg/archives_dont_chown.patch @@ -1,7 +1,7 @@ -diff -u -r ../dpkg-1.17.10/src/archives.c ./src/archives.c ---- ../dpkg-1.17.10/src/archives.c 2014-06-05 19:56:33.000000000 +0200 -+++ ./src/archives.c 2014-06-06 03:46:40.636882807 +0200 -@@ -354,8 +354,10 @@ +diff -u -r ../dpkg-1.17.25/src/archives.c ./src/archives.c +--- ../dpkg-1.17.25/src/archives.c 2015-04-09 17:40:47.000000000 -0400 ++++ ./src/archives.c 2015-07-09 20:56:04.604894782 -0400 +@@ -359,8 +359,10 @@ namenode->statoverride->uid, namenode->statoverride->gid, namenode->statoverride->mode); @@ -12,7 +12,7 @@ diff -u -r ../dpkg-1.17.10/src/archives.c ./src/archives.c if (fchmod(fd, st->mode & ~S_IFMT)) ohshite(_("error setting permissions of `%.255s'"), te->name); -@@ -468,11 +470,15 @@ +@@ -472,11 +474,15 @@ return; /* Already handled using the file descriptor. */ if (te->type == TAR_FILETYPE_SYMLINK) { @@ -28,7 +28,7 @@ diff -u -r ../dpkg-1.17.10/src/archives.c ./src/archives.c if (chmod(path, st->mode & ~S_IFMT)) ohshite(_("error setting permissions of `%.255s'"), path); } -@@ -1142,8 +1148,10 @@ +@@ -1148,14 +1154,18 @@ varbuf_end_str(&symlinkfn); if (symlink(symlinkfn.buf,fnametmpvb.buf)) ohshite(_("unable to make backup symlink for `%.255s'"), ti->name); @@ -39,3 +39,13 @@ diff -u -r ../dpkg-1.17.10/src/archives.c ./src/archives.c tarobject_set_se_context(fnamevb.buf, fnametmpvb.buf, stab.st_mode); } else { debug(dbg_eachfiledetail, "tarobject nondirectory, 'link' backup"); + if (link(fnamevb.buf,fnametmpvb.buf)) +- ohshite(_("unable to make backup link of `%.255s' before installing new version"), +- ti->name); ++ /* Termux modification: Try with rename(2) for systems not supporting hardlinks. */ ++ if (rename(fnamevb.buf,fnametmpvb.buf)) ++ ohshite(_("unable to make backup link of `%.255s' before installing new version"), ++ ti->name); + } + } + diff --git a/packages/dpkg/lib-dpkg-atomic-file.c.patch b/packages/dpkg/lib-dpkg-atomic-file.c.patch new file mode 100644 index 000000000..0a5db775e --- /dev/null +++ b/packages/dpkg/lib-dpkg-atomic-file.c.patch @@ -0,0 +1,18 @@ +diff -u -r ../dpkg-1.17.25/lib/dpkg/atomic-file.c ./lib/dpkg/atomic-file.c +--- ../dpkg-1.17.25/lib/dpkg/atomic-file.c 2015-04-09 17:40:47.000000000 -0400 ++++ ./lib/dpkg/atomic-file.c 2015-07-08 22:18:48.766580146 -0400 +@@ -90,8 +90,12 @@ + + if (unlink(name_old) && errno != ENOENT) + ohshite(_("error removing old backup file '%s'"), name_old); +- if (link(file->name, name_old) && errno != ENOENT) +- ohshite(_("error creating new backup file '%s'"), name_old); ++ if (link(file->name, name_old) && errno != ENOENT) { ++ /* Termux modification: Try with rename(2) for systems not supporting hardlinks. */ ++ if (rename(file->name, name_old)) { ++ ohshite(_("error creating new backup file '%s'"), name_old); ++ } ++ } + + free(name_old); + }