1 diff -u -r ../dpkg-1.17.25/src/archives.c ./src/archives.c
2 --- ../dpkg-1.17.25/src/archives.c 2015-04-09 17:40:47.000000000 -0400
3 +++ ./src/archives.c 2015-07-09 20:56:04.604894782 -0400
5 namenode->statoverride->uid,
6 namenode->statoverride->gid,
7 namenode->statoverride->mode);
9 if (fchown(fd, st->uid, st->gid))
10 ohshite(_("error setting ownership of `%.255s'"), te->name);
12 if (fchmod(fd, st->mode & ~S_IFMT))
13 ohshite(_("error setting permissions of `%.255s'"), te->name);
16 return; /* Already handled using the file descriptor. */
18 if (te->type == TAR_FILETYPE_SYMLINK) {
20 if (lchown(path, st->uid, st->gid))
21 ohshite(_("error setting ownership of symlink `%.255s'"), path);
25 if (chown(path, st->uid, st->gid))
26 ohshite(_("error setting ownership of `%.255s'"), path);
28 if (chmod(path, st->mode & ~S_IFMT))
29 ohshite(_("error setting permissions of `%.255s'"), path);
31 @@ -1148,14 +1154,18 @@
32 varbuf_end_str(&symlinkfn);
33 if (symlink(symlinkfn.buf,fnametmpvb.buf))
34 ohshite(_("unable to make backup symlink for `%.255s'"), ti->name);
36 if (lchown(fnametmpvb.buf,stab.st_uid,stab.st_gid))
37 ohshite(_("unable to chown backup symlink for `%.255s'"), ti->name);
39 tarobject_set_se_context(fnamevb.buf, fnametmpvb.buf, stab.st_mode);
41 debug(dbg_eachfiledetail, "tarobject nondirectory, 'link' backup");
42 if (link(fnamevb.buf,fnametmpvb.buf))
43 - ohshite(_("unable to make backup link of `%.255s' before installing new version"),
45 + /* Termux modification: Try with rename(2) for systems not supporting hardlinks. */
46 + if (rename(fnamevb.buf,fnametmpvb.buf))
47 + ohshite(_("unable to make backup link of `%.255s' before installing new version"),