openpkg.spec 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597
  1. ##
  2. ## openpkg.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2003 Cable & Wireless Deutschland GmbH
  4. ## Copyright (c) 2000-2003 The OpenPKG Project <http://www.openpkg.org/>
  5. ## Copyright (c) 2000-2003 Ralf S. Engelschall <rse@engelschall.com>
  6. ##
  7. ## Permission to use, copy, modify, and distribute this software for
  8. ## any purpose with or without fee is hereby granted, provided that
  9. ## the above copyright notice and this permission notice appear in all
  10. ## copies.
  11. ##
  12. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  13. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  16. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  17. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  18. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  19. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  21. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  22. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  23. ## SUCH DAMAGE.
  24. ##
  25. # NOTICE: This RPM specification is _very_ special, because it is
  26. # used both for bootstrapping OpenPKG with its RPM and for regular
  27. # builds of RPM in order to upgrade an existing installation. For this
  28. # it has to interact correctly with the "openpkg.boot" script. See
  29. # this companion script for details, but do not touch anything here
  30. # until you are 100% sure about what you are doing. In short: This
  31. # script is allowed to use only a very restricted subset of the RPM
  32. # functionality!
  33. # BUILD REQUIREMENTS:
  34. # o any sh(1)
  35. # o any tar(1)
  36. # o any make(1)
  37. # o any cc(1)
  38. # the package version/release
  39. %define V_openpkg 20030422
  40. # the used software versions
  41. %define V_rpm 4.0.2
  42. %define V_zlib 1.1.4
  43. %define V_bzip2 1.0.2
  44. %define V_db 3.2.9
  45. %define V_curl 7.10.4
  46. %define V_make 3.80
  47. %define V_gzip 1.3.5
  48. %define V_patch 2.5.4
  49. %define V_tar 1.13.25
  50. %define V_bash 2.05b
  51. # package information
  52. Name: openpkg
  53. Summary: OpenPKG Bootstrap
  54. URL: http://www.openpkg.org/
  55. Vendor: OpenPKG
  56. Packager: The OpenPKG Project
  57. Distribution: OpenPKG [CORE]
  58. Group: Bootstrapping
  59. License: GPL
  60. Version: %{V_openpkg}
  61. Release: %{V_openpkg}
  62. # list of sources
  63. Source0: README
  64. Source1: openpkg.boot
  65. Source2: ftp://ftp.rpm.org/pub/rpm/dist/rpm-%{V_rpm}.x/rpm-%{V_rpm}.tar.gz
  66. Source3: rpm.patch.bugfix
  67. Source4: rpm.patch.feature
  68. Source5: rpm.patch.porting
  69. Source6: rpm.patch.regen
  70. Source7: http://www.sleepycat.com/update/%{V_db}/db-%{V_db}.tar.gz
  71. Source8: ftp://sources.redhat.com/pub/bzip2/v102/bzip2-%{V_bzip2}.tar.gz
  72. Source9: ftp://ftp.info-zip.org/pub/infozip/zlib/zlib-%{V_zlib}.tar.gz
  73. Source10: http://curl.haxx.se/download/curl-%{V_curl}.tar.gz
  74. Source11: rpmpopt
  75. Source12: rpmrc
  76. Source13: rpmmacros
  77. Source14: root.README
  78. Source15: local.README
  79. Source16: rc
  80. Source17: rc.func
  81. Source18: rpmtool
  82. Source19: rpmtool.8
  83. Source20: rpmtool.pod
  84. Source21: lsync
  85. Source22: lsync.8
  86. Source23: lsync.pod
  87. Source24: aux.wrapsrc.sh
  88. Source25: aux.wrapbin.sh
  89. Source26: openpkg.pgp
  90. Source27: shtool
  91. Source28: rpmx.sh
  92. Source29: rpmx.pl
  93. Source30: ftp://ftp.gnu.org/gnu/make/make-%{V_make}.tar.gz
  94. Source31: ftp://alpha.gnu.org/gnu/gzip/gzip-%{V_gzip}.tar
  95. Source32: ftp://ftp.gnu.org/gnu/patch/patch-%{V_patch}.tar.gz
  96. Source33: rc.openpkg
  97. Source34: ftp://ftp.gnu.org/gnu/tar/tar-%{V_tar}.tar.gz
  98. Source35: ftp://ftp.gnu.org/gnu/bash/bash-%{V_bash}.tar.gz
  99. Source36: dot.bashrc
  100. Source37: dot.bash_login
  101. Source38: dot.lsyncrc
  102. Source39: db.patch
  103. Source40: rc.conf
  104. Source41: aux.prereq.sh
  105. Source42: aux.usrgrp.sh
  106. Source43: mkproxyrpm.pl
  107. Source44: ftp://ftp.gnu.org/gnu/config/config.guess
  108. Source45: ftp://ftp.gnu.org/gnu/config/config.sub
  109. Source46: make.patch
  110. # build information
  111. Prefix: %{l_prefix}
  112. BuildRoot: %{l_buildroot}
  113. AutoReq: no
  114. AutoReqProv: no
  115. Provides: OpenPKG
  116. %description
  117. This is the bootstrap package for the RPM-based Unix Software
  118. Package Hierarchy OpenPKG. The RedHat Package Manager (RPM) is a
  119. sophisticated and portable package manager for Unix platforms,
  120. which supports the automated building, installation, management and
  121. deinstallation of Unix software. Originally RPM is designed and
  122. implemented for us with the RedHat Linux operating system where
  123. it manages every file on the whole system. In OpenPKG RPM is used
  124. only for managing all files in a particular filesystem hierarchy
  125. dedicated to the installation of third-party software packages
  126. provided by the OpenPKG project.
  127. Internally the OpenPKG bootstrap package is based on the
  128. following particular vendor products:
  129. RedHat RPM %{V_rpm}, Berkeley-DB %{V_db}, ZLib %{V_zlib},
  130. GNU Bzip2 %{V_bzip2}, GNU Gzip %{V_gzip}, GNU Tar %{V_tar},
  131. GNU Patch %{V_patch}, GNU Make %{V_make}, GNU Bash %{V_bash},
  132. cURL %{V_curl}
  133. %prep
  134. # skip in bootstrap phase 2 (see openpkg.boot)
  135. [ ".$OPENPKG_BOOT" = .1 ] && exit 0
  136. # switch into a temporary build area
  137. rm -rf %{name}-%{version}
  138. mkdir %{name}-%{version}
  139. cd %{name}-%{version}
  140. rm -f .buildenv
  141. touch .buildenv
  142. # provide a bootstrap alternative to %{SOURCE xxx} because else
  143. # it is not possible to upgrade a newer OpenPKG RPM with an older
  144. # OpenPKG RPM.
  145. echo >>.buildenv 'SOURCE () {'
  146. echo >>.buildenv ' if [ -f "%{_specdir}/$1" ]; then'
  147. echo >>.buildenv ' echo "%{_specdir}/$1"'
  148. echo >>.buildenv ' else'
  149. echo >>.buildenv ' echo "%{_sourcedir}/$1"'
  150. echo >>.buildenv ' fi'
  151. echo >>.buildenv '}'
  152. . ./.buildenv
  153. # determine path to shtool
  154. shtool=`SOURCE shtool`
  155. echo "shtool=$shtool" >>./.buildenv
  156. # manually make sure tar(1) is available
  157. l_tar=`sh $shtool path gtar tar`; export l_tar
  158. if [ ".$l_tar" = . ]; then
  159. echo "openpkg: prerequisite tool \`gtar' or \`tar' not found"
  160. exit 1
  161. fi
  162. echo "l_tar=\"$l_tar\"; export l_tar" >>.buildenv
  163. # manually make sure make(1) is available
  164. l_make=`sh $shtool path gmake make`; export l_make
  165. if [ ".$l_make" = . ]; then
  166. echo "openpkg: prerequisite tool \`gmake' or \`make' not found"
  167. exit 1
  168. fi
  169. echo "l_make=\"$l_make\"; export l_make" >>.buildenv
  170. # manually make sure cc(1) is available
  171. l_cc=`sh $shtool path gcc cc`; export l_cc
  172. if [ ".$l_cc" = . ]; then
  173. echo "openpkg: prerequisite tool \`gcc' or \`cc' not found"
  174. exit 1
  175. fi
  176. echo "l_cc=\"$l_cc\"; export l_cc" >>.buildenv
  177. # manually make sure ar(1) is available
  178. l_ar=`sh $shtool path ar`; export l_ar
  179. if [ ".$l_ar" = . ]; then
  180. echo "openpkg: prerequisite tool \`ar' not found"
  181. exit 1
  182. fi
  183. # manually make sure ld(1) is available
  184. l_ld=`sh $shtool path ld`; export l_ld
  185. if [ ".$l_ld" = . ]; then
  186. echo "openpkg: prerequisite tool \`ld' not found"
  187. exit 1
  188. fi
  189. # determine path to aux.usrgrp.sh script
  190. usrgrp=`SOURCE aux.usrgrp.sh`
  191. echo "usrgrp=$usrgrp" >>./.buildenv
  192. # determine user/group name/id pairs
  193. # - bootstrapping: %{l_[smrn]{usr,grp}} is set via sed(1)
  194. # - upgrading new: %{l_[smrn]{usr,grp}} is set via rpmmacros
  195. # - upgrading old: %{l_[smrn]{usr,grp}} is not set at all
  196. susr=""; [ ".%{?l_susr:set}" = .set ] && susr="%{l_susr}"
  197. sgrp=""; [ ".%{?l_sgrp:set}" = .set ] && sgrp="%{l_sgrp}"
  198. musr=""; [ ".%{?l_musr:set}" = .set ] && musr="%{l_musr}"
  199. mgrp=""; [ ".%{?l_mgrp:set}" = .set ] && mgrp="%{l_mgrp}"
  200. rusr=""; [ ".%{?l_rusr:set}" = .set ] && rusr="%{l_rusr}"
  201. rgrp=""; [ ".%{?l_rgrp:set}" = .set ] && rgrp="%{l_rgrp}"
  202. nusr=""; [ ".%{?l_nusr:set}" = .set ] && nusr="%{l_nusr}"
  203. ngrp=""; [ ".%{?l_ngrp:set}" = .set ] && ngrp="%{l_ngrp}"
  204. # corresponding ids
  205. suid=""; [ ".%{?l_suid:set}" = .set ] && suid="%{l_suid}"
  206. sgid=""; [ ".%{?l_sgid:set}" = .set ] && sgid="%{l_sgid}"
  207. muid=""; [ ".%{?l_muid:set}" = .set ] && muid="%{l_muid}"
  208. mgid=""; [ ".%{?l_mgid:set}" = .set ] && mgid="%{l_mgid}"
  209. ruid=""; [ ".%{?l_ruid:set}" = .set ] && ruid="%{l_ruid}"
  210. rgid=""; [ ".%{?l_rgid:set}" = .set ] && rgid="%{l_rgid}"
  211. nuid=""; [ ".%{?l_nuid:set}" = .set ] && nuid="%{l_nuid}"
  212. ngid=""; [ ".%{?l_ngid:set}" = .set ] && ngid="%{l_ngid}"
  213. # compat:
  214. usr=""; [ ".%{?l_fsusr:set}" = .set ] && usr="%{l_fsusr}"
  215. grp=""; [ ".%{?l_fsgrp:set}" = .set ] && grp="%{l_fsgrp}"
  216. eval `sh $usrgrp \
  217. --usr="$usr" --grp="$grp" \
  218. --susr="$susr" --sgrp="$sgrp" \
  219. --musr="$musr" --mgrp="$mgrp" \
  220. --rusr="$rusr" --rgrp="$rgrp" \
  221. --nusr="$nusr" --ngrp="$ngrp" \
  222. --suid="$suid" --sgid="$sgid" \
  223. --muid="$muid" --mgid="$mgid" \
  224. --ruid="$ruid" --rgid="$rgid" \
  225. --nuid="$nuid" --ngid="$ngid"`
  226. echo "susr=\"$susr\"; export susr" >>.buildenv
  227. echo "sgrp=\"$sgrp\"; export sgrp" >>.buildenv
  228. echo "musr=\"$musr\"; export musr" >>.buildenv
  229. echo "mgrp=\"$mgrp\"; export mgrp" >>.buildenv
  230. echo "rusr=\"$rusr\"; export rusr" >>.buildenv
  231. echo "rgrp=\"$rgrp\"; export rgrp" >>.buildenv
  232. echo "nusr=\"$nusr\"; export nusr" >>.buildenv
  233. echo "ngrp=\"$ngrp\"; export ngrp" >>.buildenv
  234. echo "suid=\"$suid\"; export suid" >>.buildenv
  235. echo "sgid=\"$sgid\"; export sgid" >>.buildenv
  236. echo "muid=\"$muid\"; export muid" >>.buildenv
  237. echo "mgid=\"$mgid\"; export mgid" >>.buildenv
  238. echo "ruid=\"$ruid\"; export ruid" >>.buildenv
  239. echo "rgid=\"$rgid\"; export rgid" >>.buildenv
  240. echo "nuid=\"$nuid\"; export nuid" >>.buildenv
  241. echo "ngid=\"$ngid\"; export ngid" >>.buildenv
  242. # determine installation location id
  243. if [ ".%{?l_location:set}" = .set ]; then
  244. loc="%{l_location}"
  245. else
  246. if [ ".`expr %{l_prefix} : '/[^/][^/]*$'`" != .0 ]; then
  247. loc=`echo %{l_prefix} | cut -c2-4`
  248. else
  249. loc=`echo %{l_prefix} | sed -e 's;/\(.\)[^/]*;\1;g' | cut -c1-3`
  250. fi
  251. fi
  252. echo "loc=\"$loc\"; export loc" >>.buildenv
  253. # determine platform id
  254. s=`(uname -s) 2>/dev/null` || s='Unknown'
  255. r=`(uname -r) 2>/dev/null` || r='0.0'
  256. plid="${s}/${r}"
  257. # determine platform-specific build environment
  258. case $plid in
  259. FreeBSD/* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
  260. Linux/* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
  261. SunOS/* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin:/usr/ccs/bin" ;;
  262. Darwin/* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
  263. * ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
  264. esac
  265. case $plid in
  266. FreeBSD/* ) l_build_ldlp="/usr/lib" ;;
  267. Linux/* ) l_build_ldlp="/lib:/usr/lib" ;;
  268. SunOS/* ) l_build_ldlp="/usr/lib:/usr/ccs/lib" ;;
  269. Darwin/* ) l_build_ldlp="/usr/lib" ;;
  270. * ) l_build_ldlp="/usr/lib" ;;
  271. esac
  272. case $plid in
  273. FreeBSD/4* ) l_build_ulim="ulimit -H -S -f 262144 -d 262144 -m 262144 -s 65536 -u 128" ;;
  274. Linux/2* ) l_build_ulim="ulimit -H -S -f 262144 -d 262144 -m 262144 -v 262144 -s 65536 -u 128" ;;
  275. SunOS/5.8* ) l_build_ulim="ulimit -H -S -f 262144 -d 262144 -s 65536" ;;
  276. Darwin/* ) l_build_ulim=":" ;;
  277. * ) l_build_ulim=":" ;;
  278. esac
  279. echo "l_build_path=\"$l_build_path\"; export l_build_path" >>.buildenv
  280. echo "l_build_ldlp=\"$l_build_ldlp\"; export l_build_ldlp" >>.buildenv
  281. echo "l_build_ulim=\"$l_build_ulim\"; export l_build_ulim" >>.buildenv
  282. # bootstrap GNU zip tool
  283. ${l_tar} xf `SOURCE gzip-%{V_gzip}.tar` 2>/dev/null || true
  284. ( cd gzip-%{V_gzip}
  285. CC="${l_cc}" ./configure
  286. ${l_make}
  287. )
  288. l_gzip="`pwd`/gzip-%{V_gzip}/gzip"; export l_gzip
  289. echo "l_gzip=\"$l_gzip\"; export l_gzip" >>.buildenv
  290. # unpack distribution tarballs
  291. ${l_gzip} -dc `SOURCE rpm-%{V_rpm}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  292. ${l_gzip} -dc `SOURCE zlib-%{V_zlib}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  293. ${l_gzip} -dc `SOURCE bzip2-%{V_bzip2}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  294. ${l_gzip} -dc `SOURCE db-%{V_db}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  295. ${l_gzip} -dc `SOURCE curl-%{V_curl}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  296. ${l_gzip} -dc `SOURCE make-%{V_make}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  297. ${l_gzip} -dc `SOURCE patch-%{V_patch}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  298. ${l_gzip} -dc `SOURCE tar-%{V_tar}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  299. ${l_gzip} -dc `SOURCE bash-%{V_bash}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
  300. # update config.guess/config.sub
  301. for dir in rpm-%{V_rpm} rpm-%{V_rpm}/popt db-%{V_db}/dist \
  302. curl-%{V_curl} make-%{V_make} patch-%{V_patch} tar-%{V_tar} bash-%{V_bash}/support; do
  303. chmod u+w $dir/config.guess $dir/config.sub >/dev/null 2>&1 || true
  304. cp `SOURCE config.guess` $dir/
  305. cp `SOURCE config.sub` $dir/
  306. done
  307. # bootstrap GNU patch tool
  308. ( cd patch-%{V_patch}
  309. echo 'ac_cv_func_setmode=${ac_cv_func_setmode=no}' >config.cache
  310. false=`sh $shtool path false`
  311. echo "ac_cv_path_ed_PROGRAM=\${ac_cv_path_ed_PROGRAM=$false}" >>config.cache
  312. CC="${l_cc}" ./configure --disable-largefile
  313. ${l_make}
  314. (mv patch ..; ${l_make} clean || true; mv ../patch .)
  315. ) || exit $?
  316. l_patch="`pwd`/patch-%{V_patch}/patch"; export l_patch
  317. echo "l_patch=\"$l_patch\"; export l_patch" >>.buildenv
  318. # apply OpenPKG patches to distribution trees
  319. ( cd rpm-%{V_rpm}
  320. ${l_patch} -p0 <`SOURCE rpm.patch.bugfix`
  321. ${l_patch} -p0 <`SOURCE rpm.patch.feature`
  322. ${l_patch} -p0 <`SOURCE rpm.patch.porting`
  323. ${l_patch} -p0 <`SOURCE rpm.patch.regen`
  324. touch aclocal.m4 configure
  325. ) || exit $?
  326. ( cd db-%{V_db}
  327. ${l_patch} -p0 <`SOURCE db.patch`
  328. ) || exit $?
  329. ( cd make-%{V_make}
  330. ${l_patch} -p0 <`SOURCE make.patch`
  331. ) || exit $?
  332. # bootstrap GNU make tool
  333. ( cd make-%{V_make}
  334. CC="${l_cc}" ./configure --disable-nls --disable-largefile
  335. ${l_make}
  336. (mv make ..; ${l_make} clean || true; mv ../make .)
  337. ) || exit $?
  338. l_make="`pwd`/make-%{V_make}/make"; export l_make
  339. echo "l_make=\"$l_make\"; export l_make" >>.buildenv
  340. %build
  341. # skip in bootstrap phase 2 (see openpkg.boot)
  342. [ ".$OPENPKG_BOOT" = .1 ] && exit 0
  343. # switch into a temporary build area
  344. cd %{name}-%{version}
  345. . ./.buildenv
  346. # build GNU bash tool
  347. ( cd bash-%{V_bash}
  348. ( # force disabled wide-character support
  349. echo "ac_cv_header_wchar_h=no"
  350. echo "ac_cv_header_wctype_h=no"
  351. echo "ac_cv_func_mbsrtowcs=no"
  352. # force disabled internationalization support
  353. echo "ac_cv_header_libintl_h=no"
  354. echo "ac_cv_func_gettext=no"
  355. echo "ac_cv_func_textdomain=no"
  356. echo "ac_cv_func_bindtextdomain=no"
  357. echo "ac_cv_lib_intl_bindtextdomain=no"
  358. ) >config.cache || exit $?
  359. CC="${l_cc}"
  360. ./configure \
  361. --cache-file=./config.cache \
  362. --prefix=%{l_prefix} \
  363. --without-curses \
  364. --without-gnu-malloc \
  365. --disable-nls
  366. ${l_make} || exit $?
  367. (mv bash ..; ${l_make} clean || true; mv ../bash .)
  368. ) || exit $?
  369. # build GNU tar tool
  370. ( cd tar-%{V_tar}
  371. echo 'am_cv_func_iconv=${am_cv_func_iconv=no}' >config.cache
  372. echo 'am_cv_lib_iconv=${am_cv_lib_iconv=no}' >config.cache
  373. echo 'am_cv_func_iconv=${am_cv_func_iconv=no}' >config.cache
  374. CC="${l_cc}"
  375. ../bash-%{V_bash}/bash \
  376. ./configure \
  377. --config-cache \
  378. --prefix=%{l_prefix} \
  379. --disable-nls
  380. ${l_make} || exit $?
  381. (mv src/tar ..; ${l_make} clean || true; mv ../tar src/)
  382. ) || exit $?
  383. # build BZIP2 library
  384. ( cd bzip2-%{V_bzip2}
  385. ${l_make} CC="${l_cc}" CFLAGS="-O" libbz2.a bzip2 || exit $?
  386. ) || exit $?
  387. # build ZLIB library
  388. ( cd zlib-%{V_zlib}
  389. CC="${l_cc}" CFLAGS="-O" ./configure
  390. ${l_make} CC="${l_cc}" CFLAGS="-O" libz.a || exit $?
  391. ) || exit $?
  392. # build cURL tool
  393. ( cd curl-%{V_curl}
  394. echo 'ac_cv_header_openssl_engine_h=no' >config.cache
  395. CC="${l_cc}" \
  396. CFLAGS="-I`pwd`/../zlib-%{V_zlib}" \
  397. CPPFLAGS="-I`pwd`/../zlib-%{V_zlib}" \
  398. LDFLAGS="-L`pwd`/../zlib-%{V_zlib}" \
  399. ./configure \
  400. --cache-file=./config.cache \
  401. --without-ssl \
  402. --disable-shared \
  403. --disable-thread \
  404. --disable-ipv6 \
  405. --with-zlib=`pwd`/../zlib-%{V_zlib}
  406. ${l_make} || exit $?
  407. (mv src/curl ..; ${l_make} clean || true; mv ../curl ./src)
  408. ) || exit $?
  409. # build Berkeley-DB library
  410. ( cd db-%{V_db}/build_unix
  411. case `sh ../dist/config.guess` in
  412. *-*-osf* ) echo 'db_cv_mutex=${db_cv_mutex=UNIX/msem_init}' >config.cache ;; # avoid dependency to pthread
  413. esac
  414. CC="${l_cc}" ../dist/configure
  415. ${l_make} libdb.a || exit $?
  416. ln libdb.a libdbXXX.a # workaround for Tru64
  417. ) || exit $?
  418. # build RPM
  419. # - we make sure RPM builds without NLS/gettext problems :-(
  420. # - we make sure RPM finds and uses our own BZIP2/ZLIB/DB libraries
  421. # - we speed up building by skipping the NLS/gettext data
  422. ( br=`pwd`
  423. cd rpm-%{V_rpm}
  424. sed -e 's;(aclocal --version);false;' \
  425. -e 's;(automake --version);false;' \
  426. -e 's;(autoconf --version);false;' \
  427. -e 's;(autoheader --version);false;' \
  428. -e 's;(makeinfo --version);false;' \
  429. -e 's;/lib/rpm;/lib/openpkg;' \
  430. -e "s;MKDIR_P=.*;MKDIR_P='%{l_prefix}/lib/openpkg/shtool mkdir -f -p -m 755';" \
  431. -e 's;LDFLAGS_STATIC="[^"]*";LDFLAGS_STATIC="";g' \
  432. <configure >configure.n && \
  433. mv configure.n configure
  434. sed -e 's;@INTLLIBS@;@INTLLIBS@ @LIBMISC@;' \
  435. <tools/Makefile.in >tools/Makefile.in.n && \
  436. mv tools/Makefile.in.n tools/Makefile.in
  437. sed -e 's;^\(SUBDIRS[ ]*=.*\) po \(.*\)$;\1 \2;' \
  438. -e 's;^\(SUBDIRS[ ]*=.*\) tools \(.*\)$;\1 \2;' \
  439. -e 's;^\(LIBS[ ]*=\).*;\1 @LIBS@ $(EXTRA_LIBS);' \
  440. <Makefile.in >Makefile.in.n && mv Makefile.in.n Makefile.in
  441. sed -e 's;^\(SUBDIRS[ ]*=.*\) po$;\1;' \
  442. <popt/Makefile.in >popt/Makefile.in.n && \
  443. mv popt/Makefile.in.n popt/Makefile.in
  444. sed -e 's;BUFSIZ;8192;g' \
  445. <rpmio/macro.c >rpmio/macro.c.n && \
  446. mv rpmio/macro.c.n rpmio/macro.c
  447. ( echo 'ac_cv_path_MSGFMT=${ac_cv_path_MSGFMT=no}'
  448. echo 'ac_cv_path_GMSGFMT=${ac_cv_path_GMSGFMT=no}'
  449. echo "ac_cv_path_MKDIR=%{l_prefix}/lib/openpkg/shtool mkdir -f -p -m 755}"
  450. echo "ac_cv_path___MKDIR=%{l_prefix}/lib/openpkg/shtool mkdir -f -p -m 755}"
  451. ) >config.cache
  452. case `sh ./config.guess` in
  453. *-*-linux* ) nlsopt="--disable-nls" ;;
  454. * ) nlsopt="--enable-nls --with-included-gettext" ;;
  455. esac
  456. nlsopt="--disable-nls"
  457. CC="${l_cc} -DOPENPKG -I$br/db-%{V_db}/build_unix -I$br/zlib-%{V_zlib} -I$br/bzip2-%{V_bzip2}" \
  458. CFLAGS="-DOPENPKG -I$br/db-%{V_db}/build_unix -I$br/zlib-%{V_zlib} -I$br/bzip2-%{V_bzip2}" \
  459. CPPFLAGS="-DOPENPKG -I$br/db-%{V_db}/build_unix -I$br/zlib-%{V_zlib} -I$br/bzip2-%{V_bzip2}" \
  460. LDFLAGS="-L$br/db-%{V_db}/build_unix -L$br/zlib-%{V_zlib} -L$br/bzip2-%{V_bzip2}" \
  461. LIBS="-L$br/db-%{V_db}/build_unix -ldbXXX -L$br/zlib-%{V_zlib} -lz -L$br/bzip2-%{V_bzip2} -lbz2" \
  462. sh ./configure \
  463. --prefix=%{l_prefix} \
  464. --disable-shared \
  465. --disable-db1 \
  466. --with-glob \
  467. $nlsopt
  468. ${l_make} \
  469. EXTRA_LIBS="-L$br/db-%{V_db}/build_unix -ldbXXX -L$br/zlib-%{V_zlib} -lz -L$br/bzip2-%{V_bzip2} -lbz2"
  470. ) || exit $?
  471. %install
  472. # skip in bootstrap phase 2 (see openpkg.boot)
  473. [ ".$OPENPKG_BOOT" = .1 ] && exit 0
  474. # switch into a temporary build area
  475. cd %{name}-%{version}
  476. . ./.buildenv
  477. # create installation hierarchy
  478. rm -rf $RPM_BUILD_ROOT
  479. sh $shtool mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}
  480. for dir in bin etc include info lib libexec man sbin share var cgi pub local; do
  481. test -d $RPM_BUILD_ROOT%{l_prefix}/$dir || \
  482. mkdir $RPM_BUILD_ROOT%{l_prefix}/$dir
  483. done
  484. for i in 1 2 3 4 5 6 7 8 9; do
  485. test -d $RPM_BUILD_ROOT%{l_prefix}/man/man$i || \
  486. mkdir $RPM_BUILD_ROOT%{l_prefix}/man/man$i
  487. test -d $RPM_BUILD_ROOT%{l_prefix}/man/cat$i || \
  488. mkdir $RPM_BUILD_ROOT%{l_prefix}/man/cat$i
  489. done
  490. for dir in PKG bin etc include info lib man sbin; do
  491. test -d $RPM_BUILD_ROOT%{l_prefix}/local/$dir || \
  492. mkdir $RPM_BUILD_ROOT%{l_prefix}/local/$dir
  493. done
  494. for i in 1 2 3 4 5 6 7 8 9; do
  495. test -d $RPM_BUILD_ROOT%{l_prefix}/local/man/man$i || \
  496. mkdir $RPM_BUILD_ROOT%{l_prefix}/local/man/man$i
  497. test -d $RPM_BUILD_ROOT%{l_prefix}/local/man/cat$i || \
  498. mkdir $RPM_BUILD_ROOT%{l_prefix}/local/man/cat$i
  499. done
  500. test -d $RPM_BUILD_ROOT%{l_prefix}/RPM || \
  501. mkdir $RPM_BUILD_ROOT%{l_prefix}/RPM
  502. for dir in SRC PKG DB TMP; do
  503. test -d $RPM_BUILD_ROOT%{l_prefix}/RPM/$dir || \
  504. mkdir $RPM_BUILD_ROOT%{l_prefix}/RPM/$dir
  505. done
  506. # install RPM into installation hierarchy
  507. ( cd rpm-%{V_rpm}
  508. ${l_make} DESTDIR="$RPM_BUILD_ROOT" install
  509. ) || exit $?
  510. # strip RPM installation
  511. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* \
  512. $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/* >/dev/null 2>&1 || true
  513. for dir in man/ja man/pl man/ru man/sk src; do
  514. rm -rf $RPM_BUILD_ROOT%{l_prefix}/$dir >/dev/null 2>&1 || true
  515. done
  516. for file in rpmbuild rpmdb rpme rpmi rpmsign rpmu rpmverify rpmquery gendiff; do
  517. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/$file >/dev/null 2>&1 || true
  518. done
  519. rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/* >/dev/null 2>&1 || true
  520. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/* >/dev/null 2>&1 || true
  521. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man3/* >/dev/null 2>&1 || true
  522. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/rpmpopt >/dev/null 2>&1 || true
  523. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/rpmrc >/dev/null 2>&1 || true
  524. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/lib*.la >/dev/null 2>&1 || true
  525. rm -rf $RPM_BUILD_ROOT%{l_prefix}/var/lib >/dev/null 2>&1 || true
  526. for file in \
  527. u_pkg.sh vpkg-provides.sh vpkg-provides2.sh rpmdiff.cgi rpmdiff \
  528. perl.prov perl.req mkinstalldirs magic.prov magic.req http.req \
  529. getpo.sh get_magic.pl find-requires.perl find-req.pl find-provides.perl \
  530. find-prov.pl find-lang.sh cpanflute convertrpmrc.sh check-prereqs \
  531. rpmputtext rpmgettext brp-compress brp-redhat brp-sparc64-linux \
  532. brp-strip brp-strip-shared brp-strip-comment-note rpmrc \
  533. config.guess config.sub; do
  534. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/$file >/dev/null 2>&1 || true
  535. done
  536. # add additional development files
  537. cp zlib-%{V_zlib}/zlib.h $RPM_BUILD_ROOT%{l_prefix}/include/rpm/
  538. cp zlib-%{V_zlib}/libz.a $RPM_BUILD_ROOT%{l_prefix}/lib/librpmz.a
  539. cp db-%{V_db}/build_unix/db.h $RPM_BUILD_ROOT%{l_prefix}/include/rpm/
  540. cp db-%{V_db}/build_unix/libdb.a $RPM_BUILD_ROOT%{l_prefix}/lib/librpmdb.a
  541. # post-adjust RPM installation (namespace-clean POPT inclusion)
  542. mv $RPM_BUILD_ROOT%{l_prefix}/lib/libpopt.a \
  543. $RPM_BUILD_ROOT%{l_prefix}/lib/librpmpopt.a
  544. mv $RPM_BUILD_ROOT%{l_prefix}/include/popt.h \
  545. $RPM_BUILD_ROOT%{l_prefix}/include/rpm/popt.h
  546. # replace symlinks with hardlinks
  547. for entry in rpme:rpmi rpmt:rpmb rpmu:rpmi rpmv:rpmq; do
  548. eval `echo $entry | sed -e 's/^\(.*\):\(.*\)$/dst=\1; src=\2/'`
  549. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/$dst
  550. ln $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/$src \
  551. $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/$dst
  552. done
  553. # install lsync tool
  554. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  555. <`SOURCE lsync` \
  556. >$RPM_BUILD_ROOT%{l_prefix}/sbin/lsync
  557. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/sbin/lsync
  558. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  559. <`SOURCE dot.lsyncrc` \
  560. >$RPM_BUILD_ROOT%{l_prefix}/local/.lsyncrc
  561. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  562. <`SOURCE lsync.8` \
  563. >$RPM_BUILD_ROOT%{l_prefix}/man/man8/lsync.8
  564. # install RPM extension
  565. ( cd curl-%{V_curl}
  566. cp src/curl $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/curl
  567. strip $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/curl
  568. )
  569. ( cd bzip2-%{V_bzip2}
  570. cp bzip2 $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bzip2
  571. strip $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bzip2
  572. )
  573. ( cd gzip-%{V_gzip}
  574. cp gzip $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/gzip
  575. strip $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/gzip
  576. )
  577. ( cd patch-%{V_patch}
  578. cp patch $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/patch
  579. strip $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/patch
  580. )
  581. ( cd tar-%{V_tar}
  582. cp src/tar $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/tar
  583. strip $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/tar
  584. )
  585. ( cd bash-%{V_bash}
  586. cp bash $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bash
  587. strip $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bash
  588. )
  589. sed -e "s;@l_prefix@;%{l_prefix};g" \
  590. <`SOURCE rpmx.sh` >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmx.sh
  591. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmx.sh
  592. sed -e "s;@l_prefix@;%{l_prefix};g" \
  593. <`SOURCE rpmx.pl` >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmx.pl
  594. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmx.pl
  595. sed -e "s;@l_prefix@;%{l_prefix};g" \
  596. <`SOURCE mkproxyrpm.pl` >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/mkproxyrpm.pl
  597. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/mkproxyrpm.pl
  598. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  599. <`SOURCE rpmtool` >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmtool
  600. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmtool
  601. # install an own copy of shtool
  602. cp $shtool $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/shtool
  603. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/shtool
  604. # install GNU config scripts
  605. cp `SOURCE config.guess` $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/
  606. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/config.guess
  607. cp `SOURCE config.sub` $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/
  608. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/config.sub
  609. # install a few README files
  610. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  611. <`SOURCE root.README` \
  612. >$RPM_BUILD_ROOT%{l_prefix}/README
  613. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  614. <`SOURCE local.README` \
  615. >$RPM_BUILD_ROOT%{l_prefix}/local/README
  616. # install Bash environment
  617. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  618. <`SOURCE dot.bashrc` \
  619. >$RPM_BUILD_ROOT%{l_prefix}/.bashrc
  620. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  621. <`SOURCE dot.bash_login` \
  622. >$RPM_BUILD_ROOT%{l_prefix}/.bash_login
  623. # install Run-Command files
  624. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  625. <`SOURCE rc` \
  626. >$RPM_BUILD_ROOT%{l_prefix}/etc/rc
  627. chmod 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc
  628. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  629. <`SOURCE rc.conf` \
  630. >$RPM_BUILD_ROOT%{l_prefix}/etc/rc.conf
  631. chmod 644 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.conf
  632. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  633. <`SOURCE rc.func` \
  634. >$RPM_BUILD_ROOT%{l_prefix}/etc/rc.func
  635. chmod 644 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.func
  636. mkdir $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  637. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  638. <`SOURCE rc.openpkg` \
  639. >$RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/rc.openpkg
  640. chmod 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/rc.openpkg
  641. # hard-code RPM tool for installation hierarchy
  642. # and adjust RPM configuration files
  643. mv $RPM_BUILD_ROOT%{l_prefix}/bin/rpm \
  644. $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpm
  645. ( echo "#!%{l_prefix}/lib/openpkg/bash";
  646. echo "exec %{l_prefix}/lib/openpkg/rpm --rcfile %{l_prefix}/etc/openpkg/rpmrc \${1+\"\$@\"}"
  647. ) >$RPM_BUILD_ROOT%{l_prefix}/bin/rpm
  648. chmod 755 $RPM_BUILD_ROOT%{l_prefix}/bin/rpm
  649. cat `SOURCE rpmpopt` \
  650. >>$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmpopt-%{V_rpm}
  651. test -d $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg || \
  652. mkdir $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg
  653. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  654. <`SOURCE rpmrc` \
  655. >$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/rpmrc
  656. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  657. -e "s;@l_build_path@;$l_build_path;g" \
  658. -e "s;@l_build_ldlp@;$l_build_ldlp;g" \
  659. -e "s;@l_build_ulim@;$l_build_ulim;g" \
  660. -e "s:@LOC@:$loc:g" \
  661. -e "s:@SUSR@:$susr:g" \
  662. -e "s:@SGRP@:$sgrp:g" \
  663. -e "s:@MUSR@:$musr:g" \
  664. -e "s:@MGRP@:$mgrp:g" \
  665. -e "s:@RUSR@:$rusr:g" \
  666. -e "s:@RGRP@:$rgrp:g" \
  667. -e "s:@NUSR@:$nusr:g" \
  668. -e "s:@NGRP@:$ngrp:g" \
  669. <`SOURCE rpmmacros` \
  670. >$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/rpmmacros
  671. cp `SOURCE openpkg.pgp` \
  672. $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/openpkg.pgp
  673. %files
  674. %defattr(-,%{?l_musr}%{!?l_musr:%{l_fsusr}},%{?l_mgrp}%{!?l_mgrp:%{l_fsgrp}})
  675. %{l_prefix}/README
  676. %config(noreplace) %{l_prefix}/.bashrc
  677. %config(noreplace) %{l_prefix}/.bash_login
  678. %dir %{l_prefix}/RPM
  679. %dir %{l_prefix}/RPM/SRC
  680. %dir %{l_prefix}/RPM/PKG
  681. %dir %{l_prefix}/RPM/DB
  682. %dir %{l_prefix}/RPM/TMP
  683. %dir %{l_prefix}/cgi
  684. %dir %{l_prefix}/bin
  685. %{l_prefix}/bin/rpm2cpio
  686. %{l_prefix}/bin/rpm
  687. %dir %{l_prefix}/etc
  688. %{l_prefix}/etc/rc
  689. %config(noreplace) %{l_prefix}/etc/rc.conf
  690. %{l_prefix}/etc/rc.func
  691. %dir %{l_prefix}/etc/rc.d
  692. %{l_prefix}/etc/rc.d/rc.openpkg
  693. %dir %{l_prefix}/etc/openpkg
  694. %config %{l_prefix}/etc/openpkg/rpmmacros
  695. %config %{l_prefix}/etc/openpkg/rpmrc
  696. %{l_prefix}/etc/openpkg/openpkg.pgp
  697. %dir %{l_prefix}/include
  698. %dir %{l_prefix}/include/rpm
  699. %{l_prefix}/include/rpm/popt.h
  700. %{l_prefix}/include/rpm/header.h
  701. %{l_prefix}/include/rpm/misc.h
  702. %{l_prefix}/include/rpm/rpmbuild.h
  703. %{l_prefix}/include/rpm/rpmerr.h
  704. %{l_prefix}/include/rpm/rpmio.h
  705. %{l_prefix}/include/rpm/rpmlib.h
  706. %{l_prefix}/include/rpm/rpmlog.h
  707. %{l_prefix}/include/rpm/rpmmacro.h
  708. %{l_prefix}/include/rpm/rpmmessages.h
  709. %{l_prefix}/include/rpm/rpmspec.h
  710. %{l_prefix}/include/rpm/rpmurl.h
  711. %{l_prefix}/include/rpm/stringbuf.h
  712. %{l_prefix}/include/rpm/ugid.h
  713. %{l_prefix}/include/rpm/db.h
  714. %{l_prefix}/include/rpm/zlib.h
  715. %dir %{l_prefix}/info
  716. %dir %{l_prefix}/lib
  717. %dir %{l_prefix}/lib/openpkg
  718. %{l_prefix}/lib/openpkg/bash
  719. %{l_prefix}/lib/openpkg/bzip2
  720. %{l_prefix}/lib/openpkg/curl
  721. %{l_prefix}/lib/openpkg/find-provides
  722. %{l_prefix}/lib/openpkg/find-requires
  723. %{l_prefix}/lib/openpkg/gzip
  724. %{l_prefix}/lib/openpkg/macros
  725. %{l_prefix}/lib/openpkg/mkproxyrpm.pl
  726. %{l_prefix}/lib/openpkg/patch
  727. %{l_prefix}/lib/openpkg/rpm
  728. %{l_prefix}/lib/openpkg/rpmb
  729. %{l_prefix}/lib/openpkg/rpmdb
  730. %{l_prefix}/lib/openpkg/rpme
  731. %{l_prefix}/lib/openpkg/rpmi
  732. %{l_prefix}/lib/openpkg/rpmk
  733. %{l_prefix}/lib/openpkg/rpmpopt-%{V_rpm}
  734. %{l_prefix}/lib/openpkg/rpmq
  735. %{l_prefix}/lib/openpkg/rpmt
  736. %{l_prefix}/lib/openpkg/rpmtool
  737. %{l_prefix}/lib/openpkg/rpmu
  738. %{l_prefix}/lib/openpkg/rpmv
  739. %{l_prefix}/lib/openpkg/rpmx.pl
  740. %{l_prefix}/lib/openpkg/rpmx.sh
  741. %{l_prefix}/lib/openpkg/shtool
  742. %{l_prefix}/lib/openpkg/tar
  743. %{l_prefix}/lib/openpkg/config.guess
  744. %{l_prefix}/lib/openpkg/config.sub
  745. %{l_prefix}/lib/librpmpopt.a
  746. %{l_prefix}/lib/librpm.a
  747. %{l_prefix}/lib/librpmbuild.a
  748. %{l_prefix}/lib/librpmio.a
  749. %{l_prefix}/lib/librpmz.a
  750. %{l_prefix}/lib/librpmdb.a
  751. %dir %{l_prefix}/libexec
  752. %dir %{l_prefix}/man
  753. %dir %{l_prefix}/man/man1
  754. %dir %{l_prefix}/man/man2
  755. %dir %{l_prefix}/man/man3
  756. %dir %{l_prefix}/man/man4
  757. %dir %{l_prefix}/man/man5
  758. %dir %{l_prefix}/man/man6
  759. %dir %{l_prefix}/man/man7
  760. %dir %{l_prefix}/man/man8
  761. %dir %{l_prefix}/man/man9
  762. %dir %{l_prefix}/man/cat1
  763. %dir %{l_prefix}/man/cat2
  764. %dir %{l_prefix}/man/cat3
  765. %dir %{l_prefix}/man/cat4
  766. %dir %{l_prefix}/man/cat5
  767. %dir %{l_prefix}/man/cat6
  768. %dir %{l_prefix}/man/cat7
  769. %dir %{l_prefix}/man/cat8
  770. %dir %{l_prefix}/man/cat9
  771. %{l_prefix}/man/man8/rpm.8
  772. %{l_prefix}/man/man8/rpm2cpio.8
  773. %{l_prefix}/man/man8/lsync.8
  774. %dir %{l_prefix}/sbin
  775. %dir %{l_prefix}/pub
  776. %dir %{l_prefix}/share
  777. %dir %{l_prefix}/var
  778. %{l_prefix}/sbin/lsync
  779. %dir %{l_prefix}/local
  780. %{l_prefix}/local/README
  781. %{l_prefix}/local/.lsyncrc
  782. %dir %{l_prefix}/local/PKG
  783. %dir %{l_prefix}/local/bin
  784. %dir %{l_prefix}/local/etc
  785. %dir %{l_prefix}/local/include
  786. %dir %{l_prefix}/local/info
  787. %dir %{l_prefix}/local/lib
  788. %dir %{l_prefix}/local/man
  789. %dir %{l_prefix}/local/man/man1
  790. %dir %{l_prefix}/local/man/man2
  791. %dir %{l_prefix}/local/man/man3
  792. %dir %{l_prefix}/local/man/man4
  793. %dir %{l_prefix}/local/man/man5
  794. %dir %{l_prefix}/local/man/man6
  795. %dir %{l_prefix}/local/man/man7
  796. %dir %{l_prefix}/local/man/man8
  797. %dir %{l_prefix}/local/man/man9
  798. %dir %{l_prefix}/local/man/cat1
  799. %dir %{l_prefix}/local/man/cat2
  800. %dir %{l_prefix}/local/man/cat3
  801. %dir %{l_prefix}/local/man/cat4
  802. %dir %{l_prefix}/local/man/cat5
  803. %dir %{l_prefix}/local/man/cat6
  804. %dir %{l_prefix}/local/man/cat7
  805. %dir %{l_prefix}/local/man/cat8
  806. %dir %{l_prefix}/local/man/cat9
  807. %dir %{l_prefix}/local/sbin
  808. %clean
  809. # skip in bootstrap phase 2 (see openpkg.boot)
  810. [ ".$OPENPKG_BOOT" = .1 ] && exit 0
  811. # cleanup after building
  812. rm -rf $RPM_BUILD_ROOT
  813. rm -rf %{name}-%{version}
  814. %pre
  815. # always performed for upgrades and because it doesn't harm!
  816. # [ ".$1" != .1 ] && exit 0
  817. # this procedure is only usable with root privileges
  818. # (for non-root installations it is not required at all)
  819. cusr=`(id -un) 2>/dev/null ||\
  820. (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
  821. (whoami) 2>/dev/null ||\
  822. (who am i | cut "-d " -f1) 2>/dev/null ||\
  823. echo $LOGNAME`
  824. # determine runtime details (for both inside and outside RPM!!)
  825. # - bootstrapping: $xxx is set from aux.wrapbin.sh
  826. # - upgrading new: %{l_[smrn]{usr,grp}} is set via rpmmacros
  827. # - upgrading old: %{l_[smrn]{usr,grp}} is not set at all
  828. [ ".$susr" = . ] && susr="%{?l_susr}%{!?l_susr:root}"
  829. [ ".$sgrp" = . ] && sgrp="%{?l_sgrp}%{!?l_sgrp:wheel}"
  830. [ ".$musr" = . ] && musr="%{?l_musr}%{!?l_musr:%{l_fsusr}}"
  831. [ ".$mgrp" = . ] && mgrp="%{?l_mgrp}%{!?l_mgrp:%{l_fsgrp}}"
  832. [ ".$rusr" = . ] && rusr="%{?l_rusr}%{!?l_rusr:%{l_fsusr}-r}"
  833. [ ".$rgrp" = . ] && rgrp="%{?l_rgrp}%{!?l_rgrp:%{l_fsgrp}-r}"
  834. [ ".$nusr" = . ] && nusr="%{?l_nusr}%{!?l_nusr:%{l_fsusr}-n}"
  835. [ ".$ngrp" = . ] && ngrp="%{?l_ngrp}%{!?l_ngrp:%{l_fsgrp}-n}"
  836. # if any of these optional params are not used we won't have a
  837. # corresponding macro either, so make use of one conditionally
  838. [ ".$suid" = . ] && [ ".%{?l_suid:set}" = .set ] && suid="%{?l_suid}"
  839. [ ".$sgid" = . ] && [ ".%{?l_sgid:set}" = .set ] && sgid="%{?l_sgid}"
  840. [ ".$muid" = . ] && [ ".%{?l_muid:set}" = .set ] && muid="%{?l_muid}"
  841. [ ".$mgid" = . ] && [ ".%{?l_mgid:set}" = .set ] && mgid="%{?l_mgid}"
  842. [ ".$ruid" = . ] && [ ".%{?l_ruid:set}" = .set ] && ruid="%{?l_ruid}"
  843. [ ".$rgid" = . ] && [ ".%{?l_rgid:set}" = .set ] && rgid="%{?l_rgid}"
  844. [ ".$nuid" = . ] && [ ".%{?l_nuid:set}" = .set ] && nuid="%{?l_nuid}"
  845. [ ".$ngid" = . ] && [ ".%{?l_ngid:set}" = .set ] && ngid="%{?l_ngid}"
  846. # determine prefix
  847. [ ".$prefix" = . ] && prefix="%{l_prefix}"
  848. prefix=`echo "$prefix" | sed -e 's;//*;/;g' -e 's;/$;;'`
  849. # determine user/group ids
  850. for class in s m r n; do
  851. eval "xusr=\"\$${class}usr\""
  852. eval "xgrp=\"\$${class}grp\""
  853. eval "xuid=\"\$${class}uid\""
  854. eval "xgid=\"\$${class}gid\""
  855. if [ ".$xuid" = . ]; then
  856. xuid=`(getent passwd; cat /etc/passwd; ypcat passwd; nidump passwd .) 2>/dev/null |\
  857. grep "^${xusr}:" | awk -F: '{ print $3; }'`
  858. if [ ".$xuid" = . ]; then
  859. # seek for a reasonably uid/gid pair
  860. xuid=1000
  861. ok=0
  862. while [ ".$ok" = .0 ]; do
  863. eval "u_exists=\$u_exists_$xuid"
  864. if [ ".$u_exists" = . ]; then
  865. u_exists=`(getent passwd; cat /etc/passwd; ypcat passwd; nidump passwd .) 2>/dev/null | grep "^[^:]*:[^:]*:$xuid:"`
  866. fi
  867. eval "g_exists=\$g_exists_$xuid"
  868. if [ ".$g_exists" = . ]; then
  869. g_exists=`(getent group; cat /etc/group; ypcat group; nidump group .) 2>/dev/null | grep "^[^:]*:[^:]*:$xuid:"`
  870. fi
  871. if [ ".$u_exists" = . -a ".$g_exists" = . ]; then
  872. ok=1
  873. break
  874. fi
  875. xuid=`expr $xuid + 1`
  876. done
  877. eval "u_exists_$xuid=yes"
  878. eval "g_exists_$xuid=yes"
  879. fi
  880. fi
  881. if [ ".$xgid" = . ]; then
  882. xgid=`(getent group; cat /etc/group; ypcat group; nidump group .) 2>/dev/null |\
  883. grep "^${xgrp}:" | awk -F: '{ print $3; }'`
  884. if [ ".$xgid" = . ]; then
  885. xgid="$xuid"
  886. fi
  887. fi
  888. eval "${class}uid=\"$xuid\""
  889. eval "${class}gid=\"$xgid\""
  890. done
  891. # determine platform id
  892. s=`(uname -s) 2>/dev/null` || s='Unknown'
  893. r=`(uname -r) 2>/dev/null` || r='0.0'
  894. plid="${s}/${r}"
  895. # add entry to /etc/shells
  896. shell="${prefix}/lib/openpkg/bash"
  897. exists=`cat /etc/shells 2>/dev/null | grep "^$shell"`
  898. if [ ".$exists" = . ]; then
  899. if [ ".$cusr" != ".root" ]; then
  900. echo "openpkg:WARNING: skipping addition of $shell to /etc/shells" 1>&2
  901. echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  902. else
  903. echo "${shell}" >>/etc/shells
  904. fi
  905. fi
  906. # create the hierarchy user/group
  907. for req in "superuser:${susr}:${suid}:${sgrp}:${sgid}" \
  908. "management:${musr}:${muid}:${mgrp}:${mgid}" \
  909. "restricted:${rusr}:${ruid}:${rgrp}:${rgid}" \
  910. "non-privileged:${nusr}:${nuid}:${ngrp}:${ngid}"; do
  911. # split request into class/usr/uid/grp/gid
  912. OIFS="$IFS"; IFS=":"; set -- $req; IFS="$OIFS"
  913. class="$1"; usr="$2"; uid="$3"; grp="$4"; gid="$5"
  914. # check whether user already exists
  915. exists=`(getent passwd; cat /etc/passwd; ypcat passwd; nidump passwd .) 2>/dev/null | grep "^$usr:"`
  916. if [ ".$exists" = . ]; then
  917. if [ ".$cusr" != ".root" ]; then
  918. echo "openpkg:WARNING: skipping creation of OpenPKG $class user $usr" 1>&2
  919. echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  920. else
  921. # add entry to passwd database
  922. realname="${prefix} OpenPKG ($class)"
  923. case "$plid" in
  924. FreeBSD/* | NetBSD/* )
  925. file=/etc/master.passwd
  926. entry="${usr}:*:${uid}:${gid}::0:0:${realname}:${prefix}:${shell}"
  927. update="(PATH=\$PATH:/usr/sbin; pwd_mkdb -p /etc/master.passwd)"
  928. ;;
  929. Linux/* )
  930. file=/etc/passwd
  931. entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
  932. update="(PATH=\$PATH:/usr/sbin; pwconv)"
  933. ;;
  934. SunOS/5.* )
  935. file=/etc/passwd
  936. entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
  937. update="(PATH=\$PATH:/usr/sbin; pwconv)"
  938. ;;
  939. OSF1/V5.* )
  940. file=/etc/passwd
  941. entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
  942. update="(PATH=\$PATH:/usr/sbin; mkpasswd /etc/passwd)"
  943. ;;
  944. HP-UX/* )
  945. file=/etc/passwd
  946. entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
  947. update=":"
  948. ;;
  949. Darwin/* )
  950. # intentionally do nothing here
  951. ;;
  952. esac
  953. case "$plid" in
  954. Darwin/* )
  955. niutil -create . "/users/${usr}"
  956. niutil -createprop . "/users/${usr}" passwd "*"
  957. niutil -createprop . "/users/${usr}" uid "${uid}"
  958. niutil -createprop . "/users/${usr}" gid "${gid}"
  959. niutil -createprop . "/users/${usr}" realname "${realname}"
  960. niutil -createprop . "/users/${usr}" home "${prefix}"
  961. niutil -createprop . "/users/${usr}" shell "${shell}"
  962. ;;
  963. * )
  964. cp $file $file.bak && \
  965. (grep -v '^+:' $file.bak; echo $entry; grep '^+:' $file.bak) >$file
  966. rm -f $file.bak >/dev/null 2>&1
  967. eval $update
  968. ;;
  969. esac
  970. fi
  971. fi
  972. # check whether group already exists
  973. exists=`(getent group; cat /etc/group; ypcat group; nidump group .) 2>/dev/null | grep "^$grp:"`
  974. if [ ".$exists" = . ]; then
  975. if [ ".$cusr" != ".root" ]; then
  976. echo "openpkg:WARNING: skipping creation of OpenPKG $class group $grp" 1>&2
  977. echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  978. else
  979. case "$plid" in
  980. Darwin/* )
  981. niutil -create . "/groups/${grp}"
  982. niutil -createprop . "/groups/${grp}" gid "${gid}"
  983. niutil -createprop . "/groups/${grp}" users "${usr}"
  984. ;;
  985. * )
  986. # add entry to group database
  987. file=/etc/group
  988. entry="${grp}:*:${gid}:${usr}"
  989. cp $file $file.bak && \
  990. (grep -v '^+:' $file.bak; echo $entry; grep '^+:' $file.bak) >$file
  991. rm -f $file.bak >/dev/null 2>&1
  992. ;;
  993. esac
  994. fi
  995. fi
  996. done
  997. # create the startup/shutdown transfer script
  998. name=`echo "$prefix" | sed -e 's;/;;g'`
  999. if [ ".$cusr" != ".root" ]; then
  1000. echo "openpkg:WARNING: skipping creation of system run-command hooks" 1>&2
  1001. echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  1002. else
  1003. case "$plid" in
  1004. FreeBSD/* )
  1005. if [ ! -f /etc/rc.d/${name}.sh ]; then
  1006. # make sure /etc/rc.d exists
  1007. if [ ! -d /etc/rc.d ]; then
  1008. mkdir /etc/rc.d
  1009. fi
  1010. # make sure /etc/rc.d is activated
  1011. ( . /etc/defaults/rc.conf
  1012. . /etc/rc.conf
  1013. found=0
  1014. for p in ${local_startup-x}; do
  1015. if [ ".$p" = "./etc/rc.d" ]; then
  1016. found=1
  1017. break
  1018. fi
  1019. done
  1020. if [ ".$found" = .0 ]; then
  1021. cp -p /etc/rc.conf /etc/rc.conf.bak
  1022. (
  1023. grep -v local_startup /etc/rc.conf.bak
  1024. echo "local_startup=\"/etc/rc.d $local_startup\""
  1025. ) >/etc/rc.conf
  1026. fi
  1027. )
  1028. # install transfer script
  1029. rm -f /etc/rc.d/${name}.sh >/dev/null 2>&1
  1030. ( echo "#!/bin/sh"
  1031. echo "#"
  1032. echo "# ${name}.sh -- startup/shutdown transfer script for ${prefix} OpenPKG hierarchy"
  1033. echo "#"
  1034. echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  1035. echo "case \$1 in"
  1036. echo " start ) exec ${prefix}/etc/rc all start ;;"
  1037. echo " stop ) exec ${prefix}/etc/rc all stop ;;"
  1038. echo "esac"
  1039. ) >/etc/rc.d/${name}.sh
  1040. chmod 755 /etc/rc.d/${name}.sh
  1041. fi
  1042. ;;
  1043. NetBSD/* )
  1044. if [ ! -f /etc/rc.d/${name} ]; then
  1045. ( echo "#!/bin/sh"
  1046. echo "#"
  1047. echo "# ${name} -- startup/shutdown transfer script for ${prefix} OpenPKG hierarchy"
  1048. echo "#"
  1049. echo "# PROVIDE: ${name}"
  1050. echo "# REQUIRE: DAEMON LOGIN NETWORK SERVERS"
  1051. echo "#"
  1052. echo ""
  1053. echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  1054. echo "case \$1 in"
  1055. echo " start ) exec ${prefix}/etc/rc all start ;;"
  1056. echo " stop ) exec ${prefix}/etc/rc all stop ;;"
  1057. echo " restart ) exec ${prefix}/etc/rc all stop start ;;"
  1058. echo " status ) ;;"
  1059. echo "esac"
  1060. ) >/etc/rc.d/${name}
  1061. chmod 755 /etc/rc.d/${name}
  1062. fi
  1063. ;;
  1064. Linux/* )
  1065. # sroot: script root directory
  1066. # lroot: link root directory
  1067. if [ -f /etc/debian_version ]; then
  1068. sroot=/etc/init.d
  1069. lroot=/etc/rc%d.d
  1070. elif [ -f /etc/redhat-release -o -f /etc/mandrake-release ]; then
  1071. sroot=/etc/rc.d/init.d
  1072. lroot=/etc/rc.d/rc%d.d
  1073. else
  1074. echo "WARNING: you are not running one of the supported standard" 1>&2
  1075. echo "WARNING: Linux platforms (Debian, RedHat). We are trying" 1>&2
  1076. echo "WARNING: to guess the location of the system init scripts!" 1>&2
  1077. sroot=""
  1078. lroot=""
  1079. for sr in /etc/rc.d/init.d /etc/init.d /sbin/init.d; do
  1080. if [ -d $sr ]; then
  1081. sroot="$sr"
  1082. break
  1083. fi
  1084. done
  1085. for lr in /etc/rc.d/rc2.d /etc/rc2.d /sbin/init.d/rc2.d; do
  1086. if [ -d $lr ]; then
  1087. lroot="`echo $lr | sed -e 's;2;%d;'`"
  1088. break
  1089. fi
  1090. done
  1091. if [ ".$sroot" = . -o ".$lroot" = . ]; then
  1092. echo "ERROR: Failed to guess the location of the system init scripts!" 1>&2
  1093. exit 1
  1094. fi
  1095. fi
  1096. if [ ! -f $sroot/${name} ]; then
  1097. # install transfer script
  1098. ( echo "#!/bin/sh"
  1099. echo "#"
  1100. echo "# ${name} -- startup/shutdown transfer script for ${prefix} OpenPKG hierarchy"
  1101. echo "#"
  1102. echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  1103. echo "case \$1 in"
  1104. echo " start ) exec ${prefix}/etc/rc all start ;;"
  1105. echo " stop ) exec ${prefix}/etc/rc all stop ;;"
  1106. echo "esac"
  1107. ) >$sroot/${name}
  1108. chmod 755 $sroot/${name}
  1109. # create corresponding symbolic links
  1110. for i in 2 3 4 5; do
  1111. ln -s $sroot/${name} `echo $lroot | sed -e "s;%d;$i;"`/S99${name}
  1112. done
  1113. for i in 0 1 6; do
  1114. ln -s $sroot/${name} `echo $lroot | sed -e "s;%d;$i;"`/K00${name}
  1115. done
  1116. fi
  1117. ;;
  1118. SunOS/5.* )
  1119. if [ ! -f /etc/init.d/${name} ]; then
  1120. # install transfer script
  1121. ( echo "#!/bin/sh"
  1122. echo "#"
  1123. echo "# ${name} -- startup/shutdown transfer script for ${prefix} OpenPKG hierarchy"
  1124. echo "#"
  1125. echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  1126. echo "case \$1 in"
  1127. echo " start ) exec ${prefix}/etc/rc all start ;;"
  1128. echo " stop ) exec ${prefix}/etc/rc all stop ;;"
  1129. echo "esac"
  1130. ) >/etc/init.d/${name}
  1131. chmod 755 /etc/init.d/${name}
  1132. # create corresponding symbolic links
  1133. ( cd /etc
  1134. ln init.d/${name} rc3.d/S99${name}
  1135. ln init.d/${name} rc0.d/K00${name}
  1136. ln init.d/${name} rc1.d/K00${name}
  1137. )
  1138. fi
  1139. ;;
  1140. OSF1/V5.* )
  1141. if [ ! -f /sbin/init.d/${name} ]; then
  1142. # install transfer script
  1143. ( echo "#!/bin/sh"
  1144. echo "#"
  1145. echo "# ${name} -- startup/shutdown transfer script for ${prefix} OpenPKG hierarchy"
  1146. echo "#"
  1147. echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  1148. echo "case \$1 in"
  1149. echo " start ) exec ${prefix}/etc/rc all start ;;"
  1150. echo " stop ) exec ${prefix}/etc/rc all stop ;;"
  1151. echo "esac"
  1152. ) >/sbin/init.d/${name}
  1153. chmod 755 /sbin/init.d/${name}
  1154. # create corresponding symbolic links
  1155. ( cd /sbin
  1156. ln -s ../init.d/${name} rc3.d/S99${name}
  1157. ln -s ../init.d/${name} rc0.d/K00${name}
  1158. )
  1159. fi
  1160. ;;
  1161. HP-UX/* )
  1162. if [ ! -f /sbin/init.d/${name} ]; then
  1163. # install transfer script
  1164. ( echo "#!/bin/sh"
  1165. echo "#"
  1166. echo "# ${name} -- startup/shutdown transfer script for ${prefix} OpenPKG hierarchy"
  1167. echo "#"
  1168. echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  1169. echo "case \$1 in"
  1170. echo " start ) exec ${prefix}/etc/rc all start ;;"
  1171. echo " stop ) exec ${prefix}/etc/rc all stop ;;"
  1172. echo "esac"
  1173. ) >/sbin/init.d/${name}
  1174. chmod 755 /sbin/init.d/${name}
  1175. # create corresponding symbolic links
  1176. ( cd /sbin
  1177. ln -s ../init.d/${name} rc2.d/S900${name}
  1178. ln -s ../init.d/${name} rc1.d/K100${name}
  1179. )
  1180. fi
  1181. ;;
  1182. Darwin/* )
  1183. darwin_rc_dir="/System/Library/StartupItems/${name}"
  1184. if [ ! -d ${darwin_rc_dir} ]; then
  1185. mkdir ${darwin_rc_dir}
  1186. fi
  1187. # make sure hierarchy is activated in /etc/hostconfig
  1188. # FIXME: cs: simple and bad code here without any detection of existing entries
  1189. echo "OPENPKG_${name}=-YES-" >>/etc/hostconfig
  1190. # install transfer script
  1191. if [ ! -f ${darwin_rc_dir}/${name} ]; then
  1192. rm -f ${darwin_rc_dir}/${name} >/dev/null 2>&1
  1193. ( echo "#!/bin/sh"
  1194. echo "#"
  1195. echo "# /System/Library/StartupItems/${name}/${name}"
  1196. echo "# -- startup transfer script for OpenPKG ${prefix} hierarchy"
  1197. echo "#"
  1198. echo ""
  1199. echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  1200. echo ""
  1201. echo ". /etc/rc.common"
  1202. echo ""
  1203. echo "if [ \"\${OPENPKG_${name}:=-NO-}\" = \"-YES-\" ]; then"
  1204. echo " ConsoleMessage \"OpenPKG ${prefix} hierarchy\""
  1205. echo " ${prefix}/etc/rc all start"
  1206. echo "fi"
  1207. ) >${darwin_rc_dir}/${name}
  1208. chmod 755 ${darwin_rc_dir}/${name}
  1209. fi
  1210. # install startup parameter list
  1211. if [ ! -f ${darwin_rc_dir}/StartupParameters.plist ]; then
  1212. rm -f ${darwin_rc_dir}/StartupParameters.plist >/dev/null 2>&1
  1213. (
  1214. echo "{"
  1215. echo " Description = \"OpenPKG ${prefix} hierarchy\";"
  1216. echo " Provides = (\"OpenPKG ${prefix}\");"
  1217. echo " Requires = (\"Disks\", \"Network Configuration\", \"Resolver\");"
  1218. echo " Uses = (\"Cron\");"
  1219. echo " OrderPreference = \"Last\";"
  1220. echo " Messages ="
  1221. echo " {"
  1222. echo " start = \"Starting OpenPKG ${prefix} hierarchy\";"
  1223. echo " stop = \"Stopping OpenPKG ${prefix} hierarchy\";"
  1224. echo " };"
  1225. echo "}"
  1226. ) >${darwin_rc_dir}/StartupParameters.plist
  1227. chmod 644 ${darwin_rc_dir}/StartupParameters.plist
  1228. fi
  1229. ;;
  1230. esac
  1231. fi
  1232. # create the cron transfer entries
  1233. if [ ".$cusr" != ".root" ]; then
  1234. echo "openpkg:WARNING: skipping creation of system cron hooks" 1>&2
  1235. echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  1236. else
  1237. case "$plid" in
  1238. FreeBSD/* | Linux/* | Darwin/* )
  1239. exists=`grep "$prefix/etc/rc" /etc/crontab`
  1240. if [ ".$exists" = . ]; then
  1241. ( echo "# <OpenPKG prefix=$prefix pkg=openpkg>"
  1242. echo "# chronological tasks of ${prefix} OpenPKG hierarchy"
  1243. echo "0 0 1 * * root [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all monthly"
  1244. echo "0 0 * * 0 root [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all weekly"
  1245. echo "0 0 * * * root [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all daily"
  1246. echo "0 * * * * root [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all hourly"
  1247. echo "*/15 * * * * root [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all quarterly"
  1248. echo "# </OpenPKG>"
  1249. ) >>/etc/crontab
  1250. fi
  1251. ;;
  1252. SunOS/5.* | OSF1/V5.* | NetBSD/* | HP-UX/* )
  1253. exists=`crontab -l | grep "$prefix/etc/rc"`
  1254. if [ ".$exists" = . ]; then
  1255. EDITOR=/tmp/vipw.$$
  1256. VISUAL="$EDITOR"
  1257. export EDITOR
  1258. export VISUAL
  1259. ( echo "#!/bin/sh"
  1260. echo "( echo \"# <OpenPKG prefix=$prefix pkg=openpkg>\""
  1261. echo " echo \"# chronological tasks of ${prefix} OpenPKG hierarchy\""
  1262. echo " echo \"0 0 1 * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all monthly\""
  1263. echo " echo \"0 0 * * 0 [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all weekly\""
  1264. echo " echo \"0 0 * * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all daily\""
  1265. echo " echo \"0 * * * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all hourly\""
  1266. echo " echo \"0,15,30,45 * * * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all quarterly\""
  1267. echo " echo \"# </OpenPKG>\""
  1268. echo ") >>\$1"
  1269. ) >$EDITOR
  1270. chmod a+x $EDITOR
  1271. (PATH="$PATH:/usr/bin"; crontab -e)
  1272. rm -f $EDITOR
  1273. fi
  1274. ;;
  1275. esac
  1276. fi
  1277. %post
  1278. # Finally, rebuild the RPM database with the newly installed RPM
  1279. # program on upgrades. Because of RPM internal database locking we
  1280. # have to play a little trick here and delay the operation until RPM
  1281. # thinks this "post" script has already terminated.
  1282. if [ ".$1" = .2 ]; then
  1283. ( sleep 2
  1284. %{l_prefix}/bin/rpm --rebuilddb
  1285. chown %{l_musr}:%{l_mgrp} %{l_prefix}/RPM/DB/* || true
  1286. ) </dev/null >/dev/null 2>/dev/null &
  1287. fi
  1288. %preun
  1289. [ ".$1" != .0 ] && exit 0
  1290. # remove files which are not RPM controlled
  1291. rm -rf %{l_prefix}/RPM/TMP/* %{l_prefix}/RPM/TMP/.[a-z]* >/dev/null 2>&1 || true
  1292. rm -rf %{l_prefix}/RPM/SRC/* %{l_prefix}/RPM/SRC/.[a-z]* >/dev/null 2>&1 || true
  1293. rm -rf %{l_prefix}/RPM/PKG/* %{l_prefix}/RPM/PKG/.[a-z]* >/dev/null 2>&1 || true
  1294. rm -rf %{l_prefix}/RPM/DB/* %{l_prefix}/RPM/DB/.[a-z]* >/dev/null 2>&1 || true
  1295. # The following code usually would be done in a %postun section.
  1296. # But because we already had to remove the database in this %preun
  1297. # section (see the 'rm' commands above) in order to make RPM happy
  1298. # inside its own removal procedure, RPM would no longer find the
  1299. # %postun script (because it's recorded in the database files). So
  1300. # we have to perform the procedure already in this %preun script.
  1301. # except for the removal of the top-level directory it does not
  1302. # matter. But the top-level directory can only be removed after
  1303. # the RPM removal procedure took place, so we play a little delay
  1304. # trick below.
  1305. # determine current user
  1306. cusr=`(id -un) 2>/dev/null ||\
  1307. (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
  1308. (whoami) 2>/dev/null ||\
  1309. (who am i | cut "-d " -f1) 2>/dev/null ||\
  1310. echo $LOGNAME`
  1311. # determine runtime details (for both inside and outside RPM!!)
  1312. user="%{l_musr}"
  1313. group="%{l_mgrp}"
  1314. prefix="%{l_prefix}"
  1315. prefix=`echo "$prefix" | sed -e 's;//*;/;g' -e 's;/$;;'`
  1316. # determine platform id
  1317. s=`(uname -s) 2>/dev/null` || s='Unknown'
  1318. r=`(uname -r) 2>/dev/null` || r='0.0'
  1319. plid="${s}/${r}"
  1320. # remove entry in /etc/shells
  1321. shell="${prefix}/lib/openpkg/bash"
  1322. exists=`cat /etc/shells 2>/dev/null | grep "^$shell"`
  1323. if [ ".$exists" != . ]; then
  1324. if [ ".$cusr" != ".root" ]; then
  1325. echo "openpkg:WARNING: skipping deletion of $shell from /etc/shells" 1>&2
  1326. echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  1327. else
  1328. cp /etc/shells /etc/shells.bak && \
  1329. grep -v "^${shell}" /etc/shells.bak >/etc/shells
  1330. fi
  1331. fi
  1332. # remove the hierarchy user/group
  1333. for req in "super-user:%{l_susr}:%{l_suid}:%{l_sgrp}:%{l_sgid}" \
  1334. "management:%{l_musr}:%{l_muid}:%{l_mgrp}:%{l_mgid}" \
  1335. "restricted:%{l_rusr}:%{l_ruid}:%{l_rgrp}:%{l_rgid}" \
  1336. "non-privileged:%{l_nusr}:%{l_nuid}:%{l_ngrp}:%{l_ngid}"; do
  1337. # split request into class/usr/uid/grp/gid
  1338. OIFS="$IFS"; IFS=":"; set -- $req; IFS="$OIFS"
  1339. class="$1"; usr="$2"; uid="$3"; grp="$4"; gid="$5"
  1340. # check whether user already exists
  1341. exists=`(getent passwd; cat /etc/passwd; ypcat passwd; nidump passwd .) 2>/dev/null | grep "^$usr:"`
  1342. if [ ".$exists" != . ]; then
  1343. if [ ".$cusr" != ".root" ]; then
  1344. echo "openpkg:WARNING: skipping deletion of OpenPKG $class user $usr" 1>&2
  1345. echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  1346. elif [ ".$usr" = ".root" ]; then
  1347. echo "openpkg:WARNING: skipping deletion of OpenPKG $class user $usr" 1>&2
  1348. echo "openpkg:WARNING: (would remove system standard user)" 1>&2
  1349. else
  1350. case "$plid" in
  1351. FreeBSD/* | NetBSD/* )
  1352. cp /etc/master.passwd /etc/master.passwd.bak && \
  1353. grep -v "^${usr}:" /etc/master.passwd.bak >/etc/master.passwd
  1354. (PATH="$PATH:/usr/sbin"; pwd_mkdb -p /etc/master.passwd)
  1355. ;;
  1356. Linux/* | SunOS/5.* )
  1357. cp /etc/passwd /etc/passwd.bak && \
  1358. grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
  1359. (PATH="$PATH:/usr/sbin"; pwconv)
  1360. ;;
  1361. OSF1/V5.* )
  1362. cp /etc/passwd /etc/passwd.bak && \
  1363. grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
  1364. (PATH="$PATH:/usr/sbin"; mkpasswd /etc/passwd)
  1365. ;;
  1366. HP-UX/* )
  1367. cp /etc/passwd /etc/passwd.bak && \
  1368. grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
  1369. ;;
  1370. Darwin/* )
  1371. niutil -destroy . "/users/${usr}"
  1372. ;;
  1373. esac
  1374. fi
  1375. fi
  1376. # check whether group already exists
  1377. exists=`(getent group; cat /etc/group; ypcat group; nidump group .) 2>/dev/null | grep "^$grp:"`
  1378. if [ ".$exists" != . ]; then
  1379. if [ ".$cusr" != ".root" ]; then
  1380. echo "openpkg:WARNING: skipping deletion of OpenPKG $class group $grp" 1>&2
  1381. echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  1382. elif [ ".$usr" = ".root" ] || [ ".$grp" = ".root" ] || [ ".$grp" = ".wheel" ]; then
  1383. echo "openpkg:WARNING: skipping deletion of OpenPKG $class group $grp" 1>&2
  1384. echo "openpkg:WARNING: (would remove system standard group)" 1>&2
  1385. else
  1386. case "$plid" in
  1387. Darwin/* )
  1388. niutil -destroy . "/groups/${grp}"
  1389. ;;
  1390. * )
  1391. cp /etc/group /etc/group.bak && \
  1392. grep -v "^${grp}:" /etc/group.bak >/etc/group
  1393. ;;
  1394. esac
  1395. fi
  1396. fi
  1397. done
  1398. # remove the startup/shutdown transfer ripts
  1399. name=`echo "$prefix" | sed -e 's;/;;g'`
  1400. if [ ".$cusr" != ".root" ]; then
  1401. echo "openpkg:WARNING: skipping deletion of system run-command hooks" 1>&2
  1402. echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  1403. else
  1404. case "$plid" in
  1405. FreeBSD/* )
  1406. rm -f /etc/rc.d/${name}.sh >/dev/null 2>&1
  1407. ;;
  1408. NetBSD/* )
  1409. rm -f /etc/rc.d/${name} >/dev/null 2>&1
  1410. ;;
  1411. Linux/* )
  1412. # sroot: script root directory
  1413. # lroot: link root directory
  1414. if [ -f /etc/debian_version ]; then
  1415. sroot=/etc/init.d
  1416. lroot=/etc/rc%d.d
  1417. elif [ -f /etc/redhat-release -o -f /etc/mandrake-release ]; then
  1418. sroot=/etc/rc.d/init.d
  1419. lroot=/etc/rc.d/rc%d.d
  1420. else
  1421. echo "WARNING: you are not running one of the supported standard" 1>&2
  1422. echo "WARNING: Linux platforms (Debian, RedHat). We are trying" 1>&2
  1423. echo "WARNING: to guess the location of the system init scripts!" 1>&2
  1424. sroot=""
  1425. lroot=""
  1426. for sr in /etc/rc.d/init.d /etc/init.d /sbin/init.d; do
  1427. if [ -d $sr ]; then
  1428. sroot="$sr"
  1429. break
  1430. fi
  1431. done
  1432. for lr in /etc/rc.d/rc2.d /etc/rc2.d /sbin/init.d/rc2.d; do
  1433. if [ -d $lr ]; then
  1434. lroot="`echo $lr | sed -e 's;2;%d;'`"
  1435. break
  1436. fi
  1437. done
  1438. if [ ".$sroot" = . -o ".$lroot" = . ]; then
  1439. echo "ERROR: Failed to guess the location of the system init scripts!" 1>&2
  1440. exit 1
  1441. fi
  1442. fi
  1443. rm -f ${sroot}/${name} >/dev/null 2>&1
  1444. for i in 2 3 4 5; do
  1445. rm -f `echo $lroot | sed -e "s;%d;$i;"`/S99${name} >/dev/null 2>&1
  1446. done
  1447. for i in 0 1 6; do
  1448. rm -f `echo $lroot | sed -e "s;%d;$i;"`/K00${name} >/dev/null 2>&1
  1449. done
  1450. ;;
  1451. SunOS/5.* )
  1452. rm -f /etc/init.d/${name} >/dev/null 2>&1
  1453. rm -f /etc/rc3.d/S99${name} >/dev/null 2>&1
  1454. rm -f /etc/rc0.d/K00${name} >/dev/null 2>&1
  1455. rm -f /etc/rc1.d/K00${name} >/dev/null 2>&1
  1456. ;;
  1457. OSF1/V5.* )
  1458. rm -f /sbin/init.d/${name} >/dev/null 2>&1
  1459. rm -f /sbin/rc3.d/S99${name} >/dev/null 2>&1
  1460. rm -f /sbin/rc0.d/K00${name} >/dev/null 2>&1
  1461. ;;
  1462. HP-UX/* )
  1463. rm -f /sbin/init.d/${name} >/dev/null 2>&1
  1464. rm -f /etc/rc2.d/S900${name} >/dev/null 2>&1
  1465. rm -f /etc/rc1.d/K100${name} >/dev/null 2>&1
  1466. ;;
  1467. Darwin/* )
  1468. cp /etc/hostconfig /etc/hostconfig.bak && \
  1469. grep -v "^OPENPKG_${name}=" /etc/hostconfig.bak >/etc/hostconfig
  1470. rm -rf /System/Library/StartupItems/${name} >/dev/null 2>&1
  1471. ;;
  1472. esac
  1473. fi
  1474. # remove the cron transfer entries
  1475. if [ ".$cusr" != ".root" ]; then
  1476. echo "openpkg:WARNING: skipping deletion of system cron hooks" 1>&2
  1477. echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  1478. else
  1479. case "$plid" in
  1480. FreeBSD/* | Linux/* | Darwin/* )
  1481. exists=`grep "<OpenPKG prefix=$prefix pkg=openpkg>" /etc/crontab`
  1482. if [ ".$exists" != . ]; then
  1483. p=`echo $prefix | sed -e 's;/;\\\\/;g'`
  1484. cp /etc/crontab /etc/crontab.bak
  1485. cat /etc/crontab.bak |\
  1486. sed -e "/<OpenPKG prefix=$p pkg=openpkg>/,/<\\/OpenPKG>/d" \
  1487. >/etc/crontab
  1488. fi
  1489. ;;
  1490. SunOS/5.* | OSF1/V5.* | NetBSD/* | HP-UX/* )
  1491. EDITOR=/tmp/vipw.$$
  1492. VISUAL="$EDITOR"
  1493. export EDITOR
  1494. export VISUAL
  1495. p=`echo $prefix | sed -e 's;/;\\\\\\\\/;g'`
  1496. ( echo "cp \$1 \$1.bak"
  1497. echo "cat \$1.bak | sed -e \"/<OpenPKG prefix=$p pkg=openpkg>/,/<\\\\/OpenPKG>/d\" >\$1"
  1498. echo "rm -f \$1.bak"
  1499. ) >$EDITOR
  1500. chmod a+x $EDITOR
  1501. (PATH="$PATH:/usr/bin"; crontab -e)
  1502. rm -f $EDITOR
  1503. ;;
  1504. esac
  1505. fi
  1506. # delayed removal of top-level directory.
  1507. ( sleep 10
  1508. rmdir %{l_prefix} >/dev/null 2>&1 || true
  1509. ) </dev/null >/dev/null 2>/dev/null &