openpkg.spec 111 KB

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