rpm-4.0.2.patch.feature 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. ##
  2. ## rpm-4.0.2.patch.feature -- Annotated patch file
  3. ## Copyright (c) 2000-2001 Cable & Wireless Deutschland GmbH
  4. ## Copyright (c) 2000-2001 Ralf S. Engelschall <rse.com>
  5. ##
  6. ## This file assembles changes to existing RPM source files between
  7. ## the original RedHat RPM and the OpenPKG RPM variant. It can be
  8. ## automatically applied to a vanilla RedHat RPM source tree with the
  9. ## 'patch' tool to upgrade those files. Each patch snippet is annotated
  10. ## with a short description.
  11. ##
  12. ## Created on: 23-Sep-2001
  13. ##
  14. +---------------------------------------------------------------------------
  15. | In OpenPKG, the RPM package contains own local versions of the
  16. | "patch" and "tar" tools, so we cannot accept hard-coded names here.
  17. | Instead we expand a variable to allow us to direct RPM to our tools.
  18. | Also we allow %setup and %patch macros whitespace-indented in %prep,
  19. | because both in OpenPKG we both have all scripts indented and this
  20. | way it is more flexible and clean.
  21. | Additionally add support for splitted source directories, i.e.,
  22. | source files alternatively can be placed into the spec directory and
  23. | are picked up there, too.
  24. +---------------------------------------------------------------------------
  25. Index: build/parsePrep.c
  26. --- build/parsePrep.c 2001/01/15 23:10:04 1.1.1.7
  27. +++ build/parsePrep.c 2001/09/21 12:24:12 1.4
  28. @@ -65,6 +65,7 @@
  29. struct Source *sp;
  30. rpmCompressedMagic compressed = COMPRESSED_NOT;
  31. int urltype;
  32. + const char *patcher;
  33. for (sp = spec->sources; sp != NULL; sp = sp->next) {
  34. if ((sp->flags & RPMBUILD_ISPATCH) && (sp->num == c)) {
  35. @@ -76,7 +77,15 @@
  36. return NULL;
  37. }
  38. +#ifndef OPENPKG
  39. fn = urlfn = rpmGetPath("%{_sourcedir}/", sp->source, NULL);
  40. +#else
  41. + fn = urlfn = rpmGetPath("%{_specdir}/", sp->source, NULL);
  42. + if (access(fn, F_OK) == -1) {
  43. + free(fn);
  44. + fn = urlfn = rpmGetPath("%{_sourcedir}/", sp->source, NULL);
  45. + }
  46. +#endif
  47. args[0] = '\0';
  48. if (db) {
  49. @@ -112,6 +121,9 @@
  50. /*@notreached@*/ break;
  51. }
  52. + patcher = rpmGetPath("%{_patchbin}", NULL);
  53. + if (strcmp(patcher, "%{_patchbin}") == 0)
  54. + patcher = "patch";
  55. if (compressed) {
  56. const char *zipper = rpmGetPath(
  57. (compressed == COMPRESSED_BZIP2 ? "%{_bzip2bin}" : "%{_gzipbin}"),
  58. @@ -119,20 +131,20 @@
  59. sprintf(buf,
  60. "echo \"Patch #%d (%s):\"\n"
  61. - "%s -d < %s | patch -p%d %s -s\n"
  62. + "%s -d < %s | %s -p%d %s -s\n"
  63. "STATUS=$?\n"
  64. "if [ $STATUS -ne 0 ]; then\n"
  65. " exit $STATUS\n"
  66. "fi",
  67. c, (const char *) basename(fn),
  68. zipper,
  69. - fn, strip, args);
  70. + fn, patcher, strip, args);
  71. free((void *)zipper);
  72. } else {
  73. sprintf(buf,
  74. "echo \"Patch #%d (%s):\"\n"
  75. - "patch -p%d %s -s < %s", c, (const char *) basename(fn),
  76. - strip, args, fn);
  77. + "%s -p%d %s -s < %s", c, (const char *) basename(fn),
  78. + patcher, strip, args, fn);
  79. }
  80. free((void *)urlfn);
  81. @@ -155,6 +167,7 @@
  82. struct Source *sp;
  83. rpmCompressedMagic compressed = COMPRESSED_NOT;
  84. int urltype;
  85. + const char *tar;
  86. for (sp = spec->sources; sp != NULL; sp = sp->next) {
  87. if ((sp->flags & RPMBUILD_ISSOURCE) && (sp->num == c)) {
  88. @@ -166,7 +179,19 @@
  89. return NULL;
  90. }
  91. +#ifndef OPENPKG
  92. fn = urlfn = rpmGetPath("%{_sourcedir}/", sp->source, NULL);
  93. +#else
  94. + fn = urlfn = rpmGetPath("%{_specdir}/", sp->source, NULL);
  95. + if (access(fn, F_OK) == -1) {
  96. + free(fn);
  97. + fn = urlfn = rpmGetPath("%{_sourcedir}/", sp->source, NULL);
  98. + }
  99. +#endif
  100. +
  101. + tar = rpmGetPath("%{_tarbin}", NULL);
  102. + if (strcmp(tar, "%{_tarbin}") == 0)
  103. + tar = "tar";
  104. taropts = ((rpmIsVerbose() && !quietly) ? "-xvvf" : "-xf");
  105. @@ -232,8 +257,13 @@
  106. free((void *)zipper);
  107. *t++ = ' ';
  108. t = stpcpy(t, fn);
  109. - if (needtar)
  110. - t = stpcpy( stpcpy( stpcpy(t, " | tar "), taropts), " -");
  111. + if (needtar) {
  112. + t = stpcpy(t, " | ");
  113. + t = stpcpy(t, tar);
  114. + t = stpcpy(t, " ");
  115. + t = stpcpy(t, taropts);
  116. + t = stpcpy(t, " -");
  117. + }
  118. t = stpcpy(t,
  119. "\n"
  120. "STATUS=$?\n"
  121. @@ -242,7 +272,7 @@
  122. "fi");
  123. } else {
  124. buf[0] = '\0';
  125. - t = stpcpy( stpcpy(buf, "tar "), taropts);
  126. + t = stpcpy( stpcpy(stpcpy(buf, tar), " "), taropts);
  127. *t++ = ' ';
  128. t = stpcpy(t, fn);
  129. }
  130. @@ -549,11 +579,14 @@
  131. saveLines = splitString(getStringBuf(buf), strlen(getStringBuf(buf)), '\n');
  132. for (lines = saveLines; *lines; lines++) {
  133. + char *cp;
  134. + for (cp = *lines; *cp == ' ' || *cp == '\t'; cp++)
  135. + ;
  136. res = 0;
  137. - if (! strncmp(*lines, "%setup", sizeof("%setup")-1)) {
  138. - res = doSetupMacro(spec, *lines);
  139. - } else if (! strncmp(*lines, "%patch", sizeof("%patch")-1)) {
  140. - res = doPatchMacro(spec, *lines);
  141. + if (! strncmp(cp, "%setup", sizeof("%setup")-1)) {
  142. + res = doSetupMacro(spec, cp);
  143. + } else if (! strncmp(cp, "%patch", sizeof("%patch")-1)) {
  144. + res = doPatchMacro(spec, cp);
  145. } else {
  146. appendLineStringBuf(spec->prep, *lines);
  147. }
  148. +---------------------------------------------------------------------------
  149. | Not everything on a system is RPM based (for instance OpenPKG is
  150. | just an add-on to the system), so do not assume we can just require
  151. | a package to provide "/bin/sh".
  152. +---------------------------------------------------------------------------
  153. Index: build/parseScript.c
  154. --- build/parseScript.c 2001/01/15 23:10:04 1.1.1.9
  155. +++ build/parseScript.c 2001/06/25 19:31:13 1.2
  156. @@ -246,6 +246,7 @@
  157. stripTrailingBlanksStringBuf(sb);
  158. p = getStringBuf(sb);
  159. + if (progArgv[0] != NULL && strcmp(progArgv[0], "/bin/sh") != 0)
  160. addReqProv(spec, pkg->header, (tagflags | RPMSENSE_INTERP), progArgv[0], NULL, 0);
  161. /* Trigger script insertion is always delayed in order to */
  162. +---------------------------------------------------------------------------
  163. | RPM has two platform id canonicalizations: hard-coded ones in the
  164. | "rpm" program and defined ones in the rpmrc files. The hard-coded
  165. | ones make the defined ones inconsistent. Additionally in OpenPKG we
  166. | know exactly what we do. So disable the hard-coded canonicalizations
  167. | and use only the defined ones. The only thing we do inside "rpm" is
  168. | to reduce the platform version to major and minor version numbers in
  169. | order to simplify the "rpmrc" files.
  170. +---------------------------------------------------------------------------
  171. Index: lib/rpmrc.c
  172. --- lib/rpmrc.c 2001/03/13 12:55:25 1.1.1.20
  173. +++ lib/rpmrc.c 2001/09/23 08:15:32 1.3
  174. @@ -931,6 +931,26 @@
  175. if (!gotDefaults) {
  176. uname(&un);
  177. +#ifdef OPENPKG
  178. + {
  179. + char *cp;
  180. + char *cpR;
  181. + int n;
  182. + cpR = un.release;
  183. + if ((n = strcspn(cpR, "0123456789")) > 0)
  184. + cpR += n;
  185. + if ((n = strspn(cpR, "0123456789.")) > 0) {
  186. + /* terminate after "N.N.N...." prefix */
  187. + cpR[n] = '\0';
  188. + /* shorten to "N.N" if longer */
  189. + if ((cp = strchr(cpR, '.')) != NULL) {
  190. + if ((cp = strchr(cp+1, '.')) != NULL)
  191. + *cp = '\0';
  192. + }
  193. + strcat(un.sysname, cpR);
  194. + }
  195. + }
  196. +#else /* OPENPKG */
  197. #if !defined(__linux__)
  198. #ifdef SNI
  199. /* USUALLY un.sysname on sinix does start with the word "SINIX"
  200. @@ -1114,6 +1134,7 @@
  201. un.machine[1] = class;
  202. }
  203. # endif
  204. +#endif /* OPENPKG */
  205. /* the uname() result goes through the arch_canon table */
  206. canon = lookupInCanonTable(un.machine,
  207. +---------------------------------------------------------------------------
  208. | Add support for splitted source directories, i.e., source files
  209. | alternatively can be placed into the spec directory and are picked
  210. | up there, too.
  211. +---------------------------------------------------------------------------
  212. Index: build/build.c
  213. --- build/build.c 2001/01/15 23:10:04 1.1.1.16
  214. +++ build/build.c 2001/09/17 11:09:23 1.2
  215. @@ -25,7 +25,15 @@
  216. for (p = spec->sources; p != NULL; p = p->next) {
  217. if (! (p->flags & RPMBUILD_ISNO)) {
  218. +#ifndef OPENPKG
  219. const char *fn = rpmGetPath("%{_sourcedir}/", p->source, NULL);
  220. +#else
  221. + const char *fn = rpmGetPath("%{_specdir}/", p->source, NULL);
  222. + if (access(fn, F_OK) == -1) {
  223. + free(fn);
  224. + fn = rpmGetPath("%{_sourcedir}/", p->source, NULL);
  225. + }
  226. +#endif
  227. unlink(fn);
  228. free((void *)fn);
  229. }
  230. @@ -34,7 +42,15 @@
  231. for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
  232. for (p = pkg->icon; p != NULL; p = p->next) {
  233. if (! (p->flags & RPMBUILD_ISNO)) {
  234. +#ifndef OPENPKG
  235. const char *fn = rpmGetPath("%{_sourcedir}/", p->source, NULL);
  236. +#else
  237. + const char *fn = rpmGetPath("%{_specdir}/", p->source, NULL);
  238. + if (access(fn, F_OK) == -1) {
  239. + free(fn);
  240. + fn = rpmGetPath("%{_sourcedir}/", p->source, NULL);
  241. + }
  242. +#endif
  243. unlink(fn);
  244. free((void *)fn);
  245. }
  246. +---------------------------------------------------------------------------
  247. | Add support for splitted source directories, i.e., source files
  248. | alternatively can be placed into the spec directory and are picked
  249. | up there, too.
  250. +---------------------------------------------------------------------------
  251. Index: build/files.c
  252. --- build/files.c 2001/01/19 01:47:25 1.1.1.15
  253. +++ build/files.c 2001/09/17 11:09:23 1.2
  254. @@ -1655,8 +1655,20 @@
  255. }
  256. { const char *s;
  257. +#ifndef OPENPKG
  258. s = rpmGetPath( ((srcPtr->flags & RPMBUILD_ISNO) ? "!" : ""),
  259. "%{_sourcedir}/", srcPtr->source, NULL);
  260. +#else
  261. + const char *s2;
  262. + s2 = rpmGetPath("%{_specdir}/", srcPtr->source, NULL);
  263. + if (access(s2, F_OK) == 0)
  264. + s = rpmGetPath( ((srcPtr->flags & RPMBUILD_ISNO) ? "!" : ""),
  265. + "%{_specdir}/", srcPtr->source, NULL);
  266. + else
  267. + s = rpmGetPath( ((srcPtr->flags & RPMBUILD_ISNO) ? "!" : ""),
  268. + "%{_sourcedir}/", srcPtr->source, NULL);
  269. + free(s2);
  270. +#endif
  271. appendLineStringBuf(sourceFiles, s);
  272. free((void *)s);
  273. }
  274. @@ -1665,8 +1677,20 @@
  275. for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
  276. for (srcPtr = pkg->icon; srcPtr != NULL; srcPtr = srcPtr->next) {
  277. const char *s;
  278. +#ifndef OPENPKG
  279. s = rpmGetPath( ((srcPtr->flags & RPMBUILD_ISNO) ? "!" : ""),
  280. "%{_sourcedir}/", srcPtr->source, NULL);
  281. +#else
  282. + const char *s2;
  283. + s2 = rpmGetPath("%{_specdir}/", srcPtr->source, NULL);
  284. + if (access(s2, F_OK) == 0)
  285. + s = rpmGetPath( ((srcPtr->flags & RPMBUILD_ISNO) ? "!" : ""),
  286. + "%{_specdir}/", srcPtr->source, NULL);
  287. + else
  288. + s = rpmGetPath( ((srcPtr->flags & RPMBUILD_ISNO) ? "!" : ""),
  289. + "%{_sourcedir}/", srcPtr->source, NULL);
  290. + free(s2);
  291. +#endif
  292. appendLineStringBuf(sourceFiles, s);
  293. free((void *)s);
  294. }
  295. +---------------------------------------------------------------------------
  296. | Add support for splitted source directories, i.e., source files
  297. | alternatively can be placed into the spec directory and are picked
  298. | up there, too.
  299. +---------------------------------------------------------------------------
  300. Index: build/parsePreamble.c
  301. --- build/parsePreamble.c 2001/01/15 23:10:04 1.1.1.9
  302. +++ build/parsePreamble.c 2001/09/17 11:09:23 1.2
  303. @@ -317,7 +317,15 @@
  304. size_t nb, iconsize;
  305. /* XXX use rpmGenPath(rootdir, "%{_sourcedir}/", file) for icon path. */
  306. +#ifndef OPENPKG
  307. fn = rpmGetPath("%{_sourcedir}/", file, NULL);
  308. +#else
  309. + fn = rpmGetPath("%{_specdir}/", file, NULL);
  310. + if (access(fn, F_OK) == -1) {
  311. + free(fn);
  312. + fn = rpmGetPath("%{_sourcedir}/", file, NULL);
  313. + }
  314. +#endif
  315. fd = Fopen(fn, "r.ufdio");
  316. if (fd == NULL || Ferror(fd)) {
  317. +---------------------------------------------------------------------------
  318. | Add support for splitted source directories, i.e., source files
  319. | alternatively can be placed into the spec directory and are picked
  320. | up there, too.
  321. +---------------------------------------------------------------------------
  322. Index: build/spec.c
  323. --- build/spec.c 2001/01/15 23:10:04 1.1.1.16
  324. +++ build/spec.c 2001/09/17 11:09:23 1.2
  325. @@ -319,7 +319,15 @@
  326. spec->numSources++;
  327. if (tag != RPMTAG_ICON) {
  328. +#ifndef OPENPKG
  329. const char *body = rpmGetPath("%{_sourcedir}/", p->source, NULL);
  330. +#else
  331. + const char *body = rpmGetPath("%{_specdir}/", p->source, NULL);
  332. + if (access(body, F_OK) == -1) {
  333. + free(body);
  334. + body = rpmGetPath("%{_sourcedir}/", p->source, NULL);
  335. + }
  336. +#endif
  337. sprintf(buf, "%s%d",
  338. (flag & RPMBUILD_ISPATCH) ? "PATCH" : "SOURCE", num);