openpkg.spec 91 KB

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