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