openpkg.spec 90 KB

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