diff options
Diffstat (limited to 'meta/recipes-devtools/opkg')
| -rw-r--r-- | meta/recipes-devtools/opkg/opkg/add_uname_support.patch | 88 | ||||
| -rw-r--r-- | meta/recipes-devtools/opkg/opkg_svn.bb | 3 |
2 files changed, 90 insertions, 1 deletions
diff --git a/meta/recipes-devtools/opkg/opkg/add_uname_support.patch b/meta/recipes-devtools/opkg/opkg/add_uname_support.patch new file mode 100644 index 0000000000..0f627f1178 --- /dev/null +++ b/meta/recipes-devtools/opkg/opkg/add_uname_support.patch | |||
| @@ -0,0 +1,88 @@ | |||
| 1 | |||
| 2 | When updating packages on the target device we ideally want to match | ||
| 3 | user and group numbers from the existing file system. This patch encourages | ||
| 4 | opkg to lookup the uname/gname fields first and only use the hardcoded | ||
| 5 | numerical values if that fails. | ||
| 6 | |||
| 7 | Upstream-Status: Pending | ||
| 8 | |||
| 9 | RP 11/11/11 | ||
| 10 | |||
| 11 | Index: trunk/libbb/unarchive.c | ||
| 12 | =================================================================== | ||
| 13 | --- trunk.orig/libbb/unarchive.c 2011-11-11 15:52:59.761674091 +0000 | ||
| 14 | +++ trunk/libbb/unarchive.c 2011-11-11 17:04:56.501574419 +0000 | ||
| 15 | @@ -22,10 +22,13 @@ | ||
| 16 | #include <stdio.h> | ||
| 17 | #include <errno.h> | ||
| 18 | #include <stdlib.h> | ||
| 19 | +#include <stdbool.h> | ||
| 20 | #include <string.h> | ||
| 21 | #include <unistd.h> | ||
| 22 | #include <utime.h> | ||
| 23 | #include <libgen.h> | ||
| 24 | +#include <grp.h> | ||
| 25 | +#include <pwd.h> | ||
| 26 | |||
| 27 | #include "libbb.h" | ||
| 28 | |||
| 29 | @@ -436,6 +439,42 @@ | ||
| 30 | free(ar_entry); | ||
| 31 | } | ||
| 32 | |||
| 33 | +static char uname_cache[32] = ""; | ||
| 34 | +static uid_t uid_cache; | ||
| 35 | + | ||
| 36 | +static bool update_unamecache(char *uname) { | ||
| 37 | + struct passwd *passwd; | ||
| 38 | + if (!uname) | ||
| 39 | + return FALSE; | ||
| 40 | + if (!uname_cache[0] && strcmp(uname_cache, uname) == 0) | ||
| 41 | + return TRUE; | ||
| 42 | + passwd = getpwnam(uname); | ||
| 43 | + if (passwd) { | ||
| 44 | + uid_cache = passwd->pw_uid; | ||
| 45 | + strncpy(uname, uname_cache, 32); | ||
| 46 | + return TRUE; | ||
| 47 | + } | ||
| 48 | + return FALSE; | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | +static char gname_cache[32] = ""; | ||
| 52 | +static gid_t gid_cache; | ||
| 53 | + | ||
| 54 | +static bool update_gnamecache(char *gname) { | ||
| 55 | + struct group *group; | ||
| 56 | + if (!gname) | ||
| 57 | + return FALSE; | ||
| 58 | + if (!gname_cache[0] && strcmp(gname_cache, gname) == 0) | ||
| 59 | + return TRUE; | ||
| 60 | + group = getgrnam(gname); | ||
| 61 | + if (group) { | ||
| 62 | + gid_cache = group->gr_gid; | ||
| 63 | + strncpy(gname, gname_cache, 32); | ||
| 64 | + return TRUE; | ||
| 65 | + } | ||
| 66 | + return FALSE; | ||
| 67 | +} | ||
| 68 | + | ||
| 69 | |||
| 70 | static file_header_t * | ||
| 71 | get_header_tar(FILE *tar_stream) | ||
| 72 | @@ -515,8 +554,14 @@ | ||
| 73 | */ | ||
| 74 | tar_entry->mode = 07777 & strtol(tar.formated.mode, NULL, 8); | ||
| 75 | |||
| 76 | - tar_entry->uid = strtol(tar.formated.uid, NULL, 8); | ||
| 77 | - tar_entry->gid = strtol(tar.formated.gid, NULL, 8); | ||
| 78 | + if (update_unamecache(tar.formated.uname)) | ||
| 79 | + tar_entry->uid = uid_cache; | ||
| 80 | + else | ||
| 81 | + tar_entry->uid = strtol(tar.formated.uid, NULL, 8); | ||
| 82 | + if (update_gnamecache(tar.formated.gname)) | ||
| 83 | + tar_entry->gid = gid_cache; | ||
| 84 | + else | ||
| 85 | + tar_entry->gid = strtol(tar.formated.gid, NULL, 8); | ||
| 86 | tar_entry->size = strtol(tar.formated.size, NULL, 8); | ||
| 87 | tar_entry->mtime = strtol(tar.formated.mtime, NULL, 8); | ||
| 88 | |||
diff --git a/meta/recipes-devtools/opkg/opkg_svn.bb b/meta/recipes-devtools/opkg/opkg_svn.bb index 099a373f34..8f50f677bd 100644 --- a/meta/recipes-devtools/opkg/opkg_svn.bb +++ b/meta/recipes-devtools/opkg/opkg_svn.bb | |||
| @@ -11,13 +11,14 @@ RREPLACES_${PN} = "opkg-nogpg" | |||
| 11 | 11 | ||
| 12 | SRC_URI = "svn://opkg.googlecode.com/svn;module=trunk;proto=http \ | 12 | SRC_URI = "svn://opkg.googlecode.com/svn;module=trunk;proto=http \ |
| 13 | file://add_vercmp.patch \ | 13 | file://add_vercmp.patch \ |
| 14 | file://add_uname_support.patch \ | ||
| 14 | " | 15 | " |
| 15 | 16 | ||
| 16 | S = "${WORKDIR}/trunk" | 17 | S = "${WORKDIR}/trunk" |
| 17 | 18 | ||
| 18 | SRCREV = "625" | 19 | SRCREV = "625" |
| 19 | PV = "0.1.8+svnr${SRCPV}" | 20 | PV = "0.1.8+svnr${SRCPV}" |
| 20 | PR = "r2" | 21 | PR = "r3" |
| 21 | 22 | ||
| 22 | PACKAGES =+ "libopkg${PKGSUFFIX}-dev libopkg${PKGSUFFIX} update-alternatives-cworth${PKGSUFFIX}" | 23 | PACKAGES =+ "libopkg${PKGSUFFIX}-dev libopkg${PKGSUFFIX} update-alternatives-cworth${PKGSUFFIX}" |
| 23 | 24 | ||
