diff options
author | Thierry Vignaud <thierry.vignaud@gmail.com> | 2014-08-27 16:15:29 +0200 |
---|---|---|
committer | Thierry Vignaud <thierry.vignaud@gmail.com> | 2014-09-12 23:11:56 +0200 |
commit | 47f12646b34ad10fca581e8946ade89f18765483 (patch) | |
tree | 3f526418bb2fe32524d6ca208d5f39e9f510a6b5 | |
parent | 3db43b0cf315a4c0c7b78787f637db04045f90ed (diff) | |
download | perl-URPM-47f12646b34ad10fca581e8946ade89f18765483.tar perl-URPM-47f12646b34ad10fca581e8946ade89f18765483.tar.gz perl-URPM-47f12646b34ad10fca581e8946ade89f18765483.tar.bz2 perl-URPM-47f12646b34ad10fca581e8946ade89f18765483.tar.xz perl-URPM-47f12646b34ad10fca581e8946ade89f18765483.zip |
rename "suggests" field to "recommends"
as this really what it is
-rw-r--r-- | URPM.xs | 16 | ||||
-rw-r--r-- | xs1.xs | 61 | ||||
-rw-r--r-- | xs1b.xs | 43 | ||||
-rw-r--r-- | xs2.xs | 28 |
4 files changed, 140 insertions, 8 deletions
@@ -50,7 +50,7 @@ struct s_Package { unsigned flag; char *info; char *requires; - char *suggests; + char *recommends; char *obsoletes; char *conflicts; char *provides; @@ -763,8 +763,8 @@ pack_header(const URPM__Package pkg) { if (pkg->filesize == 0) pkg->filesize = get_filesize(pkg->h); if (pkg->requires == NULL) pkg->requires = pack_list(pkg->h, RPMTAG_REQUIRENAME, RPMTAG_REQUIREFLAGS, RPMTAG_REQUIREVERSION); - if (pkg->suggests == NULL) - pkg->suggests = pack_list(pkg->h, RPMTAG_RECOMMENDNAME, 0, 0); + if (pkg->recommends == NULL) + pkg->recommends = pack_list(pkg->h, RPMTAG_RECOMMENDNAME, 0, 0); if (pkg->obsoletes == NULL) pkg->obsoletes = pack_list(pkg->h, RPMTAG_OBSOLETENAME, RPMTAG_OBSOLETEFLAGS, RPMTAG_OBSOLETEVERSION); if (pkg->conflicts == NULL) @@ -1051,7 +1051,7 @@ parse_line(AV *depslist, HV *provides, HV *obsoletes, URPM__Package pkg, char *b if (!strcmp(tag, "requires")) ptr = &pkg->requires; else if (!strcmp(tag, "suggests")) - ptr = &pkg->suggests; + ptr = &pkg->recommends; else if (!strcmp(tag, "obsoletes")) ptr = &pkg->obsoletes; else if (!strcmp(tag, "conflicts")) @@ -1417,7 +1417,7 @@ Pkg_DESTROY(pkg) CODE: free(pkg->info); free(pkg->requires); - free(pkg->suggests); + free(pkg->recommends); free(pkg->obsoletes); free(pkg->conflicts); free(pkg->provides); @@ -1871,7 +1871,7 @@ Pkg_obsoletes_nosense(pkg) case 1: tag = RPMTAG_CONFLICTNAME; s = pkg->conflicts; break; case 2: tag = RPMTAG_PROVIDENAME; s = pkg->provides; break; case 3: tag = RPMTAG_REQUIRENAME; s = pkg->requires; break; - case 4: tag = RPMTAG_RECOMMENDNAME;s = pkg->suggests; break; + case 4: tag = RPMTAG_RECOMMENDNAME;s = pkg->recommends; break; default: tag = RPMTAG_OBSOLETENAME; s = pkg->obsoletes; break; } return_list_str(s, pkg->h, tag, 0, 0, callback_list_str_xpush, NULL); @@ -2098,8 +2098,8 @@ Pkg_build_info(pkg, fileno, provides_files=NULL) size = snprintf(buff, sizeof(buff), "@requires@%s\n", pkg->requires); if (size < sizeof(buff)) write_nocheck(fileno, buff, size); } - if (pkg->suggests && *pkg->suggests) { - size = snprintf(buff, sizeof(buff), "@suggests@%s\n", pkg->suggests); + if (pkg->recommends && *pkg->recommends) { + size = snprintf(buff, sizeof(buff), "@suggests@%s\n", pkg->recommends); if (size < sizeof(buff)) write_nocheck(fileno, buff, size); } if (pkg->summary && *pkg->summary) { @@ -0,0 +1,61 @@ +static void +update_provides(const URPM__Package pkg, HV *provides) { + if (pkg->h) { + int len; + struct rpmtd_s td, td_flags; + unsigned int i; + + /* examine requires for files which need to be marked in provides */ + if (headerGet(pkg->h, RPMTAG_REQUIRENAME, &td, HEADERGET_DEFAULT)) { + for (i = 0; i < rpmtdCount(&td); ++i) { + const char *s = rpmtdNextString(&td); + len = strlen(s); + if (s[0] == '/') (void)hv_fetch(provides, s, len, 1); + } + } + + /* update all provides */ + if (headerGet(pkg->h, RPMTAG_PROVIDENAME, &td, HEADERGET_DEFAULT)) { + char **list = td.data; + rpmsenseFlags *flags = NULL; + if (headerGet(pkg->h, RPMTAG_PROVIDEFLAGS, &td_flags, HEADERGET_DEFAULT)) + flags = td_flags.data; + for (i = 0; i < rpmtdCount(&td); ++i) { + len = strlen(list[i]); + if (!strncmp(list[i], "rpmlib(", 7)) continue; + update_hash_entry(provides, list[i], len, 1, flags && flags[i] & (RPMSENSE_PREREQ|RPMSENSE_SCRIPT_PREUN|RPMSENSE_SCRIPT_PRE|RPMSENSE_SCRIPT_POSTUN|RPMSENSE_SCRIPT_POST|RPMSENSE_LESS|RPMSENSE_EQUAL|RPMSENSE_GREATER), + pkg); + } + } + } else { + char *ps, *s, *es; + + if ((s = pkg->requires) != NULL && *s != 0) { + ps = strchr(s, '@'); + /* examine requires for files which need to be marked in provides */ + while(ps != NULL) { + if (s[0] == '/') { + *ps = 0; es = strchr(s, '['); if (!es) es = strchr(s, ' '); *ps = '@'; + (void)hv_fetch(provides, s, es != NULL ? es-s : ps-s, 1); + } + s = ps + 1; ps = strchr(s, '@'); + } + if (s[0] == '/') { + es = strchr(s, '['); if (!es) es = strchr(s, ' '); + (void)hv_fetch(provides, s, es != NULL ? (U32)(es-s) : strlen(s), 1); + } + } + + /* update all provides */ + if ((s = pkg->provides) != NULL && *s != 0) { + ps = strchr(s, '@'); + while(ps != NULL) { + *ps = 0; es = strchr(s, '['); if (!es) es = strchr(s, ' '); *ps = '@'; + update_hash_entry(provides, s, es != NULL ? es-s : ps-s, 1, es != NULL, pkg); + s = ps + 1; ps = strchr(s, '@'); + } + es = strchr(s, '['); if (!es) es = strchr(s, ' '); + update_hash_entry(provides, s, es != NULL ? es-s : 0, 1, es != NULL, pkg); + } + } + @@ -0,0 +1,43 @@ +static void +update_provides_files(const URPM__Package pkg, HV *provides) { + if (pkg->h) { + STRLEN len; + unsigned int i; + + struct rpmtd_s td_baseNames, td_dirIndexes, td_dirNames; + if (headerGet(pkg->h, RPMTAG_BASENAMES, &td_baseNames, HEADERGET_DEFAULT) && + headerGet(pkg->h, RPMTAG_DIRINDEXES, &td_dirIndexes, HEADERGET_DEFAULT) && + headerGet(pkg->h, RPMTAG_DIRNAMES, &td_dirNames, HEADERGET_DEFAULT)) { + + char **baseNames = td_baseNames.data; + char **dirNames = td_dirNames.data; + int32_t *dirIndexes = td_dirIndexes.data; + + char buff[4096]; + char *p; + + for(i = 0; i < rpmtdCount(&td_baseNames); i++) { + len = strlen(dirNames[dirIndexes[i]]); + if (len >= sizeof(buff)) continue; + memcpy(p = buff, dirNames[dirIndexes[i]], len + 1); p += len; + len = strlen(baseNames[i]); + if (p - buff + len >= sizeof(buff)) continue; + memcpy(p, baseNames[i], len + 1); p += len; + + update_hash_entry(provides, buff, p-buff, 0, 0, pkg); + } + + rpmtdFreeData(&td_baseNames); + rpmtdFreeData(&td_dirNames); + } else { + struct rpmtd_s td; + + if (headerGet(pkg->h, RPMTAG_OLDFILENAMES, &td, HEADERGET_DEFAULT)) { + for (i = 0; i < rpmtdCount(&td); i++) + update_hash_entry(provides, rpmtdNextString(&td), 0, 0, 0, pkg); + + rpmtdFreeData(&td); + } + } + } + @@ -0,0 +1,28 @@ +static void +update_obsoletes(const URPM__Package pkg, HV *obsoletes) { + if (pkg->h) { + struct rpmtd_s td; + + /* update all provides */ + if (headerGet(pkg->h, RPMTAG_OBSOLETENAME, &td, HEADERGET_DEFAULT)) { + unsigned int i; + for (i = 0; i < rpmtdCount(&td); ++i) + update_hash_entry(obsoletes, rpmtdNextString(&td), 0, 1, 0, pkg); + } + } else { + char *ps, *s; + + if ((s = pkg->obsoletes) != NULL && *s != 0) { + char *es; + + ps = strchr(s, '@'); + while(ps != NULL) { + *ps = 0; es = strchr(s, '['); if (!es) es = strchr(s, ' '); *ps = '@'; + update_hash_entry(obsoletes, s, es != NULL ? es-s : ps-s, 1, 0, pkg); + s = ps + 1; ps = strchr(s, '@'); + } + es = strchr(s, '['); if (!es) es = strchr(s, ' '); + update_hash_entry(obsoletes, s, es != NULL ? es-s : 0, 1, 0, pkg); + } + } + |