openpkg.spec 116 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787
  1. ##
  2. ## openpkg.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2007 OpenPKG Foundation e.V. <http://openpkg.net/>
  4. ## Copyright (c) 2000-2007 Ralf S. Engelschall <http://engelschall.com/>
  5. ##
  6. ## Permission to use, copy, modify, and distribute this software for
  7. ## any purpose with or without fee is hereby granted, provided that
  8. ## the above copyright notice and this permission notice appear in all
  9. ## copies.
  10. ##
  11. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  12. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  13. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  15. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  17. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  18. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  20. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  21. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  22. ## SUCH DAMAGE.
  23. ##
  24. # NOTICE: This OpenPKG RPM specification is _very_ special, because
  25. # it is used both for bootstrapping OpenPKG with its OpenPKG RPM and
  26. # for regular builds of OpenPKG RPM in order to upgrade an existing
  27. # installation. For this it has to interact correctly with the
  28. # "openpkg.boot" script. See the documentation in the file "README"
  29. # and the source of the companion script "openpkg.boot" for details,
  30. # but do not touch anything here until you are 100% sure about what
  31. # you are doing. In short: This script is allowed to use only a very
  32. # restricted subset of the OpenPKG RPM functionality!
  33. # BUILD REQUIREMENTS:
  34. # o any sh(1)
  35. # o any tar(1)
  36. # o any make(1)
  37. # o any cc(1)
  38. # the package version/release
  39. %define V_openpkg 20070102
  40. # the used software versions
  41. %define V_rpm 4.2.1
  42. %define V_zlib 1.2.3
  43. %define V_bzip2 1.0.3
  44. %define V_beecrypt 4.1.2
  45. %define V_curl 7.16.0
  46. %define V_make 3.81
  47. %define V_gzip 1.3.10
  48. %define V_gzip_r 1.11
  49. %define V_patch 2.5.9
  50. %define V_tar 1.16.1
  51. %define V_bash 3.2
  52. %define V_uuid 1.5.1
  53. %define V_config 20060923
  54. %define V_registry 1.0.1
  55. %define V_perl 5.8.8
  56. %define V_openssl 0.9.8d
  57. %define V_tools 1.3.1
  58. %define V_exec 2.0.0-C
  59. # package information
  60. Name: openpkg
  61. Summary: OpenPKG Bootstrap
  62. URL: http://www.openpkg.org/
  63. Vendor: OpenPKG
  64. Packager: OpenPKG Foundation e.V.
  65. Distribution: OpenPKG Community
  66. Class: CORE
  67. Group: Bootstrapping
  68. License: MIT/BSD/LGPL/GPL
  69. Version: %{V_openpkg}
  70. Release: %{V_openpkg}
  71. # list of sources
  72. Source0: ftp://alpha.gnu.org/gnu/patch/patch-%{V_patch}.tar.gz
  73. Source1: ftp://ftp.cwru.edu/pub/bash/bash-%{V_bash}.tar.gz
  74. Source2: ftp://ftp.gnu.org/gnu/make/make-%{V_make}.tar.gz
  75. Source3: ftp://ftp.gnu.org/gnu/tar/tar-%{V_tar}.tar.gz
  76. Source4: ftp://ftp.openpkg.org/sources/CPY/config/config-%{V_config}.tar.gz
  77. Source5: ftp://ftp.openpkg.org/sources/CPY/openpkg-registry/openpkg-registry-%{V_registry}.tar.gz
  78. Source6: ftp://ftp.openpkg.org/sources/CPY/openpkg-tools/openpkg-tools-%{V_tools}.tar.gz
  79. Source7: ftp://ftp.openpkg.org/sources/CPY/openpkg/gzip-%{V_gzip}-openpkg-r%{V_gzip_r}.tar
  80. Source8: ftp://ftp.openpkg.org/sources/CPY/openpkg/gzip-%{V_gzip}.tar
  81. Source9: ftp://ftp.openpkg.org/sources/CPY/openpkg/openpkg-executable-%{V_exec}.tar.gz
  82. Source10: ftp://ftp.openpkg.org/sources/CPY/openpkg/rpm-%{V_rpm}.tar.gz
  83. Source11: ftp://ftp.openpkg.org/sources/CPY/perl/perl-%{V_perl}-mini.tar.gz
  84. Source12: ftp://ftp.openssl.org/source/openssl-%{V_openssl}.tar.gz
  85. Source13: ftp://ftp.ossp.org/pkg/lib/uuid/uuid-%{V_uuid}.tar.gz
  86. Source14: http://curl.haxx.se/download/curl-%{V_curl}.tar.gz
  87. Source15: http://switch.dl.sourceforge.net/beecrypt/beecrypt-%{V_beecrypt}.tar.gz
  88. Source16: http://www.bzip.org/%{V_bzip2}/bzip2-%{V_bzip2}.tar.gz
  89. Source17: http://www.zlib.net/zlib-%{V_zlib}.tar.gz
  90. Source18: HISTORY
  91. Source19: README
  92. Source20: aux.prereq.sh
  93. Source21: aux.usrgrp.sh
  94. Source22: aux.wrapbin.sh
  95. Source23: aux.wrapsrc.sh
  96. Source24: bash.patch
  97. Source25: beecrypt.patch
  98. Source26: dot.bash_login
  99. Source27: dot.bashrc
  100. Source28: dot.lsyncrc
  101. Source29: install.sh
  102. Source30: local.README
  103. Source31: lsync
  104. Source32: lsync.8
  105. Source33: lsync.pod
  106. Source34: make.patch
  107. Source35: man.sh
  108. Source36: openpkg.1
  109. Source37: openpkg.boot
  110. Source38: openpkg.com.pgp
  111. Source39: openpkg.net.pgp
  112. Source40: openpkg.org.pgp
  113. Source41: openpkg.pod
  114. Source42: openpkg.sh
  115. Source43: openssl.patch
  116. Source44: perl.patch
  117. Source45: pod2man.sh
  118. Source46: rc
  119. Source47: rc.8
  120. Source48: rc.conf
  121. Source49: rc.func
  122. Source50: rc.openpkg
  123. Source51: rc.pod
  124. Source52: release.8
  125. Source53: release.pod
  126. Source54: release.sh
  127. Source55: root.README
  128. Source56: rpm-config.8
  129. Source57: rpm-config.pod
  130. Source58: rpm-config.sh
  131. Source59: rpm.patch.bugfix
  132. Source60: rpm.patch.feature
  133. Source61: rpm.patch.porting
  134. Source62: rpm.patch.regen
  135. Source63: rpmdb
  136. Source64: rpmmacros
  137. Source65: rpmpopt
  138. Source66: rpmrc
  139. Source67: rpmtool
  140. Source68: rpmtool.8
  141. Source69: rpmtool.pod
  142. Source70: shtool
  143. Source71: tar.patch
  144. Source72: uuid.8
  145. Source73: uuid.pod
  146. Source74: uuid.sh
  147. # build information
  148. Prefix: %{l_prefix}
  149. BuildRoot: %{l_buildroot}
  150. AutoReq: no
  151. AutoReqProv: no
  152. Provides: OpenPKG
  153. %description
  154. This is the bootstrap package for the RPM-based Unix Software
  155. Package Hierarchy OpenPKG. The RedHat Package Manager (RPM) is a
  156. sophisticated and portable package manager for Unix platforms,
  157. which supports automated building, installation, management and
  158. deinstallation of Unix software. RPM was originally designed and
  159. implemented for the RedHat Linux operating system where it manages
  160. every file on the whole system. OpenPKG uses RPM only for managing
  161. the files in a particular filesystem hierarchy dedicated to the
  162. installation of third-party software packages provided by the
  163. OpenPKG project.
  164. The OpenPKG bootstrap package includes the following software:
  165. RedHat RPM %{V_rpm}, ZLib %{V_zlib}, GNU Bzip2 %{V_bzip2},
  166. GNU Gzip %{V_gzip}, GNU Tar %{V_tar}, GNU Patch %{V_patch},
  167. GNU Make %{V_make}, GNU Bash %{V_bash}, cURL %{V_curl},
  168. OSSP uuid %{V_uuid}, BeeCrypt %{V_beecrypt},
  169. OpenSSL %{V_openssl}, Perl %{V_perl}
  170. %track
  171. prog openpkg:bash = {
  172. version = %{V_bash}
  173. url = ftp://ftp.cwru.edu/pub/bash/
  174. regex = bash-(__VER__)\.tar\.gz
  175. }
  176. prog openpkg:bzip2 = {
  177. version = %{V_bzip2}
  178. url = http://www.bzip.org/downloads.html
  179. regex = bzip2-(__VER__)\.tar\.gz
  180. }
  181. prog openpkg:curl = {
  182. version = %{V_curl}
  183. url = http://curl.haxx.se/download/
  184. regex = curl-(__VER__)\.tar\.gz
  185. }
  186. prog openpkg:gzip = {
  187. comment = "rse: intentionally tracked at gnu.org, although fetched from openpkg.org because of uncompression"
  188. version = %{V_gzip}
  189. url = ftp://alpha.gnu.org/gnu/gzip/
  190. regex = gzip-(__VER__)\.tar(\.gz)?
  191. }
  192. prog openpkg:gzip_r = {
  193. version = %{V_gzip_r}
  194. url = ftp://ftp.openpkg.org/sources/CPY/openpkg/
  195. regex = gzip-%{V_gzip}-openpkg-r(__VER__)\.tar
  196. }
  197. prog openpkg:make = {
  198. version = %{V_make}
  199. url = ftp://ftp.gnu.org/gnu/make/
  200. regex = make-(__VER__)\.tar\.gz
  201. }
  202. prog openpkg:patch = {
  203. disabled
  204. comment = "rse: directory missing after GNU.org security issues"
  205. version = %{V_patch}
  206. url = ftp://alpha.gnu.org/gnu/patch/
  207. regex = patch-(__VER__)\.tar\.gz
  208. }
  209. prog openpkg:rpm = {
  210. disabled
  211. comment = "rse: we have a .src.rpm extracted .tar.gz, because there is still no tarball for 4.2.1"
  212. version = %{V_rpm}
  213. url = ftp://ftp.rpm.org/pub/rpm/dist/rpm-4.2.x/
  214. regex = rpm-(4\.2\.\d+)\.tar\.gz
  215. }
  216. prog openpkg:tar = {
  217. version = %{V_tar}
  218. url = ftp://ftp.gnu.org/gnu/tar/
  219. regex = tar-(__VER__)\.tar\.gz
  220. }
  221. prog openpkg:zlib = {
  222. version = %{V_zlib}
  223. url = http://www.zlib.net/
  224. regex = zlib-(__VER__)\.tar\.gz
  225. }
  226. prog openpkg:uuid = {
  227. version = %{V_uuid}
  228. url = ftp://ftp.ossp.org/pkg/lib/uuid/
  229. regex = uuid-(__VER__)\.tar\.gz
  230. }
  231. prog openpkg:config = {
  232. version = %{V_config}
  233. url = ftp://ftp.openpkg.org/sources/CPY/config/
  234. regex = config-(__VER__)\.tar\.gz
  235. }
  236. prog openpkg:beecrypt = {
  237. version = %{V_beecrypt}
  238. url = http://prdownloads.sourceforge.net/beecrypt/
  239. regex = beecrypt-(__VER__)\.tar\.gz
  240. }
  241. prog openpkg:registry = {
  242. version = %{V_registry}
  243. url = ftp://ftp.openpkg.org/sources/CPY/openpkg-registry/
  244. regex = openpkg-registry-(__VER__)\.tar\.gz
  245. }
  246. prog openpkg:perl = {
  247. version = %{V_perl}
  248. url = ftp://ftp.openpkg.org/sources/CPY/perl/
  249. regex = perl-(__VER__)-mini\.tar\.gz
  250. }
  251. prog openpkg:openssl = {
  252. version = %{V_openssl}
  253. url = ftp://ftp.openssl.org/source/
  254. regex = openssl-(\d+\.\d+\.\d+[a-z]?)\.tar\.gz
  255. }
  256. prog openpkg:openpkg-tools = {
  257. version = %{V_tools}
  258. url = ftp://ftp.openpkg.org/sources/CPY/openpkg-tools/
  259. regex = openpkg-tools-(__VER__)\.tar\.gz
  260. }
  261. prog openpkg:openpkg-executable = {
  262. version = %{V_exec}
  263. url = ftp://ftp.openpkg.org/sources/CPY/openpkg/
  264. regex = openpkg-executable-(__VER__-C)\.tar\.gz
  265. }
  266. %prep
  267. # skip in bootstrap phase 2 (see openpkg.boot)
  268. [ ".$OPENPKG_BOOT" = .1 ] && exit 0
  269. # switch into a temporary build area
  270. rm -rf openpkg-%{version}
  271. mkdir openpkg-%{version}
  272. cd openpkg-%{version}
  273. rm -f .buildenv
  274. touch .buildenv
  275. # provide a bootstrap alternative to %{SOURCE xxx} because else
  276. # it is not possible to upgrade a newer OpenPKG RPM with an older
  277. # OpenPKG RPM.
  278. echo >>.buildenv 'SOURCE () {'
  279. echo >>.buildenv ' if [ -f "%{_specdir}/$1" ]; then'
  280. echo >>.buildenv ' echo "%{_specdir}/$1"'
  281. echo >>.buildenv ' else'
  282. echo >>.buildenv ' echo "%{_sourcedir}/$1"'
  283. echo >>.buildenv ' fi'
  284. echo >>.buildenv '}'
  285. echo >>.buildenv 'VERBOSE () {'
  286. echo >>.buildenv ' if [ -f "%{_specdir}/rpmtool" ]; then'
  287. echo >>.buildenv ' echo "$*" | sh %{_specdir}/rpmtool msg'
  288. echo >>.buildenv ' else'
  289. echo >>.buildenv ' echo "$*" | sh %{_sourcedir}/rpmtool msg'
  290. echo >>.buildenv ' fi'
  291. echo >>.buildenv '}'
  292. . ./.buildenv
  293. # display verbosity header
  294. set +x; VERBOSE "PREPARATION: Determine Build Tool Paths"; set -x
  295. # determine path to shtool
  296. shtool=`SOURCE shtool`
  297. echo "shtool=$shtool" >>./.buildenv
  298. # determine development tools
  299. # - bootstrapping: %{l_xxx} is set via sed(1)
  300. # - upgrading new: %{l_xxx} is set via rpmmacros
  301. # - upgrading old: %{l_xxx} is not set at all
  302. # manually make sure tar(1) is available
  303. l_tar=""; export l_tar
  304. [ ".%{?l_tar:set}" = .set ] && l_tar="%{l_tar}"
  305. [ ".%{?use_tar:set}" = .set ] && l_tar="%{use_tar}"
  306. if [ ".$l_tar" = . ]; then
  307. l_tar=`sh $shtool path gtar tar`
  308. if [ ".$l_tar" = . ]; then
  309. echo "openpkg: prerequisite tool \`gtar' or \`tar' not found"
  310. exit 1
  311. fi
  312. fi
  313. echo "l_tar=\"$l_tar\"; export l_tar" >>.buildenv
  314. # manually make sure make(1) is available
  315. l_make=""; export l_make
  316. [ ".%{?l_make:set}" = .set ] && l_make="%{l_make}"
  317. [ ".%{?use_make:set}" = .set ] && l_make="%{use_make}"
  318. if [ ".$l_make" = . ]; then
  319. l_make=`sh $shtool path gmake make`
  320. if [ ".$l_make" = . ]; then
  321. echo "openpkg: prerequisite tool \`gmake' or \`make' not found"
  322. exit 1
  323. fi
  324. fi
  325. echo "l_make=\"$l_make\"; export l_make" >>.buildenv
  326. # manually make sure cc(1) is available
  327. l_cc=""; export l_cc
  328. [ ".%{?l_cc:set}" = .set ] && l_cc="%{l_cc}"
  329. [ ".%{?use_cc:set}" = .set ] && l_cc="%{use_cc}"
  330. if [ ".$l_cc" = . ]; then
  331. l_cc=`sh $shtool path gcc cc`
  332. if [ ".$l_cc" = . ]; then
  333. echo "openpkg: prerequisite tool \`gcc' or \`cc' not found"
  334. exit 1
  335. fi
  336. fi
  337. echo "l_cc=\"$l_cc\"; export l_cc" >>.buildenv
  338. # manually make sure ar(1) is available
  339. l_ar=""; export l_ar
  340. [ ".%{?l_ar:set}" = .set ] && l_ar="%{l_ar}"
  341. [ ".%{?use_ar:set}" = .set ] && l_ar="%{use_ar}"
  342. if [ ".$l_ar" = . ]; then
  343. l_ar=`sh $shtool path ar`
  344. if [ ".$l_ar" = . ]; then
  345. echo "openpkg: prerequisite tool \`ar' not found"
  346. exit 1
  347. fi
  348. fi
  349. echo "l_ar=\"$l_ar\"; export l_ar" >>.buildenv
  350. # manually make sure ld(1) is available
  351. l_ld=""; export l_ld
  352. [ ".%{?l_ld:set}" = .set ] && l_ld="%{l_ld}"
  353. [ ".%{?use_ld:set}" = .set ] && l_ld="%{use_ld}"
  354. if [ ".$l_ld" = . ]; then
  355. l_ld=`sh $shtool path ld`
  356. if [ ".$l_ld" = . ]; then
  357. echo "openpkg: prerequisite tool \`ld' not found"
  358. exit 1
  359. fi
  360. fi
  361. echo "l_ld=\"$l_ld\"; export l_ld" >>.buildenv
  362. # manually make sure strip(1) is available or use a null replacement
  363. l_strip=""; export l_strip
  364. [ ".%{?l_strip:set}" = .set ] && l_strip="%{l_strip}"
  365. [ ".%{?use_strip:set}" = .set ] && l_strip="%{use_strip}"
  366. if [ ".$l_strip" = . ]; then
  367. l_strip=`sh $shtool path strip ls`
  368. if [ ".$l_strip" = . ]; then
  369. echo "openpkg: prerequisite tool \`strip' not found"
  370. exit 1
  371. fi
  372. fi
  373. echo "l_strip=\"$l_strip\"; export l_strip" >>.buildenv
  374. # determine path to aux.usrgrp.sh script
  375. usrgrp=`SOURCE aux.usrgrp.sh`
  376. echo "usrgrp=$usrgrp; export usrgrp" >>./.buildenv
  377. # display verbosity header
  378. set +x; VERBOSE "PREPARATION: Determine OpenPKG User/Group Name/Id Pairs"; set -x
  379. # determine user/group name/id pairs
  380. # - bootstrapping: %{l_[smrn]{usr,grp}} is set via sed(1)
  381. # - upgrading new: %{l_[smrn]{usr,grp}} is set via rpmmacros
  382. # - upgrading old: %{l_[smrn]{usr,grp}} is not set at all
  383. susr=""; [ ".%{?l_susr:set}" = .set ] && susr="%{l_susr}"
  384. sgrp=""; [ ".%{?l_sgrp:set}" = .set ] && sgrp="%{l_sgrp}"
  385. musr=""; [ ".%{?l_musr:set}" = .set ] && musr="%{l_musr}"
  386. mgrp=""; [ ".%{?l_mgrp:set}" = .set ] && mgrp="%{l_mgrp}"
  387. rusr=""; [ ".%{?l_rusr:set}" = .set ] && rusr="%{l_rusr}"
  388. rgrp=""; [ ".%{?l_rgrp:set}" = .set ] && rgrp="%{l_rgrp}"
  389. nusr=""; [ ".%{?l_nusr:set}" = .set ] && nusr="%{l_nusr}"
  390. ngrp=""; [ ".%{?l_ngrp:set}" = .set ] && ngrp="%{l_ngrp}"
  391. # corresponding ids
  392. suid=""; [ ".%{?l_suid:set}" = .set ] && suid="%{l_suid}"
  393. sgid=""; [ ".%{?l_sgid:set}" = .set ] && sgid="%{l_sgid}"
  394. muid=""; [ ".%{?l_muid:set}" = .set ] && muid="%{l_muid}"
  395. mgid=""; [ ".%{?l_mgid:set}" = .set ] && mgid="%{l_mgid}"
  396. ruid=""; [ ".%{?l_ruid:set}" = .set ] && ruid="%{l_ruid}"
  397. rgid=""; [ ".%{?l_rgid:set}" = .set ] && rgid="%{l_rgid}"
  398. nuid=""; [ ".%{?l_nuid:set}" = .set ] && nuid="%{l_nuid}"
  399. ngid=""; [ ".%{?l_ngid:set}" = .set ] && ngid="%{l_ngid}"
  400. # compat:
  401. usr=""; [ ".%{?l_fsusr:set}" = .set ] && usr="%{l_fsusr}"
  402. grp=""; [ ".%{?l_fsgrp:set}" = .set ] && grp="%{l_fsgrp}"
  403. eval `sh $usrgrp \
  404. --usr="$usr" --grp="$grp" \
  405. --susr="$susr" --sgrp="$sgrp" \
  406. --musr="$musr" --mgrp="$mgrp" \
  407. --rusr="$rusr" --rgrp="$rgrp" \
  408. --nusr="$nusr" --ngrp="$ngrp" \
  409. --suid="$suid" --sgid="$sgid" \
  410. --muid="$muid" --mgid="$mgid" \
  411. --ruid="$ruid" --rgid="$rgid" \
  412. --nuid="$nuid" --ngid="$ngid"`
  413. echo "susr=\"$susr\"; export susr" >>.buildenv
  414. echo "sgrp=\"$sgrp\"; export sgrp" >>.buildenv
  415. echo "musr=\"$musr\"; export musr" >>.buildenv
  416. echo "mgrp=\"$mgrp\"; export mgrp" >>.buildenv
  417. echo "rusr=\"$rusr\"; export rusr" >>.buildenv
  418. echo "rgrp=\"$rgrp\"; export rgrp" >>.buildenv
  419. echo "nusr=\"$nusr\"; export nusr" >>.buildenv
  420. echo "ngrp=\"$ngrp\"; export ngrp" >>.buildenv
  421. echo "suid=\"$suid\"; export suid" >>.buildenv
  422. echo "sgid=\"$sgid\"; export sgid" >>.buildenv
  423. echo "muid=\"$muid\"; export muid" >>.buildenv
  424. echo "mgid=\"$mgid\"; export mgid" >>.buildenv
  425. echo "ruid=\"$ruid\"; export ruid" >>.buildenv
  426. echo "rgid=\"$rgid\"; export rgid" >>.buildenv
  427. echo "nuid=\"$nuid\"; export nuid" >>.buildenv
  428. echo "ngid=\"$ngid\"; export ngid" >>.buildenv
  429. # display verbosity header
  430. set +x; VERBOSE "PREPARATION: Determine OpenPKG Instance Environment"; set -x
  431. # determine installation location id
  432. if [ ".%{?l_tag_fmt:set}" = .set ]; then
  433. tag="%{l_tag_fmt}"
  434. else
  435. tag="<compat>"
  436. fi
  437. echo "tag=\"$tag\"; export tag" >>.buildenv
  438. # determine platform id
  439. s=`(uname -s) 2>/dev/null` || s='Unknown'
  440. r=`(uname -r) 2>/dev/null` || r='0.0'
  441. plid="${s}/${r}"
  442. echo "plid=\"$plid\"; export plid" >>.buildenv
  443. # determine platform-specific build environment
  444. case $plid in
  445. FreeBSD/* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
  446. NetBSD/* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
  447. Linux/* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
  448. SunOS/* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin:/usr/ccs/bin" ;;
  449. UnixWare/*) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin:/usr/ccs/bin" ;;
  450. AIX/* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin:/usr/ccs/bin" ;;
  451. Darwin/* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
  452. OSF1/V5.* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
  453. HP-UX/* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
  454. IRIX*/6.* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
  455. * ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
  456. esac
  457. case $plid in
  458. FreeBSD/* ) l_build_ldlp="/lib:/usr/lib" ;;
  459. NetBSD/* ) l_build_ldlp="/lib:/usr/lib" ;;
  460. Linux/* ) l_build_ldlp="/lib:/usr/lib" ;;
  461. SunOS/* ) l_build_ldlp="/usr/lib:/usr/ccs/lib" ;;
  462. UnixWare/*) l_build_ldlp="/usr/lib:/usr/ccs/lib" ;;
  463. AIX/* ) l_build_ldlp="/usr/lib:/usr/ccs/lib" ;;
  464. Darwin/* ) l_build_ldlp="/usr/lib" ;;
  465. OSF1/V5.* ) l_build_ldlp="/usr/lib" ;;
  466. HP-UX/* ) l_build_ldlp="/usr/lib" ;;
  467. IRIX*/6.* ) l_build_ldlp="/usr/lib" ;;
  468. * ) l_build_ldlp="/usr/lib" ;;
  469. esac
  470. case $plid in
  471. * ) l_build_ulim=":" ;;
  472. esac
  473. echo "l_build_path=\"$l_build_path\"; export l_build_path" >>.buildenv
  474. echo "l_build_ldlp=\"$l_build_ldlp\"; export l_build_ldlp" >>.buildenv
  475. echo "l_build_ulim=\"$l_build_ulim\"; export l_build_ulim" >>.buildenv
  476. # display verbosity header
  477. set +x; VERBOSE "PREPARATION: Build GNU gzip (Compression Tool)"; set -x
  478. # bootstrap GNU zip tool
  479. ${l_tar} xf `SOURCE gzip-%{V_gzip}.tar` 2>/dev/null || true
  480. ${l_tar} xf `SOURCE gzip-%{V_gzip}-openpkg-r%{V_gzip_r}.tar` 2>/dev/null || true
  481. ( cd gzip-%{V_gzip}
  482. echo "ac_cv_prog_cc_g=no" >config.cache
  483. case $plid in
  484. Darwin/* ) echo "gzip_cv_assembler=no" >>config.cache ;;
  485. esac
  486. CC="${l_cc}" \
  487. GREP="grep" \
  488. ./configure \
  489. --cache-file=./config.cache
  490. ${l_make} || exit $?
  491. ( mv gzip ..; ${l_make} clean || true; mv ../gzip . ) || exit $?
  492. ) || exit $?
  493. l_gzip="`pwd`/gzip-%{V_gzip}/gzip"; export l_gzip
  494. echo "l_gzip=\"$l_gzip\"; export l_gzip" >>.buildenv
  495. # display verbosity header
  496. set +x; VERBOSE "PREPARATION: Unpack GNU configuration guessing utilities"; set -x
  497. # unpack GNU config.guess
  498. ${l_gzip} -dc `SOURCE config-%{V_config}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  499. # display verbosity header
  500. set +x; VERBOSE "PREPARATION: Build GNU patch (Source Patching Tool)"; set -x
  501. # bootstrap GNU patch tool
  502. ${l_gzip} -dc `SOURCE patch-%{V_patch}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  503. ( cd patch-%{V_patch}
  504. chmod u+w config.guess config.sub >/dev/null 2>&1 || true
  505. cp ../config/config.guess .
  506. cp ../config/config.sub .
  507. ( echo 'ac_cv_func_setmode=${ac_cv_func_setmode=no}'
  508. echo 'ac_cv_prog_cc_g=no'
  509. false=`sh $shtool path false`
  510. echo "ac_cv_path_ed_PROGRAM=\${ac_cv_path_ed_PROGRAM=$false}"
  511. ) >config.cache
  512. CC="${l_cc}" \
  513. ./configure \
  514. --cache-file=./config.cache \
  515. --disable-largefile
  516. ${l_make} || exit $?
  517. ( mv patch ..; ${l_make} clean || true; mv ../patch . ) || exit $?
  518. ) || exit $?
  519. l_patch="`pwd`/patch-%{V_patch}/patch"; export l_patch
  520. echo "l_patch=\"$l_patch\"; export l_patch" >>.buildenv
  521. # display verbosity header
  522. set +x; VERBOSE "BUILD: Build GNU tar (Archiving Tool)"; set -x
  523. # build GNU tar tool
  524. ${l_gzip} -dc `SOURCE tar-%{V_tar}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  525. ( cd tar-%{V_tar}
  526. ${l_patch} -p0 <`SOURCE tar.patch`
  527. ( echo 'am_cv_func_iconv=no'
  528. echo 'am_cv_lib_iconv=no'
  529. echo 'ac_cv_lib_iconv_iconv=no'
  530. echo 'ac_cv_header_iconv_h=no'
  531. echo 'ac_cv_type_iconv_t=no'
  532. ) >config.cache
  533. sh $shtool subst \
  534. -e 's;^rm conftest\.sed;rm -f conftest.sed;' \
  535. configure
  536. CC="${l_cc}" \
  537. MAKEINFO="true" \
  538. GREP="grep" \
  539. ./configure \
  540. --cache-file=./config.cache \
  541. --prefix=%{l_prefix} \
  542. --disable-nls
  543. ${l_make} || exit $?
  544. ( mv src/tar ..; ${l_make} clean || true; mv ../tar . ) || exit $?
  545. ) || exit $?
  546. l_tar="`pwd`/tar-%{V_tar}/tar"; export l_tar
  547. echo "l_tar=\"$l_tar\"; export l_tar" >>.buildenv
  548. # display verbosity header
  549. set +x; VERBOSE "PREPARATION: Unpack Distribution Tarballs"; set -x
  550. # unpack distribution tarballs
  551. ${l_gzip} -dc `SOURCE rpm-%{V_rpm}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  552. ${l_gzip} -dc `SOURCE zlib-%{V_zlib}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  553. ${l_gzip} -dc `SOURCE bzip2-%{V_bzip2}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  554. ${l_gzip} -dc `SOURCE curl-%{V_curl}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  555. ${l_gzip} -dc `SOURCE make-%{V_make}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  556. ${l_gzip} -dc `SOURCE bash-%{V_bash}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  557. ${l_gzip} -dc `SOURCE uuid-%{V_uuid}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  558. ${l_gzip} -dc `SOURCE beecrypt-%{V_beecrypt}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  559. ${l_gzip} -dc `SOURCE openpkg-registry-%{V_registry}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  560. ${l_gzip} -dc `SOURCE perl-%{V_perl}-mini.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  561. ${l_gzip} -dc `SOURCE openssl-%{V_openssl}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  562. ${l_gzip} -dc `SOURCE openpkg-tools-%{V_tools}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  563. ${l_gzip} -dc `SOURCE openpkg-executable-%{V_exec}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  564. # update config.guess/config.sub
  565. for dir in rpm-%{V_rpm} rpm-%{V_rpm}/popt beecrypt-%{V_beecrypt} \
  566. curl-%{V_curl} make-%{V_make} bash-%{V_bash}/support; do
  567. chmod u+w $dir/config.guess $dir/config.sub >/dev/null 2>&1 || true
  568. cp config/config.guess $dir/
  569. cp config/config.sub $dir/
  570. done
  571. # display verbosity header
  572. set +x; VERBOSE "PREPARATION: Apply OpenPKG Patches to Distributions"; set -x
  573. # apply OpenPKG patches to distribution trees
  574. ( cd rpm-%{V_rpm}
  575. sed -e "s;@l_prefix@;%{l_prefix};g" <`SOURCE rpm.patch.bugfix` | ${l_patch} -p0
  576. sed -e "s;@l_prefix@;%{l_prefix};g" <`SOURCE rpm.patch.feature` | ${l_patch} -p0
  577. sed -e "s;@l_prefix@;%{l_prefix};g" <`SOURCE rpm.patch.porting` | ${l_patch} -p0
  578. sed -e "s;@l_prefix@;%{l_prefix};g" <`SOURCE rpm.patch.regen` | ${l_patch} -p0
  579. rm -rf db/docs # just reduce disk size of source tree
  580. ) || exit $?
  581. ( cd make-%{V_make}
  582. ${l_patch} -p0 <`SOURCE make.patch`
  583. ) || exit $?
  584. ( cd bash-%{V_bash}
  585. ${l_patch} -p0 <`SOURCE bash.patch`
  586. sh $shtool subst \
  587. -e 's;@l_openpkg_release@;OpenPKG;' \
  588. version.c
  589. sleep 1
  590. touch y.tab.[ch]
  591. ) || exit $?
  592. ( cd beecrypt-%{V_beecrypt}
  593. ${l_patch} -p0 <`SOURCE beecrypt.patch`
  594. sh $shtool subst \
  595. -e 's;^[ ][ ]*#;#;' \
  596. aes.c base64.c blowfish.c entropy.c fips186.c fips186.h md5.c \
  597. md5.h mp.c mtprng.c mtprng.h sha1.c sha1.h sha256.c sha256.h timestamp.c
  598. sh $shtool subst \
  599. -e 's;cppglue\.lo;;g' \
  600. -e 's;cppglue\.cxx;;g' \
  601. -e '/^CXX = /s;@CXX@;@CC@;g' \
  602. Makefile.in
  603. sh $shtool subst \
  604. -e '/LINENO: error: C[+]* preprocessor/{N;N;N;N;s/.*/:/;}' \
  605. configure
  606. ) || exit $?
  607. ( cd perl-%{V_perl}
  608. ${l_patch} -p0 <`SOURCE perl.patch`
  609. ) || exit $?
  610. ( cd openssl-%{V_openssl}
  611. ${l_patch} -p0 <`SOURCE openssl.patch`
  612. ) || exit $?
  613. # display verbosity header
  614. set +x; VERBOSE "PREPARATION: Build GNU make (Build Tool)"; set -x
  615. # bootstrap GNU make tool
  616. ( cd make-%{V_make}
  617. CC="${l_cc}" \
  618. ./configure \
  619. --without-libiconv-prefix \
  620. --without-libintl-prefix \
  621. --disable-nls \
  622. --disable-largefile
  623. ${l_make}
  624. ( mv make ..; ${l_make} clean || true; mv ../make . ) || exit $?
  625. ) || exit $?
  626. l_make="`pwd`/make-%{V_make}/make"; export l_make
  627. echo "l_make=\"$l_make\"; export l_make" >>.buildenv
  628. %build
  629. # skip in bootstrap phase 2 (see openpkg.boot)
  630. [ ".$OPENPKG_BOOT" = .1 ] && exit 0
  631. # switch into a temporary build area
  632. cd openpkg-%{version}
  633. . ./.buildenv
  634. # display verbosity header
  635. set +x; VERBOSE "BUILD: Build GNU bash (Bourne-Again Shell)"; set -x
  636. # build GNU bash tool
  637. ( cd bash-%{V_bash}
  638. ( # force disabled wide-character support
  639. echo "ac_cv_header_wchar_h=no"
  640. echo "ac_cv_header_wctype_h=no"
  641. echo "ac_cv_func_mbsrtowcs=no"
  642. # force disabled internationalization support
  643. echo "ac_cv_header_libintl_h=no"
  644. echo "ac_cv_func_gettext=no"
  645. echo "ac_cv_func_textdomain=no"
  646. echo "ac_cv_func_bindtextdomain=no"
  647. echo "ac_cv_lib_intl_bindtextdomain=no"
  648. # disable building with debug symbols
  649. echo "ac_cv_prog_cc_g=no"
  650. ) >config.cache
  651. CC="${l_cc}"
  652. ./configure \
  653. --cache-file=./config.cache \
  654. --prefix=%{l_prefix} \
  655. --without-curses \
  656. --without-gnu-malloc \
  657. --disable-nls
  658. ${l_make} || exit $?
  659. ( mv bash ..; ${l_make} clean || true; mv ../bash . ) || exit $?
  660. ) || exit $?
  661. # display verbosity header
  662. set +x; VERBOSE "BUILD: Build GNU bzip2 (Compression Library)"; set -x
  663. # build BZIP2 library
  664. ( cd bzip2-%{V_bzip2}
  665. ${l_make} CC="${l_cc}" CFLAGS="-O" libbz2.a bzip2 || exit $?
  666. ( echo "# libbz2.la - a libtool library file"
  667. echo "# Generated by ltmain.sh - GNU libtool x.x.x"
  668. echo "dlname=''"
  669. echo "library_names=''"
  670. echo "old_library='libbz2.a'"
  671. echo "dependency_libs=''"
  672. echo "current=0"
  673. echo "age=0"
  674. echo "revision=0"
  675. echo "installed=no"
  676. echo "dlopen=''"
  677. echo "dlpreopen=''"
  678. echo "libdir='%{l_prefix}'"
  679. ) >libbz2.la
  680. ln -s . .libs
  681. ) || exit $?
  682. # display verbosity header
  683. set +x; VERBOSE "BUILD: Build Zlib (Compression Library)"; set -x
  684. # build ZLIB library
  685. ( cd zlib-%{V_zlib}
  686. CC="${l_cc}" CFLAGS="-O" ./configure
  687. ${l_make} CC="${l_cc}" libz.a || exit $? # intentionally do not pass CFLAGS here
  688. ) || exit $?
  689. # display verbosity header
  690. set +x; VERBOSE "BUILD: Build OSSP uuid (UUID Generation Tool)"; set -x
  691. # build OSSP uuid tool
  692. ( cd uuid-%{V_uuid}
  693. CC="${l_cc}" \
  694. CFLAGS="-O" \
  695. GREP="grep" \
  696. ./configure \
  697. --prefix=%{l_prefix} \
  698. --disable-shared
  699. ${l_make} || exit $?
  700. ( mv uuid ..; ${l_make} clean || true; mv ../uuid . ) || exit $?
  701. ) || exit $?
  702. # display verbosity header
  703. set +x; VERBOSE "BUILD: Build Perl (Programming Language)"; set -x
  704. # build Perl tool
  705. ( cd perl-%{V_perl}
  706. chmod -R u+w .
  707. sh $shtool subst \
  708. -e 's;\(.*for thislib in $libswanted.*\);libswanted=`echo " $libswanted " | sed -e "s/ bind / /g" -e "s/ db / /g" -e "s/ gdbm / /g" -e "s/ iconv / /g"`\; \1;' \
  709. -e 's;package=perl5;package=perl;' \
  710. Configure
  711. sh $shtool subst \
  712. -e 's; */usr/local/lib;;' \
  713. hints/freebsd.sh hints/netbsd.sh
  714. libdirs=""
  715. for dir in %{l_prefix}/lib /lib64 /usr/lib64 /lib /usr/lib /usr/ccs/lib; do
  716. [ -d $dir ] && libdirs="$libdirs $dir"
  717. done
  718. ./Configure \
  719. -d -e -s \
  720. -Dprefix=%{l_prefix} \
  721. -Dvendorprefix=%{l_prefix} \
  722. -Dinstallprefix=%{l_prefix} \
  723. -Dinstallstyle="lib/perl5" \
  724. -Dman1dir=%{l_prefix}/man/man1 \
  725. -Dman3dir=%{l_prefix}/man/man3 \
  726. -Dcc="${l_cc}" -Uoptimize \
  727. -Dlocincpth="%{l_prefix}/include" \
  728. -Dloclibpth="%{l_prefix}/lib" \
  729. -Dldflags="-L""%{l_prefix}/lib" \
  730. -Dlibpth="$libdirs" \
  731. -Dglibpth="$libdirs" \
  732. -Dscriptdir="%{l_prefix}/bin" \
  733. -Uinstallusrbinperl \
  734. -Ui_malloc -Ui_iconv -Ui_db
  735. ${l_make} miniperl || exit $?
  736. rm -f *.o >/dev/null 2>&1 || true
  737. ) || exit $?
  738. l_perl="`pwd`/perl-%{V_perl}/miniperl"; export l_perl
  739. echo "l_perl=\"$l_perl\"; export l_perl" >>.buildenv
  740. # display verbosity header
  741. set +x; VERBOSE "BUILD: Build OpenSSL (Crypography and SSL/TLS Toolkit)"; set -x
  742. # build OpenSSL toolkit
  743. ( cd openssl-%{V_openssl}
  744. sh $shtool subst \
  745. -e 's;-m486;-march=i486;g' \
  746. -e 's;BN_LLONG *;;' \
  747. Configure
  748. sh $shtool subst \
  749. -e 's;test "$OSTYPE" = msdosdjgpp;true;' \
  750. util/point.sh
  751. sh $shtool subst \
  752. -e "1s;^.*\$;#!$l_perl;" \
  753. Configure `find . -name "*.pl" -print`
  754. opts=""
  755. case $plid in
  756. SunOS/* ) opts="-lnsl -lsocket" ;;
  757. esac
  758. CC="${l_cc}" \
  759. PERL="${l_perl}" \
  760. $l_perl ./Configure cc \
  761. --prefix=%{l_prefix} \
  762. no-asm no-shared no-dso \
  763. no-zlib no-idea no-threads no-krb5 no-hw \
  764. $opts
  765. ${l_make} CC="${l_cc}" build_libs build_apps || exit $?
  766. ( mkdir lib; cd lib; ln -s ../lib*.a . ) || exit $?
  767. ) || exit $?
  768. # display verbosity header
  769. set +x; VERBOSE "BUILD: Build cURL (URL Fetching Tool)"; set -x
  770. # build cURL tool
  771. ( cd curl-%{V_curl}
  772. sh $shtool subst \
  773. -e '/LINENO: error: C[+]* preprocessor/{N;N;N;N;s/.*/:/;}' \
  774. configure
  775. ( echo 'ac_cv_header_openssl_engine_h=no'
  776. echo 'lt_cv_prog_compiler_c_o_F77=no'
  777. echo 'lt_cv_sys_max_cmd_len=100'
  778. ) >config.cache
  779. CC="${l_cc}" \
  780. CFLAGS="-I`pwd`/../zlib-%{V_zlib}" \
  781. CPPFLAGS="-I`pwd`/../zlib-%{V_zlib}" \
  782. LDFLAGS="-L`pwd`/../zlib-%{V_zlib}" \
  783. GREP="grep" \
  784. ./configure \
  785. --cache-file=./config.cache \
  786. --without-libidn \
  787. --disable-shared \
  788. --disable-thread \
  789. --disable-ipv6 \
  790. --with-zlib=`pwd`/../zlib-%{V_zlib} \
  791. --with-ssl=`pwd`/../openssl-%{V_openssl} \
  792. --with-ca-bundle=%{l_prefix}/etc/openpkg/openpkg.x509
  793. ${l_make} || exit $?
  794. ( mv src/curl ..; ${l_make} clean || true; mv ../curl ./src ) || exit $?
  795. ) || exit $?
  796. # display verbosity header
  797. set +x; VERBOSE "BUILD: Build BeeCrypt (Cryptography Library)"; set -x
  798. # build BeeCrypt library
  799. ( cd beecrypt-%{V_beecrypt}
  800. ( echo 'ac_cv_have_dev_dsp=no'
  801. echo 'ac_cv_have_dev_audio=no'
  802. echo 'ac_cv_func_gettimeofday=yes'
  803. echo 'bc_cv_as_noexecstack=no'
  804. ) >config.cache
  805. CC="${l_cc}" \
  806. CFLAGS="-O" \
  807. ./configure \
  808. --cache-file=./config.cache \
  809. --prefix=%{l_prefix} \
  810. --without-cplusplus \
  811. --without-java \
  812. --without-python \
  813. --with-cpu=none \
  814. --with-arch=none \
  815. --disable-threads \
  816. --disable-shared
  817. ${l_make} || exit $?
  818. cp .libs/libbeecrypt.a .
  819. ) || exit $?
  820. # display verbosity header
  821. set +x; VERBOSE "BUILD: Build RPM (RedHat Package Manager)"; set -x
  822. # build RPM
  823. ( br=`pwd`
  824. cd rpm-%{V_rpm}
  825. # remove object files accidentally distributed with the RPM tarball
  826. rm -f db/build_unix/*.o
  827. rm -f db/build_unix/*.lo
  828. # remove embedded zlib (we are linking with an external one)
  829. rm -rf zlib
  830. # kill Linux-based preconfigured DB header, to allow the Makefiles to
  831. # symlink to it the header that is configured for the current system.
  832. rm -f rpmdb/db.h
  833. # make sure we do not trigger Autoconf/Automake tools
  834. touch configure
  835. touch config.h.in
  836. # disable running of any Autoconf/Automake tools
  837. ACLOCAL=true
  838. AUTOCONF=true
  839. AUTOMAKE=true
  840. AUTOHEADER=true
  841. MAKEINFO=true
  842. AMTAR=true
  843. export ACLOCAL AUTOMAKE AUTOHEADER MAKEINFO AMTAR
  844. # cheat GNU Autoconf
  845. ( echo 'ac_cv_path_MSGFMT=:'
  846. echo 'ac_cv_path_GMSGFMT=:'
  847. echo 'ac_cv_path_XGETTEXT=:'
  848. echo 'ac_cv_path_MSGMERGE=:'
  849. echo "ac_cv_path_MKDIR='%{l_prefix}/lib/openpkg/shtool mkdir -f -p -m 755'"
  850. echo "ac_cv_path___MKDIR='%{l_prefix}/lib/openpkg/shtool mkdir -f -p -m 755'"
  851. echo "ac_cv_path___PYTHON=true"
  852. echo "ac_cv_path___DOXYGEN=true"
  853. echo "acl_cv_rpath=no"
  854. echo "ac_cv_header_getopt_h=no"
  855. ) >config.cache
  856. # provide platform identification
  857. os_name=`(uname -s) 2>/dev/null` || os_name='Unknown'
  858. os_name=`echo "${os_name}" |\
  859. sed -e 's;[^a-zA-Z0-9];;g' |\
  860. tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
  861. # set build tool flags
  862. CC="${l_cc}"
  863. CPPFLAGS="-DOPENPKG -DOPENPKG_${os_name} -I$br/zlib-%{V_zlib} -I$br/bzip2-%{V_bzip2} -I$br/beecrypt-%{V_beecrypt}"
  864. CFLAGS="$CPPFLAGS"
  865. LDFLAGS="-L$br/zlib-%{V_zlib} -L$br/bzip2-%{V_bzip2} -L$br/beecrypt-%{V_beecrypt}"
  866. LIBS="$LDFLAGS -lz -lbz2 -lbeecrypt"
  867. case $os_name in
  868. SUNOS* ) LIBS="$LIBS -lresolv" ;;
  869. IRIX* ) LIBS="$LIBS -lgen" ;;
  870. esac
  871. export CC CPPFLAGS CFLAGS LDFLAGS LIBS
  872. # adjust for BeeCrypt 4.0
  873. sh $shtool subst \
  874. -e 's;beecrypt\.api\.h;beecrypt.h;g' \
  875. rpmio/rpmio_internal.h
  876. sh $shtool subst \
  877. -e 's;\(rsavrfy(\)\(&dig->rsa_pk\);\1\2.n, \2.e;g' \
  878. lib/signature.c
  879. # configure the package
  880. sh ./configure \
  881. --cache-file=./config.cache \
  882. --prefix=%{l_prefix} \
  883. --with-db \
  884. --with-glob \
  885. --without-python \
  886. --without-apidocs \
  887. --disable-shared \
  888. --disable-rpath \
  889. --disable-nls
  890. # build the package
  891. ${l_make}
  892. ) || exit $?
  893. # build "openpkg" executable
  894. ( cd openpkg-executable-%{V_exec}
  895. ${l_make} \
  896. CC="${l_cc}" \
  897. OPENPKG_PREFIX="%{l_prefix}" \
  898. OPENPKG_SUSR="%{l_susr}" \
  899. OPENPKG_MUSR="%{l_musr}"
  900. ) || exit $?
  901. %install
  902. # skip in bootstrap phase 2 (see openpkg.boot)
  903. [ ".$OPENPKG_BOOT" = .1 ] && exit 0
  904. # switch into a temporary build area
  905. cd openpkg-%{version}
  906. . ./.buildenv
  907. # display verbosity header
  908. set +x; VERBOSE "INSTALL: Create Installation Filesystem Hierarchy"; set -x
  909. # create installation hierarchy
  910. rm -rf $RPM_BUILD_ROOT
  911. sh $shtool mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}
  912. for dir in bin etc include info lib libexec man sbin share var cgi pub local; do
  913. test -d $RPM_BUILD_ROOT%{l_prefix}/$dir || \
  914. mkdir $RPM_BUILD_ROOT%{l_prefix}/$dir
  915. done
  916. for i in 1 2 3 4 5 6 7 8 9; do
  917. test -d $RPM_BUILD_ROOT%{l_prefix}/man/man$i || \
  918. mkdir $RPM_BUILD_ROOT%{l_prefix}/man/man$i
  919. test -d $RPM_BUILD_ROOT%{l_prefix}/man/cat$i || \
  920. mkdir $RPM_BUILD_ROOT%{l_prefix}/man/cat$i
  921. done
  922. for dir in PKG bin etc include info lib man sbin; do
  923. test -d $RPM_BUILD_ROOT%{l_prefix}/local/$dir || \
  924. mkdir $RPM_BUILD_ROOT%{l_prefix}/local/$dir
  925. done
  926. for i in 1 2 3 4 5 6 7 8 9; do
  927. test -d $RPM_BUILD_ROOT%{l_prefix}/local/man/man$i || \
  928. mkdir $RPM_BUILD_ROOT%{l_prefix}/local/man/man$i
  929. test -d $RPM_BUILD_ROOT%{l_prefix}/local/man/cat$i || \
  930. mkdir $RPM_BUILD_ROOT%{l_prefix}/local/man/cat$i
  931. done
  932. test -d $RPM_BUILD_ROOT%{l_prefix}/RPM || \
  933. mkdir $RPM_BUILD_ROOT%{l_prefix}/RPM
  934. for dir in SRC PKG DB TMP; do
  935. test -d $RPM_BUILD_ROOT%{l_prefix}/RPM/$dir || \
  936. mkdir $RPM_BUILD_ROOT%{l_prefix}/RPM/$dir
  937. done
  938. mkdir $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg
  939. mkdir $RPM_BUILD_ROOT%{l_prefix}/include/openpkg
  940. # display verbosity header
  941. set +x; VERBOSE "INSTALL: Installation of RPM"; set -x
  942. # install RPM into installation hierarchy
  943. ( cd rpm-%{V_rpm}
  944. DESTDIR="$RPM_BUILD_ROOT"
  945. export DESTDIR
  946. ${l_make} install
  947. ) || exit $?
  948. # display verbosity header
  949. set +x; VERBOSE "INSTALL: Stripping Down Installation"; set -x
  950. # strip RPM installation
  951. ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/bin/* \
  952. $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/* >/dev/null 2>&1 || true
  953. for dir in man/ja man/pl man/ru man/sk src; do
  954. rm -rf $RPM_BUILD_ROOT%{l_prefix}/$dir >/dev/null 2>&1 || true
  955. done
  956. rm -rf $RPM_BUILD_ROOT/var >/dev/null 2>&1 || true
  957. for file in rpme rpmi rpmsign rpmu rpmverify rpmquery gendiff; do
  958. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/$file >/dev/null 2>&1 || true
  959. done
  960. rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/* >/dev/null 2>&1 || true
  961. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/* >/dev/null 2>&1 || true
  962. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man3/* >/dev/null 2>&1 || true
  963. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/rpmpopt >/dev/null 2>&1 || true
  964. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/rpmrc >/dev/null 2>&1 || true
  965. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/lib*.la >/dev/null 2>&1 || true
  966. rm -rf $RPM_BUILD_ROOT%{l_prefix}/var/lib >/dev/null 2>&1 || true
  967. for file in \
  968. u_pkg.sh vpkg-provides.sh vpkg-provides2.sh rpmdiff.cgi rpmdiff \
  969. perl.prov perl.req mkinstalldirs magic.prov magic.req http.req \
  970. getpo.sh get_magic.pl find-provides find-requires \
  971. find-requires.perl find-req.pl find-provides.perl \
  972. find-prov.pl find-lang.sh cpanflute convertrpmrc.sh check-prereqs \
  973. rpmputtext rpmgettext brp-compress brp-redhat brp-sparc64-linux \
  974. brp-strip brp-strip-shared brp-strip-comment-note rpmrc \
  975. config.guess config.sub check-files; do
  976. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/$file >/dev/null 2>&1 || true
  977. done
  978. # display verbosity header
  979. set +x; VERBOSE "INSTALL: Install Additional Files"; set -x
  980. # add additional development files
  981. cp rpm-%{V_rpm}/misc/glob.h $RPM_BUILD_ROOT%{l_prefix}/include/rpm/
  982. cp zlib-%{V_zlib}/zlib.h $RPM_BUILD_ROOT%{l_prefix}/include/rpm/
  983. cp zlib-%{V_zlib}/zconf.h $RPM_BUILD_ROOT%{l_prefix}/include/rpm/
  984. cp zlib-%{V_zlib}/libz.a $RPM_BUILD_ROOT%{l_prefix}/lib/librpmz.a
  985. cp bzip2-%{V_bzip2}/bzlib.h $RPM_BUILD_ROOT%{l_prefix}/include/rpm/
  986. cp bzip2-%{V_bzip2}/libbz2.a $RPM_BUILD_ROOT%{l_prefix}/lib/librpmbz2.a
  987. cp beecrypt-%{V_beecrypt}/beecrypt.h $RPM_BUILD_ROOT%{l_prefix}/include/rpm/
  988. cp beecrypt-%{V_beecrypt}/libbeecrypt.a $RPM_BUILD_ROOT%{l_prefix}/lib/librpmbeecrypt.a
  989. # display verbosity header
  990. set +x; VERBOSE "INSTALL: Post-Adjust Installation"; set -x
  991. # post-adjust RPM installation (namespace-clean POPT inclusion)
  992. mv $RPM_BUILD_ROOT%{l_prefix}/lib/libpopt.a \
  993. $RPM_BUILD_ROOT%{l_prefix}/lib/librpmpopt.a
  994. mv $RPM_BUILD_ROOT%{l_prefix}/include/popt.h \
  995. $RPM_BUILD_ROOT%{l_prefix}/include/rpm/popt.h
  996. # move C API into custom locations
  997. mv $RPM_BUILD_ROOT%{l_prefix}/include/rpm \
  998. $RPM_BUILD_ROOT%{l_prefix}/include/openpkg/rpm
  999. mv $RPM_BUILD_ROOT%{l_prefix}/lib/librpm* \
  1000. $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/
  1001. # replace symlinks with hardlinks
  1002. for entry in rpme:rpmi rpmt:rpmb rpmu:rpmi rpmv:rpmq; do
  1003. eval `echo $entry | sed -e 's/^\(.*\):\(.*\)$/dst=\1; src=\2/'`
  1004. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/$dst
  1005. ln $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/$src \
  1006. $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/$dst
  1007. done
  1008. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/rpmbuild
  1009. ln $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmb \
  1010. $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpmbuild
  1011. mv $RPM_BUILD_ROOT%{l_prefix}/man/man8/rpmbuild.8 \
  1012. $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpmbuild.8
  1013. # display verbosity header
  1014. set +x; VERBOSE "INSTALL: Install Additional Tools"; set -x
  1015. # install lsync tool
  1016. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1017. <`SOURCE lsync` \
  1018. >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/lsync
  1019. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/lsync
  1020. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1021. <`SOURCE dot.lsyncrc` \
  1022. >$RPM_BUILD_ROOT%{l_prefix}/local/.lsyncrc
  1023. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1024. <`SOURCE lsync.8` \
  1025. >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/lsync.8
  1026. # install rpm-config tool
  1027. ( l_prefix="%{l_prefix}"
  1028. l_cc="%{l_cc}"
  1029. l_cflags=""
  1030. l_cppflags="-DOPENPKG -I${l_prefix}/include/openpkg/rpm -I${l_prefix}/include/openpkg"
  1031. l_ldflags="-L${l_prefix}/lib/openpkg"
  1032. l_libs="-lrpmbuild -lrpm -lrpmio -lrpmdb -lrpmpopt -lrpmbeecrypt -lrpmbz2 -lrpmz"
  1033. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1034. -e "s:@l_cc@:$l_cc:g" \
  1035. -e "s:@l_cflags@:$l_cflags:g" \
  1036. -e "s:@l_cppflags@:$l_cppflags:g" \
  1037. -e "s:@l_ldflags@:$l_ldflags:g" \
  1038. -e "s:@l_libs@:$l_libs:g" \
  1039. -e "s:@l_version@:%{V_rpm}:g" \
  1040. <`SOURCE rpm-config.sh` \
  1041. >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm-config
  1042. ) || exit $?
  1043. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm-config
  1044. sed -e "s:RPM_VERSION:%{V_rpm}:g" \
  1045. <`SOURCE rpm-config.8` \
  1046. >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm-config.8
  1047. # move rpm2cpio tool to custom location
  1048. mv $RPM_BUILD_ROOT%{l_prefix}/bin/rpm2cpio \
  1049. $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm2cpio
  1050. mv $RPM_BUILD_ROOT%{l_prefix}/man/man8/rpm2cpio.8 \
  1051. $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm2cpio.8
  1052. # move rpm tool to custom location
  1053. mv $RPM_BUILD_ROOT%{l_prefix}/bin/rpm \
  1054. $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm
  1055. mv $RPM_BUILD_ROOT%{l_prefix}/man/man8/rpm.8 \
  1056. $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm.8
  1057. # install OpenPKG registry commands
  1058. ( cd openpkg-registry-%{V_registry}
  1059. mv $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm \
  1060. $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpm
  1061. sed -e "s;@l_prefix@;%{l_prefix};g" \
  1062. rpm.sh >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm
  1063. chmod 755 $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm
  1064. sed -e "s;@l_prefix@;%{l_prefix};g" \
  1065. register.sh >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/register
  1066. chmod 755 $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/register
  1067. cp register.8 $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/register.8
  1068. ) || exit $?
  1069. # install OpenPKG Tool Chain command subset
  1070. ( cd openpkg-tools-%{V_tools}
  1071. cp cmd/build.pl $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/build.pl
  1072. chmod 644 $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/build.pl
  1073. cp cmd/build.8 $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/build.8
  1074. ) || exit $?
  1075. # install RPM extension
  1076. ( cd rpm-%{V_rpm}
  1077. cp file/file $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/file
  1078. ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/file
  1079. ) || exit $?
  1080. ( cd perl-%{V_perl}
  1081. cp miniperl $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/miniperl
  1082. ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/miniperl
  1083. ) || exit $?
  1084. ( cd openssl-%{V_openssl}
  1085. cp apps/openssl $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/openssl
  1086. ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/openssl
  1087. ) || exit $?
  1088. ( cd curl-%{V_curl}
  1089. cp src/curl $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/curl
  1090. ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/curl
  1091. ) || exit $?
  1092. ( cd bzip2-%{V_bzip2}
  1093. cp bzip2 $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bzip2
  1094. ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bzip2
  1095. ) || exit $?
  1096. ( cd gzip-%{V_gzip}
  1097. cp gzip $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/gzip
  1098. ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/gzip
  1099. ) || exit $?
  1100. ( cd patch-%{V_patch}
  1101. cp patch $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/patch
  1102. ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/patch
  1103. ) || exit $?
  1104. ( cd tar-%{V_tar}
  1105. cp tar $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/tar
  1106. ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/tar
  1107. ) || exit $?
  1108. ( cd bash-%{V_bash}
  1109. cp bash $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bash
  1110. ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bash
  1111. ) || exit $?
  1112. ( cd uuid-%{V_uuid}
  1113. cp uuid $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/uuid
  1114. ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/uuid
  1115. ) || exit $?
  1116. sed -e "s;@l_prefix@;%{l_prefix};g" \
  1117. -e "s;@l_musr@;%{l_musr};g" \
  1118. -e "s;@l_mgrp@;%{l_mgrp};g" \
  1119. <`SOURCE uuid.sh` >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/uuid
  1120. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/uuid
  1121. sed -e "s;@l_prefix@;%{l_prefix};g" \
  1122. <`SOURCE uuid.8` >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/uuid.8
  1123. sed -e "s;@l_prefix@;%{l_prefix};g" \
  1124. <`SOURCE release.sh` >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/release
  1125. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/release
  1126. sed -e "s;@l_prefix@;%{l_prefix};g" \
  1127. <`SOURCE release.8` >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/release.8
  1128. sed -e "s;@l_prefix@;%{l_prefix};g" \
  1129. -e "s;@l_musr@;%{l_musr};g" \
  1130. -e "s;@l_mgrp@;%{l_mgrp};g" \
  1131. <`SOURCE rpmdb` >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmdb
  1132. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmdb
  1133. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1134. <`SOURCE rpmtool` >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmtool
  1135. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmtool
  1136. # install OpenPKG tool chain execution frontend and execution wrapper
  1137. cp openpkg-executable-%{V_exec}/openpkg $RPM_BUILD_ROOT%{l_prefix}/bin/openpkg
  1138. ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/bin/openpkg
  1139. chmod 4775 $RPM_BUILD_ROOT%{l_prefix}/bin/openpkg
  1140. sed -e "s;@l_prefix@;%{l_prefix};g" \
  1141. <`SOURCE openpkg.sh` >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/openpkg
  1142. chmod 755 $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/openpkg
  1143. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1144. <`SOURCE openpkg.1` \
  1145. >$RPM_BUILD_ROOT%{l_prefix}/man/man1/openpkg.1
  1146. # install more OpenPKG tool chain commands
  1147. sed -e "s;@l_prefix@;%{l_prefix};g" \
  1148. <`SOURCE install.sh` >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/install
  1149. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/install
  1150. sed -e "s;@l_prefix@;%{l_prefix};g" \
  1151. <`SOURCE man.sh` >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/man
  1152. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/man
  1153. # install an own copy of shtool
  1154. cp $shtool $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/shtool
  1155. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/shtool
  1156. # display verbosity header
  1157. set +x; VERBOSE "INSTALL: Install Configuration Files"; set -x
  1158. # install a few README files
  1159. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1160. <`SOURCE root.README` \
  1161. >$RPM_BUILD_ROOT%{l_prefix}/README
  1162. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1163. <`SOURCE local.README` \
  1164. >$RPM_BUILD_ROOT%{l_prefix}/local/README
  1165. # install Bash environment
  1166. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1167. <`SOURCE dot.bashrc` \
  1168. >$RPM_BUILD_ROOT%{l_prefix}/.bashrc
  1169. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1170. <`SOURCE dot.bash_login` \
  1171. >$RPM_BUILD_ROOT%{l_prefix}/.bash_login
  1172. # install Run-Command files
  1173. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1174. -e "s:@l_susr@:%{l_susr}:g" \
  1175. -e "s:@l_musr@:%{l_musr}:g" \
  1176. <`SOURCE rc` \
  1177. >$RPM_BUILD_ROOT%{l_prefix}/etc/rc
  1178. chmod 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc
  1179. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1180. <`SOURCE rc.conf` \
  1181. >$RPM_BUILD_ROOT%{l_prefix}/etc/rc.conf
  1182. chmod 644 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.conf
  1183. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1184. <`SOURCE rc.func` \
  1185. >$RPM_BUILD_ROOT%{l_prefix}/etc/rc.func
  1186. chmod 644 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.func
  1187. mkdir $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  1188. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1189. <`SOURCE rc.openpkg` \
  1190. >$RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/rc.openpkg
  1191. chmod 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/rc.openpkg
  1192. ( echo "#!/bin/sh"
  1193. echo "exec %{l_prefix}/etc/rc \${1+\"\$@\"}"
  1194. ) >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rc
  1195. chmod 755 $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rc
  1196. ln $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rc \
  1197. $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rc
  1198. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1199. <`SOURCE rc.8` \
  1200. >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rc.8
  1201. # create configuration directory
  1202. test -d $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg || \
  1203. mkdir $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg
  1204. # install platform identification file
  1205. sh $shtool platform -n -L -S "" -C "+" -F "%<ap>-any-%<sp>" \
  1206. >$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/platform
  1207. chmod 644 $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/platform
  1208. # install UUID configuration file (ghost)
  1209. touch $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/uuid
  1210. chmod 644 $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/uuid
  1211. # install registry configuration files (ghost)
  1212. touch \
  1213. $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.prep \
  1214. $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.tran \
  1215. $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.util
  1216. chmod 644 \
  1217. $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.prep \
  1218. $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.tran \
  1219. $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.util
  1220. # install default managers configuration file
  1221. ( echo "##"
  1222. echo "## managers -- OpenPKG Instance Managers"
  1223. echo "##"
  1224. echo ""
  1225. echo "%{l_susr}"
  1226. echo "%{l_musr}"
  1227. echo ""
  1228. ) >$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/managers
  1229. # install overriding RPM configuration files
  1230. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1231. <`SOURCE rpmpopt` \
  1232. >>$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmpopt
  1233. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1234. <`SOURCE rpmrc` \
  1235. >$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/rpmrc
  1236. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1237. -e "s:@l_prefix_static@:%{l_prefix}:g" \
  1238. -e "s;@l_build_path@;$l_build_path;g" \
  1239. -e "s;@l_build_ldlp@;$l_build_ldlp;g" \
  1240. -e "s;@l_build_ulim@;$l_build_ulim;g" \
  1241. -e "s:@TAG@:$tag:g" \
  1242. -e "s:@SUSR@:$susr:g" \
  1243. -e "s:@SGRP@:$sgrp:g" \
  1244. -e "s:@MUSR@:$musr:g" \
  1245. -e "s:@MGRP@:$mgrp:g" \
  1246. -e "s:@RUSR@:$rusr:g" \
  1247. -e "s:@RGRP@:$rgrp:g" \
  1248. -e "s:@NUSR@:$nusr:g" \
  1249. -e "s:@NGRP@:$ngrp:g" \
  1250. <`SOURCE rpmmacros` \
  1251. >$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/rpmmacros
  1252. cp `SOURCE openpkg.org.pgp` \
  1253. $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/openpkg.org.pgp
  1254. cp `SOURCE openpkg.com.pgp` \
  1255. $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/openpkg.com.pgp
  1256. cp `SOURCE openpkg.net.pgp` \
  1257. $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/openpkg.net.pgp
  1258. # display verbosity header
  1259. set +x; VERBOSE "INSTALL: Done. Thank you for flying OpenPKG..."; set -x
  1260. %files
  1261. %defattr(-,%{?l_musr}%{!?l_musr:%{l_fsusr}},%{?l_mgrp}%{!?l_mgrp:%{l_fsgrp}})
  1262. %{l_prefix}/README
  1263. %config(noreplace) %{l_prefix}/.bashrc
  1264. %config(noreplace) %{l_prefix}/.bash_login
  1265. %dir %{l_prefix}/RPM
  1266. %dir %{l_prefix}/RPM/SRC
  1267. %dir %{l_prefix}/RPM/PKG
  1268. %dir %{l_prefix}/RPM/DB
  1269. %dir %{l_prefix}/RPM/TMP
  1270. %dir %{l_prefix}/cgi
  1271. %dir %{l_prefix}/bin
  1272. %attr(4755,%{l_susr},%{l_mgrp}) %{l_prefix}/bin/openpkg
  1273. %dir %{l_prefix}/etc
  1274. %{l_prefix}/etc/rc
  1275. %config(noreplace) %{l_prefix}/etc/rc.conf
  1276. %{l_prefix}/etc/rc.func
  1277. %dir %{l_prefix}/etc/rc.d
  1278. %{l_prefix}/etc/rc.d/rc.openpkg
  1279. %dir %{l_prefix}/etc/openpkg
  1280. %ghost %{l_prefix}/etc/openpkg/uuid
  1281. %config %{l_prefix}/etc/openpkg/platform
  1282. %config %{l_prefix}/etc/openpkg/rpmmacros
  1283. %config %{l_prefix}/etc/openpkg/rpmrc
  1284. %ghost %{l_prefix}/etc/openpkg/register.prep
  1285. %ghost %{l_prefix}/etc/openpkg/register.tran
  1286. %ghost %{l_prefix}/etc/openpkg/register.util
  1287. %config %attr(664,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/openpkg/managers
  1288. %{l_prefix}/etc/openpkg/openpkg.org.pgp
  1289. %{l_prefix}/etc/openpkg/openpkg.com.pgp
  1290. %{l_prefix}/etc/openpkg/openpkg.net.pgp
  1291. %dir %{l_prefix}/include
  1292. %dir %{l_prefix}/include/openpkg
  1293. %dir %{l_prefix}/include/openpkg/rpm
  1294. %{l_prefix}/include/openpkg/rpm/argv.h
  1295. %{l_prefix}/include/openpkg/rpm/beecrypt.h
  1296. %{l_prefix}/include/openpkg/rpm/bzlib.h
  1297. %{l_prefix}/include/openpkg/rpm/db.h
  1298. %{l_prefix}/include/openpkg/rpm/fts.h
  1299. %{l_prefix}/include/openpkg/rpm/glob.h
  1300. %{l_prefix}/include/openpkg/rpm/hdrinline.h
  1301. %{l_prefix}/include/openpkg/rpm/header.h
  1302. %{l_prefix}/include/openpkg/rpm/misc.h
  1303. %{l_prefix}/include/openpkg/rpm/popt.h
  1304. %{l_prefix}/include/openpkg/rpm/rpmal.h
  1305. %{l_prefix}/include/openpkg/rpm/rpmbuild.h
  1306. %{l_prefix}/include/openpkg/rpm/rpmcli.h
  1307. %{l_prefix}/include/openpkg/rpm/rpmdb.h
  1308. %{l_prefix}/include/openpkg/rpm/rpmds.h
  1309. %{l_prefix}/include/openpkg/rpm/rpmerr.h
  1310. %{l_prefix}/include/openpkg/rpm/rpmfc.h
  1311. %{l_prefix}/include/openpkg/rpm/rpmfi.h
  1312. %{l_prefix}/include/openpkg/rpm/rpmfile.h
  1313. %{l_prefix}/include/openpkg/rpm/rpmhash.h
  1314. %{l_prefix}/include/openpkg/rpm/rpmio.h
  1315. %{l_prefix}/include/openpkg/rpm/rpmlib.h
  1316. %{l_prefix}/include/openpkg/rpm/rpmlog.h
  1317. %{l_prefix}/include/openpkg/rpm/rpmmacro.h
  1318. %{l_prefix}/include/openpkg/rpm/rpmmessages.h
  1319. %{l_prefix}/include/openpkg/rpm/rpmpgp.h
  1320. %{l_prefix}/include/openpkg/rpm/rpmps.h
  1321. %{l_prefix}/include/openpkg/rpm/rpmspec.h
  1322. %{l_prefix}/include/openpkg/rpm/rpmsw.h
  1323. %{l_prefix}/include/openpkg/rpm/rpmte.h
  1324. %{l_prefix}/include/openpkg/rpm/rpmts.h
  1325. %{l_prefix}/include/openpkg/rpm/rpmurl.h
  1326. %{l_prefix}/include/openpkg/rpm/stringbuf.h
  1327. %{l_prefix}/include/openpkg/rpm/ugid.h
  1328. %{l_prefix}/include/openpkg/rpm/zlib.h
  1329. %{l_prefix}/include/openpkg/rpm/zconf.h
  1330. %dir %{l_prefix}/info
  1331. %dir %{l_prefix}/lib
  1332. %dir %{l_prefix}/lib/openpkg
  1333. %{l_prefix}/lib/openpkg/bash
  1334. %{l_prefix}/lib/openpkg/bzip2
  1335. %{l_prefix}/lib/openpkg/uuid
  1336. %{l_prefix}/lib/openpkg/miniperl
  1337. %{l_prefix}/lib/openpkg/openssl
  1338. %{l_prefix}/lib/openpkg/curl
  1339. %{l_prefix}/lib/openpkg/file
  1340. %{l_prefix}/lib/openpkg/gzip
  1341. %{l_prefix}/lib/openpkg/macros
  1342. %{l_prefix}/lib/openpkg/magic
  1343. %{l_prefix}/lib/openpkg/magic.mgc
  1344. %{l_prefix}/lib/openpkg/magic.mime
  1345. %{l_prefix}/lib/openpkg/magic.mime.mgc
  1346. %{l_prefix}/lib/openpkg/patch
  1347. %{l_prefix}/lib/openpkg/rc
  1348. %{l_prefix}/lib/openpkg/rpm
  1349. %{l_prefix}/lib/openpkg/rpmb
  1350. %{l_prefix}/lib/openpkg/rpmd
  1351. %{l_prefix}/lib/openpkg/rpmdb
  1352. %{l_prefix}/lib/openpkg/rpmdb_dump
  1353. %{l_prefix}/lib/openpkg/rpmdb_load
  1354. %{l_prefix}/lib/openpkg/rpmdb_verify
  1355. %{l_prefix}/lib/openpkg/rpme
  1356. %{l_prefix}/lib/openpkg/rpmi
  1357. %{l_prefix}/lib/openpkg/rpmk
  1358. %{l_prefix}/lib/openpkg/rpmpopt
  1359. %{l_prefix}/lib/openpkg/rpmq
  1360. %{l_prefix}/lib/openpkg/rpmt
  1361. %{l_prefix}/lib/openpkg/rpmtool
  1362. %{l_prefix}/lib/openpkg/rpmu
  1363. %{l_prefix}/lib/openpkg/rpmv
  1364. %{l_prefix}/lib/openpkg/shtool
  1365. %{l_prefix}/lib/openpkg/tar
  1366. %{l_prefix}/lib/openpkg/librpm.a
  1367. %{l_prefix}/lib/openpkg/librpmbeecrypt.a
  1368. %{l_prefix}/lib/openpkg/librpmbuild.a
  1369. %{l_prefix}/lib/openpkg/librpmbz2.a
  1370. %{l_prefix}/lib/openpkg/librpmdb.a
  1371. %{l_prefix}/lib/openpkg/librpmio.a
  1372. %{l_prefix}/lib/openpkg/librpmpopt.a
  1373. %{l_prefix}/lib/openpkg/librpmz.a
  1374. %{l_prefix}/lib/openpkg/openpkg
  1375. %dir %{l_prefix}/libexec
  1376. %dir %{l_prefix}/libexec/openpkg
  1377. %{l_prefix}/libexec/openpkg/uuid
  1378. %{l_prefix}/libexec/openpkg/uuid.8
  1379. %{l_prefix}/libexec/openpkg/man
  1380. %{l_prefix}/libexec/openpkg/build.pl
  1381. %{l_prefix}/libexec/openpkg/build.8
  1382. %{l_prefix}/libexec/openpkg/install
  1383. %{l_prefix}/libexec/openpkg/lsync
  1384. %{l_prefix}/libexec/openpkg/lsync.8
  1385. %{l_prefix}/libexec/openpkg/rc
  1386. %{l_prefix}/libexec/openpkg/rc.8
  1387. %{l_prefix}/libexec/openpkg/rpm-config
  1388. %{l_prefix}/libexec/openpkg/rpm-config.8
  1389. %{l_prefix}/libexec/openpkg/rpm2cpio
  1390. %{l_prefix}/libexec/openpkg/rpm2cpio.8
  1391. %{l_prefix}/libexec/openpkg/rpmbuild
  1392. %{l_prefix}/libexec/openpkg/rpmbuild.8
  1393. %{l_prefix}/libexec/openpkg/rpm
  1394. %{l_prefix}/libexec/openpkg/rpm.8
  1395. %{l_prefix}/libexec/openpkg/register
  1396. %{l_prefix}/libexec/openpkg/register.8
  1397. %{l_prefix}/libexec/openpkg/release
  1398. %{l_prefix}/libexec/openpkg/release.8
  1399. %dir %{l_prefix}/man
  1400. %dir %{l_prefix}/man/man1
  1401. %dir %{l_prefix}/man/man2
  1402. %dir %{l_prefix}/man/man3
  1403. %dir %{l_prefix}/man/man4
  1404. %dir %{l_prefix}/man/man5
  1405. %dir %{l_prefix}/man/man6
  1406. %dir %{l_prefix}/man/man7
  1407. %dir %{l_prefix}/man/man8
  1408. %dir %{l_prefix}/man/man9
  1409. %dir %{l_prefix}/man/cat1
  1410. %dir %{l_prefix}/man/cat2
  1411. %dir %{l_prefix}/man/cat3
  1412. %dir %{l_prefix}/man/cat4
  1413. %dir %{l_prefix}/man/cat5
  1414. %dir %{l_prefix}/man/cat6
  1415. %dir %{l_prefix}/man/cat7
  1416. %dir %{l_prefix}/man/cat8
  1417. %dir %{l_prefix}/man/cat9
  1418. %{l_prefix}/man/man1/openpkg.1
  1419. %dir %{l_prefix}/sbin
  1420. %dir %{l_prefix}/pub
  1421. %dir %{l_prefix}/share
  1422. %dir %{l_prefix}/var
  1423. %dir %{l_prefix}/local
  1424. %{l_prefix}/local/README
  1425. %{l_prefix}/local/.lsyncrc
  1426. %dir %{l_prefix}/local/PKG
  1427. %dir %{l_prefix}/local/bin
  1428. %dir %{l_prefix}/local/etc
  1429. %dir %{l_prefix}/local/include
  1430. %dir %{l_prefix}/local/info
  1431. %dir %{l_prefix}/local/lib
  1432. %dir %{l_prefix}/local/man
  1433. %dir %{l_prefix}/local/man/man1
  1434. %dir %{l_prefix}/local/man/man2
  1435. %dir %{l_prefix}/local/man/man3
  1436. %dir %{l_prefix}/local/man/man4
  1437. %dir %{l_prefix}/local/man/man5
  1438. %dir %{l_prefix}/local/man/man6
  1439. %dir %{l_prefix}/local/man/man7
  1440. %dir %{l_prefix}/local/man/man8
  1441. %dir %{l_prefix}/local/man/man9
  1442. %dir %{l_prefix}/local/man/cat1
  1443. %dir %{l_prefix}/local/man/cat2
  1444. %dir %{l_prefix}/local/man/cat3
  1445. %dir %{l_prefix}/local/man/cat4
  1446. %dir %{l_prefix}/local/man/cat5
  1447. %dir %{l_prefix}/local/man/cat6
  1448. %dir %{l_prefix}/local/man/cat7
  1449. %dir %{l_prefix}/local/man/cat8
  1450. %dir %{l_prefix}/local/man/cat9
  1451. %dir %{l_prefix}/local/sbin
  1452. %clean
  1453. # skip in bootstrap phase 2 (see openpkg.boot)
  1454. [ ".$OPENPKG_BOOT" = .1 ] && exit 0
  1455. # cleanup build area
  1456. rm -rf openpkg-%{version} >/dev/null 2>&1 || true
  1457. # cleanup installation area
  1458. rm -rf $RPM_BUILD_ROOT >/dev/null 2>&1 || true
  1459. %pre
  1460. # always performed for upgrades and because it doesn't harm!
  1461. # [ ".$1" != .1 ] && exit 0
  1462. # this procedure is only usable with root privileges
  1463. # (for non-root installations it is not required at all)
  1464. cusr=`(id -un) 2>/dev/null ||\
  1465. (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
  1466. (whoami) 2>/dev/null ||\
  1467. (who am i | cut "-d " -f1) 2>/dev/null ||\
  1468. echo $LOGNAME`
  1469. # determine runtime details (for both inside and outside RPM!!)
  1470. # - bootstrapping: $xxx is set from aux.wrapbin.sh
  1471. # - upgrading new: %{l_[smrn]{usr,grp}} is set via rpmmacros
  1472. # - upgrading old: %{l_[smrn]{usr,grp}} is not set at all
  1473. [ ".$susr" = . ] && susr="%{?l_susr}%{!?l_susr:root}"
  1474. [ ".$sgrp" = . ] && sgrp="%{?l_sgrp}%{!?l_sgrp:wheel}"
  1475. [ ".$musr" = . ] && musr="%{?l_musr}%{!?l_musr:%{l_fsusr}}"
  1476. [ ".$mgrp" = . ] && mgrp="%{?l_mgrp}%{!?l_mgrp:%{l_fsgrp}}"
  1477. [ ".$rusr" = . ] && rusr="%{?l_rusr}%{!?l_rusr:%{l_fsusr}-r}"
  1478. [ ".$rgrp" = . ] && rgrp="%{?l_rgrp}%{!?l_rgrp:%{l_fsgrp}-r}"
  1479. [ ".$nusr" = . ] && nusr="%{?l_nusr}%{!?l_nusr:%{l_fsusr}-n}"
  1480. [ ".$ngrp" = . ] && ngrp="%{?l_ngrp}%{!?l_ngrp:%{l_fsgrp}-n}"
  1481. [ ".$suid" = . ] && suid="%{?l_suid}"
  1482. [ ".$sgid" = . ] && sgid="%{?l_sgid}"
  1483. [ ".$muid" = . ] && muid="%{?l_muid}"
  1484. [ ".$mgid" = . ] && mgid="%{?l_mgid}"
  1485. [ ".$ruid" = . ] && ruid="%{?l_ruid}"
  1486. [ ".$rgid" = . ] && rgid="%{?l_rgid}"
  1487. [ ".$nuid" = . ] && nuid="%{?l_nuid}"
  1488. [ ".$ngid" = . ] && ngid="%{?l_ngid}"
  1489. # if any of these optional params are not used we won't have a
  1490. # corresponding macro either, so make use of one conditionally
  1491. [ ".$suid" = . ] && [ ".%{?l_suid:set}" = .set ] && suid="%{?l_suid}"
  1492. [ ".$sgid" = . ] && [ ".%{?l_sgid:set}" = .set ] && sgid="%{?l_sgid}"
  1493. [ ".$muid" = . ] && [ ".%{?l_muid:set}" = .set ] && muid="%{?l_muid}"
  1494. [ ".$mgid" = . ] && [ ".%{?l_mgid:set}" = .set ] && mgid="%{?l_mgid}"
  1495. [ ".$ruid" = . ] && [ ".%{?l_ruid:set}" = .set ] && ruid="%{?l_ruid}"
  1496. [ ".$rgid" = . ] && [ ".%{?l_rgid:set}" = .set ] && rgid="%{?l_rgid}"
  1497. [ ".$nuid" = . ] && [ ".%{?l_nuid:set}" = .set ] && nuid="%{?l_nuid}"
  1498. [ ".$ngid" = . ] && [ ".%{?l_ngid:set}" = .set ] && ngid="%{?l_ngid}"
  1499. # determine prefix
  1500. [ ".$prefix" = . ] && prefix="%{l_prefix}"
  1501. prefix=`echo "$prefix" | sed -e 's;//*;/;g' -e 's;/$;;'`
  1502. # register the OpenPKG instance in /etc/openpkg
  1503. registry="/etc/openpkg"
  1504. exists=`cat $registry 2>/dev/null | egrep "^ *${prefix} *\$"`
  1505. if [ ".$exists" = . ]; then
  1506. ( umask 022
  1507. echo "${prefix}" >>$registry
  1508. ) 2>/dev/null || true
  1509. fi
  1510. # determine user/group ids
  1511. for class in s m r n; do
  1512. eval "xusr=\"\$${class}usr\""
  1513. eval "xgrp=\"\$${class}grp\""
  1514. eval "xuid=\"\$${class}uid\""
  1515. eval "xgid=\"\$${class}gid\""
  1516. if [ ".$xuid" = . ]; then
  1517. xuid=`(getent passwd "${xusr}"; \
  1518. grep "^${xusr}:" /etc/passwd; \
  1519. ypmatch "${xusr}" passwd; \
  1520. nismatch "${xusr}" passwd; \
  1521. nidump passwd . | grep "^${xusr}:") 2>/dev/null | \
  1522. sed -e 'q' | awk -F: '{ print $3; }'`
  1523. if [ ".$xuid" = . ]; then
  1524. # seek for a reasonably uid/gid pair
  1525. xuid=1000
  1526. ok=0
  1527. while [ ".$ok" = .0 ]; do
  1528. eval "u_exists=\$u_exists_$xuid"
  1529. if [ ".$u_exists" = . ]; then
  1530. u_exists=`(getent passwd; cat /etc/passwd; ypcat passwd; niscat passwd; nidump passwd .) 2>/dev/null |\
  1531. grep "^[^:]*:[^:]*:$xuid:"`
  1532. fi
  1533. eval "g_exists=\$g_exists_$xuid"
  1534. if [ ".$g_exists" = . ]; then
  1535. g_exists=`(getent group; cat /etc/group; ypcat group; niscat group; nidump group .) 2>/dev/null |\
  1536. grep "^[^:]*:[^:]*:$xuid:"`
  1537. fi
  1538. if [ ".$u_exists" = . -a ".$g_exists" = . ]; then
  1539. ok=1
  1540. break
  1541. fi
  1542. xuid=`expr $xuid + 1`
  1543. done
  1544. eval "u_exists_$xuid=yes"
  1545. eval "g_exists_$xuid=yes"
  1546. fi
  1547. fi
  1548. if [ ".$xgid" = . ]; then
  1549. xgid=`(getent group "${xgrp}"; \
  1550. grep "^${xgrp}:" /etc/group; \
  1551. ypmatch "${xgrp}" group; \
  1552. nismatch "${xgrp}" group; \
  1553. nidump group . | grep "^${xgrp}:") 2>/dev/null | \
  1554. sed -e 'q' | awk -F: '{ print $3; }'`
  1555. if [ ".$xgid" = . ]; then
  1556. xgid="$xuid"
  1557. fi
  1558. fi
  1559. eval "${class}uid=\"$xuid\""
  1560. eval "${class}gid=\"$xgid\""
  1561. done
  1562. # determine platform id
  1563. s=`(uname -s) 2>/dev/null` || s='Unknown'
  1564. r=`(uname -r) 2>/dev/null` || r='0.0'
  1565. plid="${s}/${r}"
  1566. # add entry to /etc/shells
  1567. shell="${prefix}/lib/openpkg/bash"
  1568. if [ -f /etc/shells ]; then
  1569. exists=`cat /etc/shells 2>/dev/null | grep "^$shell"`
  1570. if [ ".$exists" = . ]; then
  1571. if [ ".$cusr" != ".root" ]; then
  1572. echo "openpkg:WARNING: skipping addition of $shell to /etc/shells" 1>&2
  1573. echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  1574. else
  1575. echo "${shell}" >>/etc/shells
  1576. fi
  1577. fi
  1578. fi
  1579. # create the hierarchy user/group
  1580. for req in "superuser:${susr}:${suid}:${sgrp}:${sgid}" \
  1581. "management:${musr}:${muid}:${mgrp}:${mgid}" \
  1582. "restricted:${rusr}:${ruid}:${rgrp}:${rgid}" \
  1583. "non-privileged:${nusr}:${nuid}:${ngrp}:${ngid}"; do
  1584. # split request into class/usr/uid/grp/gid
  1585. OIFS="$IFS"; IFS=":"; set -- $req; IFS="$OIFS"
  1586. class="$1"; usr="$2"; uid="$3"; grp="$4"; gid="$5"
  1587. # check whether user already exists
  1588. exists=`(getent passwd "$usr"; \
  1589. grep "^$usr:" /etc/passwd; \
  1590. ypmatch "$usr" passwd; \
  1591. nismatch "$usr" passwd; \
  1592. nidump passwd . | grep "^$usr:") 2>/dev/null | \
  1593. sed -e 'q'`
  1594. if [ ".$exists" = . ]; then
  1595. if [ ".$cusr" != ".root" ]; then
  1596. echo "openpkg:WARNING: skipping creation of OpenPKG $class user $usr" 1>&2
  1597. echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  1598. else
  1599. # add entry to passwd database
  1600. realname="${prefix} OpenPKG ($class)"
  1601. case "$plid" in
  1602. FreeBSD/* | NetBSD/* )
  1603. file=/etc/master.passwd
  1604. entry="${usr}:*:${uid}:${gid}::0:0:${realname}:${prefix}:${shell}"
  1605. update="(PATH=\$PATH:/usr/sbin; pwd_mkdb -p /etc/master.passwd)"
  1606. ;;
  1607. Linux/* )
  1608. file=/etc/passwd
  1609. entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
  1610. update="(PATH=\$PATH:/usr/sbin; pwconv)"
  1611. ;;
  1612. SunOS/5.* | UnixWare/* )
  1613. file=/etc/passwd
  1614. entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
  1615. update="(PATH=\$PATH:/usr/sbin; pwconv)"
  1616. ;;
  1617. AIX/* )
  1618. # intentionally do nothing here
  1619. :
  1620. ;;
  1621. OSF1/V5.* )
  1622. file=/etc/passwd
  1623. entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
  1624. update="(PATH=\$PATH:/usr/sbin; mkpasswd /etc/passwd)"
  1625. ;;
  1626. HP-UX/* )
  1627. file=/etc/passwd
  1628. entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
  1629. update=":"
  1630. ;;
  1631. Darwin/* )
  1632. # intentionally do nothing here
  1633. :
  1634. ;;
  1635. IRIX*/6.* )
  1636. file=/etc/passwd
  1637. entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
  1638. if [ -f /etc/shadow ]
  1639. then update="(PATH=\$PATH:/sbin; pwconv)"
  1640. else update=":"
  1641. fi
  1642. ;;
  1643. esac
  1644. case "$plid" in
  1645. Darwin/* )
  1646. niutil -create . "/users/${usr}"
  1647. niutil -createprop . "/users/${usr}" passwd "*"
  1648. niutil -createprop . "/users/${usr}" uid "${uid}"
  1649. niutil -createprop . "/users/${usr}" gid "${gid}"
  1650. niutil -createprop . "/users/${usr}" realname "${realname}"
  1651. niutil -createprop . "/users/${usr}" home "${prefix}"
  1652. niutil -createprop . "/users/${usr}" shell "${shell}"
  1653. ;;
  1654. AIX/* )
  1655. mkuser id="${uid}" gecos="${realname}" home="${prefix}" "${usr}"
  1656. cp /etc/security/login.cfg /etc/security/login.cfg.bak && \
  1657. sed -e "/^usw:/,/^[^ ]/s;\\( *shells =.*\\) *\$;\\1,$shell;" \
  1658. </etc/security/login.cfg.bak >/etc/security/login.cfg && \
  1659. rm -f /etc/security/login.cfg.bak >/dev/null 2>&1
  1660. # defer both the setting of the primary group and the shell,
  1661. # as they do not exist at this stage of processing.
  1662. ( echo "chuser pgrp=\"${grp}\" shell=\"${shell}\" \"${usr}\""
  1663. ) >%{l_prefix}.pre-post-process.sh
  1664. ;;
  1665. * )
  1666. cp $file $file.bak && \
  1667. (grep -v '^+:' $file.bak; echo $entry; grep '^+:' $file.bak) >$file
  1668. rm -f $file.bak >/dev/null 2>&1
  1669. eval $update
  1670. [ $? -ne 0 ] && exit $?
  1671. ;;
  1672. esac
  1673. fi
  1674. fi
  1675. # check whether group already exists
  1676. exists=`(getent group "$grp"; \
  1677. grep "^$grp:" /etc/group; \
  1678. ypmatch "$grp" group; \
  1679. nismatch "$grp" group; \
  1680. nidump group . | grep "^$grp:") 2>/dev/null | \
  1681. sed -e 'q'`
  1682. if [ ".$exists" = . ]; then
  1683. if [ ".$cusr" != ".root" ]; then
  1684. echo "openpkg:WARNING: skipping creation of OpenPKG $class group $grp" 1>&2
  1685. echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  1686. else
  1687. case "$plid" in
  1688. Darwin/* )
  1689. niutil -create . "/groups/${grp}"
  1690. niutil -createprop . "/groups/${grp}" gid "${gid}"
  1691. niutil -createprop . "/groups/${grp}" users "${usr}"
  1692. ;;
  1693. AIX/* )
  1694. mkgroup id="${gid}" users="${usr}" "${grp}"
  1695. ;;
  1696. * )
  1697. # add entry to group database
  1698. file=/etc/group
  1699. entry="${grp}:*:${gid}:${usr}"
  1700. cp $file $file.bak && \
  1701. (grep -v '^+:' $file.bak; echo $entry; grep '^+:' $file.bak) >$file
  1702. rm -f $file.bak >/dev/null 2>&1
  1703. ;;
  1704. esac
  1705. fi
  1706. fi
  1707. done
  1708. # create the startup/shutdown transfer script
  1709. name=`echo "$prefix" | sed -e 's;/;;g'`
  1710. if [ ".$cusr" != ".root" ]; then
  1711. echo "openpkg:WARNING: skipping creation of system run-command hooks" 1>&2
  1712. echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  1713. else
  1714. case "$plid" in
  1715. FreeBSD/4.* )
  1716. if [ ! -f /etc/rc.d/${name}.sh ]; then
  1717. # make sure /etc/rc.d exists
  1718. if [ ! -d /etc/rc.d ]; then
  1719. mkdir /etc/rc.d
  1720. fi
  1721. # make sure /etc/rc.d is activated
  1722. ( . /etc/defaults/rc.conf
  1723. . /etc/rc.conf
  1724. found=0
  1725. for p in ${local_startup-x}; do
  1726. if [ ".$p" = "./etc/rc.d" ]; then
  1727. found=1
  1728. break
  1729. fi
  1730. done
  1731. if [ ".$found" = .0 ]; then
  1732. cp -p /etc/rc.conf /etc/rc.conf.bak
  1733. ( grep -v local_startup /etc/rc.conf.bak
  1734. echo "local_startup=\"/etc/rc.d $local_startup\""
  1735. ) >/etc/rc.conf
  1736. rm -f /etc/rc.conf.bak >/dev/null 2>&1
  1737. fi
  1738. ) || exit $?
  1739. # install transfer script
  1740. rm -f /etc/rc.d/${name}.sh >/dev/null 2>&1
  1741. ( echo "#!/bin/sh"
  1742. echo "##"
  1743. echo "## ${name}.sh -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  1744. echo "##"
  1745. echo ""
  1746. echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  1747. echo "case \$1 in"
  1748. echo " start ) exec ${prefix}/etc/rc all start ;;"
  1749. echo " stop ) exec ${prefix}/etc/rc all stop ;;"
  1750. echo "esac"
  1751. ) >/etc/rc.d/${name}.sh
  1752. chmod 755 /etc/rc.d/${name}.sh
  1753. fi
  1754. ;;
  1755. FreeBSD/* )
  1756. if [ -f /etc/rc.d/${name}.sh ]; then
  1757. # remove old transfer script (for upgrading from FreeBSD 4 only)
  1758. rm -f /etc/rc.d/${name}.sh >/dev/null 2>&1
  1759. fi
  1760. if [ ! -f /etc/rc.d/openpkg-${name} ]; then
  1761. # install transfer script
  1762. rm -f /etc/rc.d/openpkg-${name} >/dev/null 2>&1
  1763. ( echo "#!/bin/sh"
  1764. echo "##"
  1765. echo "## openpkg-${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  1766. echo "##"
  1767. echo ""
  1768. echo "# PROVIDE: openpkg-${name}"
  1769. echo "# REQUIRE: LOGIN"
  1770. echo "# KEYWORD: shutdown"
  1771. echo ""
  1772. echo ". /etc/rc.subr"
  1773. echo ""
  1774. echo "name=\"openpkg_${name}\""
  1775. echo "start_cmd=\"openpkg_rc_all start\""
  1776. echo "stop_cmd=\"openpkg_rc_all stop\""
  1777. echo "restart_cmd=\"openpkg_rc_all stop start\""
  1778. echo ""
  1779. echo "openpkg_rc_all () {"
  1780. echo " if [ -f ${prefix}/etc/rc ]; then"
  1781. echo " ${prefix}/etc/rc all \"\$@\""
  1782. echo " fi"
  1783. echo "}"
  1784. echo ""
  1785. echo "load_rc_config \$name"
  1786. echo "run_rc_command \"\$1\""
  1787. echo ""
  1788. ) >/etc/rc.d/openpkg-${name}
  1789. chmod 755 /etc/rc.d/openpkg-${name}
  1790. fi
  1791. ;;
  1792. NetBSD/* )
  1793. if [ ! -f /etc/rc.d/${name} ]; then
  1794. ( echo "#!/bin/sh"
  1795. echo "##"
  1796. echo "## ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  1797. echo "##"
  1798. echo "## PROVIDE: ${name}"
  1799. echo "## REQUIRE: DAEMON LOGIN NETWORK SERVERS"
  1800. echo "##"
  1801. echo ""
  1802. echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  1803. echo "case \$1 in"
  1804. echo " start ) exec ${prefix}/etc/rc all start ;;"
  1805. echo " stop ) exec ${prefix}/etc/rc all stop ;;"
  1806. echo " restart ) exec ${prefix}/etc/rc all stop start ;;"
  1807. echo " status ) ;;"
  1808. echo "esac"
  1809. ) >/etc/rc.d/${name}
  1810. chmod 755 /etc/rc.d/${name}
  1811. fi
  1812. ;;
  1813. Linux/* )
  1814. if [ -f /etc/gentoo-release ]; then
  1815. if [ ! -f /etc/init.d/openpkg-${name} ]; then
  1816. # install transfer script
  1817. ( echo "#!/sbin/runscript"
  1818. echo "##"
  1819. echo "## openpkg-${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  1820. echo "##"
  1821. echo ""
  1822. echo "depend() {"
  1823. echo " after *"
  1824. echo "}"
  1825. echo ""
  1826. echo "checkconfig() {"
  1827. echo " [ -f ${prefix}/etc/rc ] || return 1"
  1828. echo " case $1 in"
  1829. echo " start ) exec ${prefix}/etc/rc all start ;;"
  1830. echo " stop ) exec ${prefix}/etc/rc all stop ;;"
  1831. echo " esac"
  1832. echo "}"
  1833. echo ""
  1834. echo "start() {"
  1835. echo " checkconfig || return 1"
  1836. echo " ebegin "Starting OpenPKG ${prefix} hierarchy""
  1837. echo " exec ${prefix}/etc/rc all start"
  1838. echo " eend 0"
  1839. echo "}"
  1840. echo ""
  1841. echo "stop() {"
  1842. echo " checkconfig || return 1"
  1843. echo " ebegin "Stopping OpenPKG ${prefix} hierarchy""
  1844. echo " exec ${prefix}/etc/rc all stop"
  1845. echo " eend 0"
  1846. echo "}"
  1847. ) >/etc/init.d/openpkg-${name}
  1848. chmod 755 /etc/init.d/openpkg-${name}
  1849. /sbin/rc-update add openpkg-${name} default
  1850. fi
  1851. else
  1852. # sroot: script root directory
  1853. # lroot: link root directory
  1854. if [ -f /etc/debian_version ]; then
  1855. sroot=/etc/init.d
  1856. lroot=/etc/rc%d.d
  1857. elif [ -f /etc/redhat-release -o -f /etc/mandrake-release ]; then
  1858. sroot=/etc/rc.d/init.d
  1859. lroot=/etc/rc.d/rc%d.d
  1860. elif [ -f /etc/SuSE-release ]; then
  1861. sroot=/etc/init.d
  1862. lroot=/etc/init.d/rc%d.d
  1863. elif [ -f /etc/slackware-version ]; then
  1864. sroot=/etc/rc.d
  1865. lroot=/etc/rc.d/rc%d.d
  1866. name="rc.${name}"
  1867. for i in 0 1 2 3 4 5 6; do
  1868. l=`echo $lroot | sed -e "s;%d;$i;"`
  1869. if [ ! -d $l ]; then
  1870. mkdir $l 2>&1 || true
  1871. fi
  1872. done
  1873. else
  1874. echo "WARNING: you are not running one of the supported standard" 1>&2
  1875. echo "WARNING: Linux platforms (Debian, RedHat, Mandrake, SuSE, Gentoo)." 1>&2
  1876. echo "WARNING: Guessing the location of the system init scripts!" 1>&2
  1877. sroot=""
  1878. lroot=""
  1879. for sr in /etc/rc.d/init.d /etc/init.d /sbin/init.d; do
  1880. if [ -d $sr ]; then
  1881. sroot="$sr"
  1882. break
  1883. fi
  1884. done
  1885. for lr in /etc/rc.d/rc2.d /etc/rc2.d /sbin/init.d/rc2.d; do
  1886. if [ -d $lr ]; then
  1887. lroot="`echo $lr | sed -e 's;2;%d;'`"
  1888. break
  1889. fi
  1890. done
  1891. if [ ".$sroot" = . -o ".$lroot" = . ]; then
  1892. echo "ERROR: Failed to guess the location of the system init scripts!" 1>&2
  1893. exit 1
  1894. fi
  1895. fi
  1896. if [ ! -f $sroot/${name} ]; then
  1897. # install transfer script
  1898. ( echo "#!/bin/sh"
  1899. echo "##"
  1900. echo "## ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  1901. echo "##"
  1902. echo ""
  1903. echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  1904. echo "case \$1 in"
  1905. echo " start ) exec ${prefix}/etc/rc all start ;;"
  1906. echo " stop ) exec ${prefix}/etc/rc all stop ;;"
  1907. echo "esac"
  1908. ) >$sroot/${name}
  1909. chmod 755 $sroot/${name}
  1910. # create corresponding symbolic links
  1911. for i in 2 3 4 5; do
  1912. ln -s $sroot/${name} `echo $lroot | sed -e "s;%d;$i;"`/S99${name}
  1913. done
  1914. for i in 0 1 6; do
  1915. ln -s $sroot/${name} `echo $lroot | sed -e "s;%d;$i;"`/K00${name}
  1916. done
  1917. fi
  1918. fi
  1919. ;;
  1920. SunOS/5.* )
  1921. if [ ! -f /etc/init.d/${name} ]; then
  1922. # install transfer script
  1923. ( echo "#!/bin/sh"
  1924. echo "##"
  1925. echo "## ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  1926. echo "##"
  1927. echo ""
  1928. echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  1929. echo "case \$1 in"
  1930. echo " start ) exec ${prefix}/etc/rc all start ;;"
  1931. echo " stop ) exec ${prefix}/etc/rc all stop ;;"
  1932. echo "esac"
  1933. ) >/etc/init.d/${name}
  1934. chmod 755 /etc/init.d/${name}
  1935. # create corresponding symbolic links
  1936. ( cd /etc
  1937. ln init.d/${name} rc3.d/S99${name}
  1938. ln init.d/${name} rc0.d/K00${name}
  1939. ln init.d/${name} rc1.d/K00${name}
  1940. ) || exit $?
  1941. fi
  1942. ;;
  1943. UnixWare/* )
  1944. if [ ! -f /etc/init.d/${name} ]; then
  1945. # install transfer script
  1946. ( echo "#!/bin/sh"
  1947. echo "##"
  1948. echo "## ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  1949. echo "##"
  1950. echo ""
  1951. echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  1952. echo "case \$1 in"
  1953. echo " start ) exec ${prefix}/etc/rc all start ;;"
  1954. echo " stop ) exec ${prefix}/etc/rc all stop ;;"
  1955. echo "esac"
  1956. ) >/etc/init.d/${name}
  1957. chmod 755 /etc/init.d/${name}
  1958. # create corresponding symbolic links
  1959. ( cd /etc
  1960. ln init.d/${name} rc2.d/S99${name}
  1961. ln init.d/${name} rc0.d/K00${name}
  1962. ln init.d/${name} rc1.d/K00${name}
  1963. ) || exit $?
  1964. fi
  1965. ;;
  1966. AIX/* )
  1967. if [ ! -f /etc/init.d/${name} ]; then
  1968. # install transfer script
  1969. ( echo "#!/bin/sh"
  1970. echo "##"
  1971. echo "## ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  1972. echo "##"
  1973. echo ""
  1974. echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  1975. echo "case \$1 in"
  1976. echo " start ) exec ${prefix}/etc/rc all start ;;"
  1977. echo " stop ) exec ${prefix}/etc/rc all stop ;;"
  1978. echo "esac"
  1979. ) >/etc/init.d/${name}
  1980. chmod 755 /etc/init.d/${name}
  1981. # create corresponding symbolic links
  1982. ( cd /etc/rc.d
  1983. ln -s ../../init.d/${name} rc2.d/S99${name}
  1984. ) || exit $?
  1985. fi
  1986. ;;
  1987. OSF1/V5.* )
  1988. if [ ! -f /sbin/init.d/${name} ]; then
  1989. # install transfer script
  1990. ( echo "#!/bin/sh"
  1991. echo "##"
  1992. echo "## ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  1993. echo "##"
  1994. echo ""
  1995. echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  1996. echo "case \$1 in"
  1997. echo " start ) exec ${prefix}/etc/rc all start ;;"
  1998. echo " stop ) exec ${prefix}/etc/rc all stop ;;"
  1999. echo "esac"
  2000. ) >/sbin/init.d/${name}
  2001. chmod 755 /sbin/init.d/${name}
  2002. # create corresponding symbolic links
  2003. ( cd /sbin
  2004. ln -s ../init.d/${name} rc3.d/S99${name}
  2005. ln -s ../init.d/${name} rc0.d/K00${name}
  2006. ) || exit $?
  2007. fi
  2008. ;;
  2009. HP-UX/* )
  2010. if [ ! -f /sbin/init.d/${name} ]; then
  2011. # install transfer script
  2012. ( echo "#!/bin/sh"
  2013. echo "##"
  2014. echo "## ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  2015. echo "##"
  2016. echo ""
  2017. echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  2018. echo "case \$1 in"
  2019. echo " start ) exec ${prefix}/etc/rc all start ;;"
  2020. echo " stop ) exec ${prefix}/etc/rc all stop ;;"
  2021. echo "esac"
  2022. ) >/sbin/init.d/${name}
  2023. chmod 755 /sbin/init.d/${name}
  2024. # create corresponding symbolic links
  2025. ( cd /sbin
  2026. ln -s ../init.d/${name} rc2.d/S900${name}
  2027. ln -s ../init.d/${name} rc1.d/K100${name}
  2028. ) || exit $?
  2029. fi
  2030. ;;
  2031. Darwin/* )
  2032. darwin_rc_dir="/System/Library/StartupItems/${name}"
  2033. if [ ! -d ${darwin_rc_dir} ]; then
  2034. mkdir ${darwin_rc_dir}
  2035. fi
  2036. # make sure hierarchy is activated in /etc/hostconfig
  2037. # FIXME: cs: simple and bad code here without any detection of existing entries
  2038. echo "OPENPKG_${name}=-YES-" >>/etc/hostconfig
  2039. # install transfer script
  2040. if [ ! -f ${darwin_rc_dir}/${name} ]; then
  2041. rm -f ${darwin_rc_dir}/${name} >/dev/null 2>&1
  2042. ( echo "#!/bin/sh"
  2043. echo "##"
  2044. echo "## ${darwin_rc_dir}/${name}"
  2045. echo "## -- startup transfer script for OpenPKG ${prefix} hierarchy"
  2046. echo "##"
  2047. echo ""
  2048. echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  2049. echo ""
  2050. echo ". /etc/rc.common"
  2051. echo ""
  2052. echo "if [ \"\${OPENPKG_${name}:=-NO-}\" = \"-YES-\" ]; then"
  2053. echo " ConsoleMessage \"OpenPKG ${prefix} hierarchy\""
  2054. echo " ${prefix}/etc/rc all start"
  2055. echo "fi"
  2056. ) >${darwin_rc_dir}/${name}
  2057. chmod 755 ${darwin_rc_dir}/${name}
  2058. fi
  2059. # install startup parameter list
  2060. if [ ! -f ${darwin_rc_dir}/StartupParameters.plist ]; then
  2061. rm -f ${darwin_rc_dir}/StartupParameters.plist >/dev/null 2>&1
  2062. ( echo "{"
  2063. echo " Description = \"OpenPKG ${prefix} hierarchy\";"
  2064. echo " Provides = (\"OpenPKG ${prefix}\");"
  2065. echo " Requires = (\"Disks\", \"Network Configuration\", \"Resolver\");"
  2066. echo " Uses = (\"Cron\");"
  2067. echo " OrderPreference = \"Last\";"
  2068. echo " Messages ="
  2069. echo " {"
  2070. echo " start = \"Starting OpenPKG ${prefix} hierarchy\";"
  2071. echo " stop = \"Stopping OpenPKG ${prefix} hierarchy\";"
  2072. echo " };"
  2073. echo "}"
  2074. ) >${darwin_rc_dir}/StartupParameters.plist
  2075. chmod 644 ${darwin_rc_dir}/StartupParameters.plist
  2076. fi
  2077. ;;
  2078. IRIX*/6.* )
  2079. if [ ! -f /etc/init.d/${name} ]; then
  2080. # install transfer script
  2081. ( echo "#!/bin/sh"
  2082. echo "##"
  2083. echo "## ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  2084. echo "##"
  2085. echo ""
  2086. echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  2087. echo "case \$1 in"
  2088. echo " start ) exec ${prefix}/etc/rc all start ;;"
  2089. echo " stop ) exec ${prefix}/etc/rc all stop ;;"
  2090. echo "esac"
  2091. ) >/etc/init.d/${name}
  2092. chmod 755 /etc/init.d/${name}
  2093. # create corresponding links
  2094. ( cd /etc
  2095. ln -f init.d/${name} rc2.d/S99${name}
  2096. ln -f init.d/${name} rc0.d/K00${name}
  2097. ) || exit $?
  2098. fi
  2099. ;;
  2100. esac
  2101. fi
  2102. # create the cron transfer entries
  2103. if [ ".$cusr" != ".root" ]; then
  2104. echo "openpkg:WARNING: skipping creation of system cron hooks" 1>&2
  2105. echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  2106. else
  2107. case "$plid" in
  2108. FreeBSD/* | Linux/* | Darwin/* )
  2109. if [ -f /etc/slackware-version ]; then
  2110. exists=`crontab -l | grep "$prefix/etc/rc"`
  2111. if [ ".$exists" = . ]; then
  2112. EDITOR=/tmp/vipw.$$
  2113. VISUAL="$EDITOR"
  2114. export EDITOR
  2115. export VISUAL
  2116. ( echo "#!/bin/sh"
  2117. echo "( echo \"# <OpenPKG prefix=$prefix pkg=openpkg>\""
  2118. echo " echo \"# chronological tasks of ${prefix} OpenPKG hierarchy\""
  2119. echo " echo \"0 0 1 * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all monthly\""
  2120. echo " echo \"0 0 * * 0 [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all weekly\""
  2121. echo " echo \"0 0 * * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all daily\""
  2122. echo " echo \"0 * * * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all hourly\""
  2123. echo " echo \"0,15,30,45 * * * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all quarterly\""
  2124. echo " echo \"# </OpenPKG>\""
  2125. echo ") >>\$1"
  2126. ) >$EDITOR
  2127. chmod a+x $EDITOR
  2128. ( PATH="$PATH:/usr/bin"; crontab -e ) || exit $?
  2129. rm -f $EDITOR
  2130. fi
  2131. else
  2132. exists=`grep "$prefix/etc/rc" /etc/crontab`
  2133. if [ ".$exists" = . ]; then
  2134. ( echo "# <OpenPKG prefix=$prefix pkg=openpkg>"
  2135. echo "# chronological tasks of ${prefix} OpenPKG hierarchy"
  2136. echo "0 0 1 * * root [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all monthly"
  2137. echo "0 0 * * 0 root [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all weekly"
  2138. echo "0 0 * * * root [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all daily"
  2139. echo "0 * * * * root [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all hourly"
  2140. echo "*/15 * * * * root [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all quarterly"
  2141. echo "# </OpenPKG>"
  2142. ) >>/etc/crontab
  2143. fi
  2144. fi
  2145. ;;
  2146. SunOS/5.* | OSF1/V5.* | NetBSD/* | HP-UX/* | UnixWare/* | AIX/* )
  2147. exists=`crontab -l | grep "$prefix/etc/rc"`
  2148. if [ ".$exists" = . ]; then
  2149. EDITOR=/tmp/vipw.$$
  2150. VISUAL="$EDITOR"
  2151. export EDITOR
  2152. export VISUAL
  2153. ( echo "#!/bin/sh"
  2154. echo "( echo \"# <OpenPKG prefix=$prefix pkg=openpkg>\""
  2155. echo " echo \"# chronological tasks of ${prefix} OpenPKG hierarchy\""
  2156. echo " echo \"0 0 1 * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all monthly\""
  2157. echo " echo \"0 0 * * 0 [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all weekly\""
  2158. echo " echo \"0 0 * * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all daily\""
  2159. echo " echo \"0 * * * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all hourly\""
  2160. echo " echo \"0,15,30,45 * * * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all quarterly\""
  2161. echo " echo \"# </OpenPKG>\""
  2162. echo ") >>\$1"
  2163. ) >$EDITOR
  2164. chmod a+x $EDITOR
  2165. ( PATH="$PATH:/usr/bin"; crontab -e ) || exit $?
  2166. rm -f $EDITOR
  2167. fi
  2168. ;;
  2169. IRIX*/6.* )
  2170. exists=`crontab -l | grep "$prefix/etc/rc"`
  2171. if [ ".$exists" = . ]; then
  2172. ( crontab -l
  2173. echo "# <OpenPKG prefix=$prefix pkg=openpkg>"
  2174. echo "# chronological tasks of ${prefix} OpenPKG hierarchy"
  2175. echo "0 0 1 * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all monthly"
  2176. echo "0 0 * * 0 [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all weekly"
  2177. echo "0 0 * * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all daily"
  2178. echo "0 * * * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all hourly"
  2179. echo "0,15,30,45 * * * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all quarterly"
  2180. echo "# </OpenPKG>"
  2181. ) | /usr/bin/crontab || exit $?
  2182. fi
  2183. ;;
  2184. esac
  2185. fi
  2186. # remember what OpenPKG RPM version was installed, so we can
  2187. # correctly upgrade the RPM database in the %post section (see below).
  2188. if [ -d ${prefix}/RPM/DB ]; then
  2189. if [ -x "${prefix}/bin/openpkg" -a -x "${prefix}/libexec/openpkg/rpm" ]; then
  2190. # OpenPKG 2.0
  2191. rpm="${prefix}/bin/openpkg rpm"
  2192. else
  2193. # OpenPKG 1.x
  2194. rpm="${prefix}/bin/rpm"
  2195. fi
  2196. rm -f ${prefix}/RPM/DB/.version >/dev/null 2>&1 || true
  2197. $rpm --version |\
  2198. sed -e 's;^;X;' \
  2199. -e 's;^X[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*$;\1;' \
  2200. -e 's;^X[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$;\1;' \
  2201. -e 's;^X.*$;4.0;' \
  2202. >${prefix}/RPM/DB/.version
  2203. fi
  2204. %post
  2205. # optional post-processing from "pre" section
  2206. if [ -f %{l_prefix}.pre-post-process.sh ]; then
  2207. sh %{l_prefix}.pre-post-process.sh
  2208. rm -f %{l_prefix}.pre-post-process.sh
  2209. fi
  2210. # update or initially create OpenPKG UUID configuration
  2211. %{l_prefix}/bin/openpkg uuid update >/dev/null 2>&1 || true
  2212. # determine new and old OpenPKG RPM version
  2213. V_rpm_new="%{V_rpm}"
  2214. if [ -f %{l_prefix}/RPM/DB/.version ]; then
  2215. V_rpm_old="`cat %{l_prefix}/RPM/DB/.version`"
  2216. rm -f %{l_prefix}/RPM/DB/.version >/dev/null 2>&1 || true
  2217. else
  2218. V_rpm_old="4.0"
  2219. fi
  2220. # make sure all RPM database files are present and that their
  2221. # attributes are correct, etc. This is not a database rebuild
  2222. # operation, so this is fully harmless and can be done always.
  2223. %{l_prefix}/lib/openpkg/rpmdb --quiet --fixate
  2224. # check RPM database for upgrade requirements
  2225. if [ ".$1" = .2 -a ".$V_rpm_old" != ".$V_rpm_new" ]; then
  2226. # RPM 4.0/4.1 does not allow concurrent database access, so we
  2227. # cannot upgrade the database immediately from here (because
  2228. # we are still running within the execution context of the
  2229. # old RPM which in turn has the database locked) and instead
  2230. # have to just drop a note to the administrator about database
  2231. # upgrading. RPM 4.2 in general allows concurrent database
  2232. # access, but the whole stuff is too risky here, too.
  2233. ( echo "You are upgrading the OpenPKG bootstrap from a previous"
  2234. echo "RPM $V_rpm_old based version to this RPM $V_rpm_new based"
  2235. echo "version. The RPM database in %{l_prefix}/RPM/DB/ can still"
  2236. echo "be used, but it is strongly recommended to upgrade it as"
  2237. echo "soon as possible to the latest Berkeley-DB format files by"
  2238. echo "executing the command:"
  2239. echo " \$ %{l_prefix}/bin/openpkg rpm --db-rebuild"
  2240. echo "In case of problems with the RPM database you can always"
  2241. echo "execute the command:"
  2242. echo " \$ %{l_prefix}/bin/openpkg rpm --db-cleanup"
  2243. ) | %{l_prefix}/lib/openpkg/rpmtool msg -b -t warn
  2244. fi
  2245. # FIXME: Evil hack to workaround build problems under Debian
  2246. # (at least 3.1) (and similar platforms) where a Debian
  2247. # install-info(8) exists which is both API and functionally
  2248. # incompatible to the de-facto standardized install-info(8)
  2249. # command from GNU Texinfo. ATTENTION: THIS SHOULD BE REPLACED
  2250. # ASAP WITH A MORE GENERIC BUILD COMMAND OVERRIDE SOLUTION!
  2251. if [ ! -d %{l_prefix}/lib/openpkg/override ]; then
  2252. mkdir %{l_prefix}/lib/openpkg/override >/dev/null 2>&1 || true
  2253. fi
  2254. chown %{l_musr}:%{l_mgrp} %{l_prefix}/lib/openpkg/override >/dev/null 2>&1 || true
  2255. case "`cat %{l_prefix}/etc/openpkg/platform`" in
  2256. *-*-debian* | *-*-ubuntu* )
  2257. if [ ! -f %{l_prefix}/lib/openpkg/override/install-info ]; then
  2258. ( echo "#!/bin/sh"
  2259. echo "echo 'OpenPKG: NOTICE: install-info(8) command execution overridden'"
  2260. echo "exit 0"
  2261. ) >%{l_prefix}/lib/openpkg/override/install-info
  2262. chmod 775 %{l_prefix}/lib/openpkg/override/install-info
  2263. fi
  2264. ;;
  2265. esac
  2266. # FIXME: hack to workaround problems in environments with too few
  2267. # development tools. ATTENTION: see one paragraph above.
  2268. if [ ! -d %{l_prefix}/lib/openpkg/fallback ]; then
  2269. mkdir %{l_prefix}/lib/openpkg/fallback >/dev/null 2>&1 || true
  2270. fi
  2271. chown %{l_musr}:%{l_mgrp} %{l_prefix}/lib/openpkg/fallback >/dev/null 2>&1 || true
  2272. # display license information of "openpkg" executable in case the
  2273. # OpenPKG Community version (staying under an OSS license) is NOT used.
  2274. community_version=`%{l_prefix}/bin/openpkg --license 2>/dev/null | \
  2275. sed -e 'q' | egrep '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*-C'`
  2276. if [ ".$community_version" = . ]; then
  2277. ( echo ""
  2278. echo "NOTICE: This OpenPKG bootstrap package is based on an \"openpkg\""
  2279. echo "executable which is covered by the following terms of use:"
  2280. echo "______________________________________________________________________________"
  2281. echo ""
  2282. %{l_prefix}/bin/openpkg --license | sed -e '1d'
  2283. ) | %{l_prefix}/lib/openpkg/rpmtool msg -b -t notice
  2284. fi
  2285. %preun
  2286. [ ".$1" != .0 ] && exit 0
  2287. # remove override files
  2288. if [ -d %{l_prefix}/lib/openpkg/override ]; then
  2289. rm -rf %{l_prefix}/lib/openpkg/override >/dev/null 2>&1 || true
  2290. fi
  2291. # remove fallback files
  2292. if [ -d %{l_prefix}/lib/openpkg/fallback ]; then
  2293. rm -rf %{l_prefix}/lib/openpkg/fallback >/dev/null 2>&1 || true
  2294. fi
  2295. # remove files which are not RPM controlled
  2296. rm -rf %{l_prefix}/RPM/TMP/* %{l_prefix}/RPM/TMP/.[a-z]* >/dev/null 2>&1 || true
  2297. rm -rf %{l_prefix}/RPM/SRC/* %{l_prefix}/RPM/SRC/.[a-z]* >/dev/null 2>&1 || true
  2298. rm -rf %{l_prefix}/RPM/PKG/* %{l_prefix}/RPM/PKG/.[a-z]* >/dev/null 2>&1 || true
  2299. rm -rf %{l_prefix}/RPM/DB/* %{l_prefix}/RPM/DB/.[a-z]* >/dev/null 2>&1 || true
  2300. # The following code usually would be done in a %postun section.
  2301. # But because we already had to remove the database in this %preun
  2302. # section (see the 'rm' commands above) in order to make RPM happy
  2303. # inside its own removal procedure, RPM would no longer find the
  2304. # %postun script (because it's recorded in the database files). So
  2305. # we have to perform the procedure already in this %preun script.
  2306. # except for the removal of the top-level directory it does not
  2307. # matter. But the top-level directory can only be removed after
  2308. # the RPM removal procedure took place, so we play a little delay
  2309. # trick below.
  2310. # determine current user
  2311. cusr=`(id -un) 2>/dev/null ||\
  2312. (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
  2313. (whoami) 2>/dev/null ||\
  2314. (who am i | cut "-d " -f1) 2>/dev/null ||\
  2315. echo $LOGNAME`
  2316. # determine runtime details (for both inside and outside RPM!!)
  2317. user="%{l_musr}"
  2318. group="%{l_mgrp}"
  2319. prefix="%{l_prefix}"
  2320. prefix=`echo "$prefix" | sed -e 's;//*;/;g' -e 's;/$;;'`
  2321. # determine platform id
  2322. s=`(uname -s) 2>/dev/null` || s='Unknown'
  2323. r=`(uname -r) 2>/dev/null` || r='0.0'
  2324. plid="${s}/${r}"
  2325. # unregister the OpenPKG instance in /etc/openpkg
  2326. registry="/etc/openpkg"
  2327. exists=`cat $registry 2>/dev/null | egrep "^ *${prefix} *\$"`
  2328. if [ ".$exists" != . ]; then
  2329. if [ ".$cusr" != ".root" ]; then
  2330. echo "openpkg:WARNING: skipping unregistering of $prefix in $registry" 1>&2
  2331. echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  2332. else
  2333. cp $registry $registry.bak && \
  2334. egrep -v "^ *${prefix} *\$" $registry.bak >$registry
  2335. rm -f $registry.bak >/dev/null 2>&1
  2336. if [ ".`cat $registry`" = . ]; then
  2337. rm -f $registry >/dev/null 2>&1
  2338. fi
  2339. fi
  2340. fi
  2341. # remove entry in /etc/shells
  2342. shell="${prefix}/lib/openpkg/bash"
  2343. exists=`cat /etc/shells 2>/dev/null | grep "^$shell"`
  2344. if [ ".$exists" != . ]; then
  2345. if [ ".$cusr" != ".root" ]; then
  2346. echo "openpkg:WARNING: skipping deletion of $shell from /etc/shells" 1>&2
  2347. echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  2348. else
  2349. cp /etc/shells /etc/shells.bak && \
  2350. grep -v "^${shell}" /etc/shells.bak >/etc/shells
  2351. rm -f /etc/shells.bak >/dev/null 2>&1
  2352. fi
  2353. fi
  2354. # remove the hierarchy user/group
  2355. for req in "super-user:%{l_susr}:%{l_suid}:%{l_sgrp}:%{l_sgid}" \
  2356. "management:%{l_musr}:%{l_muid}:%{l_mgrp}:%{l_mgid}" \
  2357. "restricted:%{l_rusr}:%{l_ruid}:%{l_rgrp}:%{l_rgid}" \
  2358. "non-privileged:%{l_nusr}:%{l_nuid}:%{l_ngrp}:%{l_ngid}"; do
  2359. # split request into class/usr/uid/grp/gid
  2360. OIFS="$IFS"; IFS=":"; set -- $req; IFS="$OIFS"
  2361. class="$1"; usr="$2"; uid="$3"; grp="$4"; gid="$5"
  2362. # check whether user already exists
  2363. exists=`(getent passwd "$usr"; \
  2364. grep "^$usr:" /etc/passwd; \
  2365. ypmatch "$usr" passwd; \
  2366. nismatch "$usr" passwd; \
  2367. nidump passwd . | grep "^$usr:") 2>/dev/null | \
  2368. sed -e 'q'`
  2369. if [ ".$exists" != . ]; then
  2370. if [ ".$cusr" != ".root" ]; then
  2371. echo "openpkg:WARNING: skipping deletion of OpenPKG $class user $usr" 1>&2
  2372. echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  2373. elif [ ".$usr" = ".root" ]; then
  2374. echo "openpkg:WARNING: skipping deletion of OpenPKG $class user $usr" 1>&2
  2375. echo "openpkg:WARNING: (would remove system standard user)" 1>&2
  2376. else
  2377. case "$plid" in
  2378. FreeBSD/* | NetBSD/* )
  2379. cp /etc/master.passwd /etc/master.passwd.bak && \
  2380. grep -v "^${usr}:" /etc/master.passwd.bak >/etc/master.passwd
  2381. ( PATH="$PATH:/usr/sbin"; pwd_mkdb -p /etc/master.passwd ) || exit $?
  2382. rm -f /etc/master.passwd.bak >/dev/null 2>&1
  2383. ;;
  2384. Linux/* | SunOS/5.* | UnixWare/* )
  2385. cp /etc/passwd /etc/passwd.bak && \
  2386. grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
  2387. ( PATH="$PATH:/usr/sbin"; pwconv ) || exit $?
  2388. rm -f /etc/passwd.bak >/dev/null 2>&1
  2389. ;;
  2390. AIX/* )
  2391. rmuser -p "${usr}"
  2392. cp /etc/security/login.cfg /etc/security/login.cfg.bak && \
  2393. sed -e "/^usw:/,/^[^ ]/s;\\( *shells =.*\\),$shell\\(.*\\)\$;\\1\\2;" \
  2394. </etc/security/login.cfg.bak >/etc/security/login.cfg && \
  2395. rm -f /etc/security/login.cfg.bak >/dev/null 2>&1
  2396. ;;
  2397. OSF1/V5.* )
  2398. cp /etc/passwd /etc/passwd.bak && \
  2399. grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
  2400. ( PATH="$PATH:/usr/sbin"; mkpasswd /etc/passwd ) || exit $?
  2401. rm -f /etc/passwd.bak >/dev/null 2>&1
  2402. ;;
  2403. HP-UX/* )
  2404. cp /etc/passwd /etc/passwd.bak && \
  2405. grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
  2406. rm -f /etc/passwd.bak >/dev/null 2>&1
  2407. ;;
  2408. Darwin/* )
  2409. niutil -destroy . "/users/${usr}"
  2410. ;;
  2411. IRIX*/6.* )
  2412. cp /etc/passwd /etc/passwd.bak && \
  2413. grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
  2414. if [ -f /etc/shadow ]
  2415. then ( PATH="$PATH:/usr/sbin"; pwconv ) || exit $?
  2416. fi
  2417. rm -f /etc/passwd.bak >/dev/null 2>&1
  2418. ;;
  2419. esac
  2420. fi
  2421. fi
  2422. # check whether group already exists
  2423. exists=`(getent group "$grp"; \
  2424. grep "^$grp:" /etc/group; \
  2425. ypmatch "$grp" group; \
  2426. nismatch "$grp" group; \
  2427. nidump group . | grep "^$grp:") 2>/dev/null | \
  2428. sed -e 'q'`
  2429. if [ ".$exists" != . ]; then
  2430. if [ ".$cusr" != ".root" ]; then
  2431. echo "openpkg:WARNING: skipping deletion of OpenPKG $class group $grp" 1>&2
  2432. echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  2433. elif [ ".$usr" = ".root" ] || [ ".$grp" = ".root" ] || [ ".$grp" = ".wheel" ]; then
  2434. echo "openpkg:WARNING: skipping deletion of OpenPKG $class group $grp" 1>&2
  2435. echo "openpkg:WARNING: (would remove system standard group)" 1>&2
  2436. else
  2437. case "$plid" in
  2438. Darwin/* )
  2439. niutil -destroy . "/groups/${grp}"
  2440. ;;
  2441. AIX/* )
  2442. rmgroup "${grp}"
  2443. ;;
  2444. * )
  2445. cp /etc/group /etc/group.bak && \
  2446. grep -v "^${grp}:" /etc/group.bak >/etc/group
  2447. rm -f /etc/group.bak >/dev/null 2>&1
  2448. ;;
  2449. esac
  2450. fi
  2451. fi
  2452. done
  2453. # remove the startup/shutdown transfer scripts
  2454. name=`echo "$prefix" | sed -e 's;/;;g'`
  2455. if [ ".$cusr" != ".root" ]; then
  2456. echo "openpkg:WARNING: skipping deletion of system run-command hooks" 1>&2
  2457. echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  2458. else
  2459. case "$plid" in
  2460. FreeBSD/4.* )
  2461. rm -f /etc/rc.d/${name}.sh >/dev/null 2>&1
  2462. ;;
  2463. FreeBSD/* )
  2464. rm -f /etc/rc.d/openpkg-${name} >/dev/null 2>&1
  2465. ;;
  2466. NetBSD/* )
  2467. rm -f /etc/rc.d/${name} >/dev/null 2>&1
  2468. ;;
  2469. Linux/* )
  2470. if [ -f /etc/gentoo-release ]; then
  2471. /sbin/rc-update del openpkg-${name} >/dev/null 2>&1
  2472. rm -f /etc/init.d/openpkg-${name} >/dev/null 2>&1
  2473. else
  2474. # sroot: script root directory
  2475. # lroot: link root directory
  2476. if [ -f /etc/debian_version ]; then
  2477. sroot=/etc/init.d
  2478. lroot=/etc/rc%d.d
  2479. elif [ -f /etc/redhat-release -o -f /etc/mandrake-release ]; then
  2480. sroot=/etc/rc.d/init.d
  2481. lroot=/etc/rc.d/rc%d.d
  2482. elif [ -f /etc/SuSE-release ]; then
  2483. sroot=/etc/init.d
  2484. lroot=/etc/init.d/rc%d.d
  2485. elif [ -f /etc/slackware-version ]; then
  2486. sroot=/etc/rc.d
  2487. lroot=/etc/rc.d/rc%d.d
  2488. name="rc.${name}"
  2489. else
  2490. echo "WARNING: you are not running one of the supported standard" 1>&2
  2491. echo "WARNING: Linux platforms (Debian, RedHat, Mandrake, SuSE, Gentoo)." 1>&2
  2492. echo "WARNING: Guessing the location of the system init scripts!" 1>&2
  2493. sroot=""
  2494. lroot=""
  2495. for sr in /etc/rc.d/init.d /etc/init.d /sbin/init.d; do
  2496. if [ -d $sr ]; then
  2497. sroot="$sr"
  2498. break
  2499. fi
  2500. done
  2501. for lr in /etc/rc.d/rc2.d /etc/rc2.d /sbin/init.d/rc2.d; do
  2502. if [ -d $lr ]; then
  2503. lroot="`echo $lr | sed -e 's;2;%d;'`"
  2504. break
  2505. fi
  2506. done
  2507. if [ ".$sroot" = . -o ".$lroot" = . ]; then
  2508. echo "ERROR: Failed to guess the location of the system init scripts!" 1>&2
  2509. exit 1
  2510. fi
  2511. fi
  2512. rm -f ${sroot}/${name} >/dev/null 2>&1
  2513. for i in 2 3 4 5; do
  2514. rm -f `echo $lroot | sed -e "s;%d;$i;"`/S99${name} >/dev/null 2>&1
  2515. done
  2516. for i in 0 1 6; do
  2517. rm -f `echo $lroot | sed -e "s;%d;$i;"`/K00${name} >/dev/null 2>&1
  2518. done
  2519. if [ -f /etc/slackware-version ]; then
  2520. for i in 0 1 2 3 4 5 6; do
  2521. l=`echo $lroot | sed -e "s;%d;$i;"`
  2522. if [ -d $l ]; then
  2523. rmdir $l >/dev/null 2>&1 || true
  2524. fi
  2525. done
  2526. fi
  2527. fi
  2528. ;;
  2529. SunOS/5.* )
  2530. rm -f /etc/init.d/${name} >/dev/null 2>&1
  2531. rm -f /etc/rc3.d/S99${name} >/dev/null 2>&1
  2532. rm -f /etc/rc0.d/K00${name} >/dev/null 2>&1
  2533. rm -f /etc/rc1.d/K00${name} >/dev/null 2>&1
  2534. ;;
  2535. UnixWare/* )
  2536. rm -f /etc/init.d/${name} >/dev/null 2>&1
  2537. rm -f /etc/rc2.d/S99${name} >/dev/null 2>&1
  2538. rm -f /etc/rc0.d/K00${name} >/dev/null 2>&1
  2539. rm -f /etc/rc1.d/K00${name} >/dev/null 2>&1
  2540. ;;
  2541. AIX/* )
  2542. rm -f /etc/init.d/${name} >/dev/null 2>&1
  2543. rm -f /etc/rc.d/rc2.d/S99${name} >/dev/null 2>&1
  2544. ;;
  2545. OSF1/V5.* )
  2546. rm -f /sbin/init.d/${name} >/dev/null 2>&1
  2547. rm -f /sbin/rc3.d/S99${name} >/dev/null 2>&1
  2548. rm -f /sbin/rc0.d/K00${name} >/dev/null 2>&1
  2549. ;;
  2550. HP-UX/* )
  2551. rm -f /sbin/init.d/${name} >/dev/null 2>&1
  2552. rm -f /etc/rc2.d/S900${name} >/dev/null 2>&1
  2553. rm -f /etc/rc1.d/K100${name} >/dev/null 2>&1
  2554. ;;
  2555. Darwin/* )
  2556. cp /etc/hostconfig /etc/hostconfig.bak && \
  2557. grep -v "^OPENPKG_${name}=" /etc/hostconfig.bak >/etc/hostconfig
  2558. rm -f /etc/hostconfig.bak >/dev/null 2>&1
  2559. rm -rf /System/Library/StartupItems/${name} >/dev/null 2>&1
  2560. ;;
  2561. IRIX*/6.* )
  2562. rm -f /etc/init.d/${name} >/dev/null 2>&1
  2563. rm -f /etc/rc2.d/S99${name} >/dev/null 2>&1
  2564. rm -f /etc/rc0.d/K00${name} >/dev/null 2>&1
  2565. ;;
  2566. esac
  2567. fi
  2568. # remove the cron transfer entries
  2569. if [ ".$cusr" != ".root" ]; then
  2570. echo "openpkg:WARNING: skipping deletion of system cron hooks" 1>&2
  2571. echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  2572. else
  2573. case "$plid" in
  2574. FreeBSD/* | Linux/* | Darwin/* )
  2575. if [ -f /etc/slackware-version ]; then
  2576. EDITOR=/tmp/vipw.$$
  2577. VISUAL="$EDITOR"
  2578. export EDITOR
  2579. export VISUAL
  2580. p=`echo $prefix | sed -e 's;/;\\\\\\\\/;g'`
  2581. ( echo "cp \$1 \$1.bak"
  2582. echo "cat \$1.bak | sed -e \"/<OpenPKG prefix=$p pkg=openpkg>/,/<\\\\/OpenPKG>/d\" >\$1"
  2583. echo "rm -f \$1.bak"
  2584. ) >$EDITOR
  2585. chmod a+x $EDITOR
  2586. ( PATH="$PATH:/usr/bin"; crontab -e ) || exit $?
  2587. rm -f $EDITOR
  2588. else
  2589. exists=`grep "<OpenPKG prefix=$prefix pkg=openpkg>" /etc/crontab`
  2590. if [ ".$exists" != . ]; then
  2591. p=`echo $prefix | sed -e 's;/;\\\\/;g'`
  2592. cp /etc/crontab /etc/crontab.bak
  2593. cat /etc/crontab.bak |\
  2594. sed -e "/<OpenPKG prefix=$p pkg=openpkg>/,/<\\/OpenPKG>/d" \
  2595. >/etc/crontab
  2596. rm -f /etc/crontab.bak >/dev/null 2>&1
  2597. fi
  2598. fi
  2599. ;;
  2600. SunOS/5.* | OSF1/V5.* | NetBSD/* | HP-UX/* | UnixWare/* | AIX/* )
  2601. EDITOR=/tmp/vipw.$$
  2602. VISUAL="$EDITOR"
  2603. export EDITOR
  2604. export VISUAL
  2605. p=`echo $prefix | sed -e 's;/;\\\\\\\\/;g'`
  2606. ( echo "cp \$1 \$1.bak"
  2607. echo "cat \$1.bak | sed -e \"/<OpenPKG prefix=$p pkg=openpkg>/,/<\\\\/OpenPKG>/d\" >\$1"
  2608. echo "rm -f \$1.bak"
  2609. ) >$EDITOR
  2610. chmod a+x $EDITOR
  2611. ( PATH="$PATH:/usr/bin"; crontab -e ) || exit $?
  2612. rm -f $EDITOR
  2613. ;;
  2614. IRIX*/6.* )
  2615. p=`echo $prefix | sed -e 's;/;\\\\\\/;g'`
  2616. ( crontab -l |
  2617. sed -e "/<OpenPKG prefix=$p pkg=openpkg>/,/<\/OpenPKG>/d"
  2618. ) | /usr/bin/crontab || exit $?
  2619. ;;
  2620. esac
  2621. fi
  2622. # delayed removal of top-level directory.
  2623. ( sleep 2
  2624. rm -rf %{l_prefix}/RPM/DB/* %{l_prefix}/RPM/DB/.[a-z]* >/dev/null 2>&1 || true
  2625. rmdir %{l_prefix}/RPM/DB >/dev/null 2>&1 || true
  2626. rmdir %{l_prefix}/RPM >/dev/null 2>&1 || true
  2627. rmdir %{l_prefix} >/dev/null 2>&1 || true
  2628. ) </dev/null >/dev/null 2>/dev/null &