openpkg.spec 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452
  1. ##
  2. ## openpkg.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2002 Cable & Wireless Deutschland GmbH
  4. ## Copyright (c) 2000-2002 The OpenPKG Project <http://www.openpkg.org/>
  5. ## Copyright (c) 2000-2002 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 and release
  39. %define V_openpkg 20020909
  40. %define R_openpkg 20020909
  41. # the used software versions
  42. %define V_rpm 4.0.2
  43. %define V_zlib 1.1.4
  44. %define V_bzip2 1.0.2
  45. %define V_db 3.2.9
  46. %define V_curl 7.9.8
  47. %define V_make 3.79.1
  48. %define V_gzip 1.3.3
  49. %define V_patch 2.5.4
  50. %define V_tar 1.13.25
  51. %define V_bash 2.05b
  52. # package information
  53. Name: openpkg
  54. Summary: OpenPKG Bootstrap
  55. URL: http://www.openpkg.org/
  56. Vendor: OpenPKG
  57. Packager: The OpenPKG Project
  58. Distribution: OpenPKG [CORE]
  59. Group: Bootstrapping
  60. License: GPL
  61. Version: %{V_openpkg}
  62. Release: %{R_openpkg}
  63. # list of sources
  64. Source0: README
  65. Source1: openpkg.boot
  66. Source2: ftp://ftp.rpm.org/pub/rpm/dist/rpm-%{V_rpm}.x/rpm-%{V_rpm}.tar.gz
  67. Source3: rpm.patch.bugfix
  68. Source4: rpm.patch.feature
  69. Source5: rpm.patch.porting
  70. Source6: rpm.patch.regen
  71. Source7: http://www.sleepycat.com/update/%{V_db}/db-%{V_db}.tar.gz
  72. Source8: ftp://sources.redhat.com/pub/bzip2/v102/bzip2-%{V_bzip2}.tar.gz
  73. Source9: ftp://ftp.info-zip.org/pub/infozip/zlib/zlib-%{V_zlib}.tar.gz
  74. Source10: http://curl.haxx.se/download/curl-%{V_curl}.tar.gz
  75. Source11: rpmpopt
  76. Source12: rpmrc
  77. Source13: rpmmacros
  78. Source14: root.README
  79. Source15: local.README
  80. Source16: rc
  81. Source17: rc.func
  82. Source18: rpmtool
  83. Source19: rpmtool.8
  84. Source20: rpmtool.pod
  85. Source21: lsync
  86. Source22: lsync.8
  87. Source23: lsync.pod
  88. Source24: aux.wrapsrc.sh
  89. Source25: aux.wrapbin.sh
  90. Source26: openpkg.pgp
  91. Source27: shtool
  92. Source28: rpmx.sh
  93. Source29: rpmx.pl
  94. Source30: ftp://ftp.gnu.org/gnu/make/make-%{V_make}.tar.gz
  95. Source31: ftp://alpha.gnu.org/gnu/gzip/gzip-%{V_gzip}.tar
  96. Source32: ftp://ftp.gnu.org/gnu/patch/patch-%{V_patch}.tar.gz
  97. Source33: rc.openpkg
  98. Source34: ftp://ftp.gnu.org/gnu/tar/tar-%{V_tar}.tar.gz
  99. Source35: ftp://ftp.gnu.org/gnu/bash/bash-%{V_bash}.tar.gz
  100. Source36: dot.bashrc
  101. Source37: dot.bash_login
  102. Source38: dot.lsyncrc
  103. Source39: db.patch
  104. Source40: rc.conf
  105. Source41: aux.prereq.sh
  106. Source42: aux.usrgrp.sh
  107. Source43: mkproxyrpm.pl
  108. Source44: ftp://ftp.gnu.org/gnu/config/config.guess
  109. Source45: ftp://ftp.gnu.org/gnu/config/config.sub
  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. # compat:
  205. usr=""; [ ".%{?l_fsusr:set}" = .set ] && usr="%{l_fsusr}"
  206. grp=""; [ ".%{?l_fsgrp:set}" = .set ] && grp="%{l_fsgrp}"
  207. eval `sh $usrgrp \
  208. --usr="$usr" --grp="$grp" \
  209. --susr="$susr" --sgrp="$sgrp" \
  210. --musr="$musr" --mgrp="$mgrp" \
  211. --rusr="$rusr" --rgrp="$rgrp" \
  212. --nusr="$nusr" --ngrp="$ngrp"`
  213. echo "susr=\"$susr\"; export susr" >>.buildenv
  214. echo "sgrp=\"$sgrp\"; export sgrp" >>.buildenv
  215. echo "musr=\"$musr\"; export musr" >>.buildenv
  216. echo "mgrp=\"$mgrp\"; export mgrp" >>.buildenv
  217. echo "rusr=\"$rusr\"; export rusr" >>.buildenv
  218. echo "rgrp=\"$rgrp\"; export rgrp" >>.buildenv
  219. echo "nusr=\"$nusr\"; export nusr" >>.buildenv
  220. echo "ngrp=\"$ngrp\"; export ngrp" >>.buildenv
  221. # determine installation location id
  222. if [ ".%{?l_location:set}" = .set ]; then
  223. loc="%{l_location}"
  224. else
  225. if [ ".`expr %{l_prefix} : '/[^/][^/]*$'`" != .0 ]; then
  226. loc=`echo %{l_prefix} | cut -c2-4`
  227. else
  228. loc=`echo %{l_prefix} | sed -e 's;/\(.\)[^/]*;\1;g' | cut -c1-3`
  229. fi
  230. fi
  231. echo "loc=\"$loc\"; export loc" >>.buildenv
  232. # determine platform id
  233. s=`(uname -s) 2>/dev/null` || s='Unknown'
  234. r=`(uname -r) 2>/dev/null` || r='0.0'
  235. plid="${s}/${r}"
  236. # determine platform-specific build environment
  237. case $plid in
  238. FreeBSD/* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
  239. Linux/* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
  240. SunOS/* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin:/usr/ccs/bin" ;;
  241. * ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
  242. esac
  243. case $plid in
  244. FreeBSD/* ) l_build_ldlp="/usr/lib" ;;
  245. Linux/* ) l_build_ldlp="/lib:/usr/lib" ;;
  246. SunOS/* ) l_build_ldlp="/usr/lib:/usr/ccs/lib" ;;
  247. * ) l_build_ldlp="/usr/lib" ;;
  248. esac
  249. case $plid in
  250. FreeBSD/4* ) l_build_ulim="ulimit -H -S -f 262144 -d 262144 -m 262144 -s 65536 -u 128" ;;
  251. Linux/2* ) l_build_ulim="ulimit -H -S -f 262144 -d 262144 -m 262144 -v 262144 -s 65536 -u 128" ;;
  252. SunOS/5.8* ) l_build_ulim="ulimit -H -S -f 262144 -d 262144 -s 65536" ;;
  253. * ) l_build_ulim=":" ;;
  254. esac
  255. echo "l_build_path=\"$l_build_path\"; export l_build_path" >>.buildenv
  256. echo "l_build_ldlp=\"$l_build_ldlp\"; export l_build_ldlp" >>.buildenv
  257. echo "l_build_ulim=\"$l_build_ulim\"; export l_build_ulim" >>.buildenv
  258. # bootstrap GNU zip tool
  259. ${l_tar} xf `SOURCE gzip-%{V_gzip}.tar` 2>/dev/null
  260. ( cd gzip-%{V_gzip}
  261. CC="${l_cc}" ./configure
  262. ${l_make}
  263. )
  264. l_gzip="`pwd`/gzip-%{V_gzip}/gzip"; export l_gzip
  265. echo "l_gzip=\"$l_gzip\"; export l_gzip" >>.buildenv
  266. # unpack distribution tarballs
  267. ${l_gzip} -dc `SOURCE rpm-%{V_rpm}.tar.gz` | ${l_tar} xf -
  268. ${l_gzip} -dc `SOURCE zlib-%{V_zlib}.tar.gz` | ${l_tar} xf -
  269. ${l_gzip} -dc `SOURCE bzip2-%{V_bzip2}.tar.gz` | ${l_tar} xf -
  270. ${l_gzip} -dc `SOURCE db-%{V_db}.tar.gz` | ${l_tar} xf -
  271. ${l_gzip} -dc `SOURCE curl-%{V_curl}.tar.gz` | ${l_tar} xf -
  272. ${l_gzip} -dc `SOURCE make-%{V_make}.tar.gz` | ${l_tar} xf -
  273. ${l_gzip} -dc `SOURCE patch-%{V_patch}.tar.gz` | ${l_tar} xf -
  274. ${l_gzip} -dc `SOURCE tar-%{V_tar}.tar.gz` | ${l_tar} xf -
  275. ${l_gzip} -dc `SOURCE bash-%{V_bash}.tar.gz` | ${l_tar} xf -
  276. # update config.guess/config.sub
  277. for dir in rpm-%{V_rpm} rpm-%{V_rpm}/popt db-%{V_db}/dist \
  278. curl-%{V_curl} make-%{V_make} patch-%{V_patch} tar-%{V_tar} bash-%{V_bash}/support; do
  279. chmod u+w $dir/config.guess $dir/config.sub >/dev/null 2>&1 || true
  280. cp `SOURCE config.guess` $dir/
  281. cp `SOURCE config.sub` $dir/
  282. done
  283. # bootstrap GNU make tool
  284. ( cd make-%{V_make}
  285. CC="${l_cc}" ./configure --disable-nls --disable-largefile
  286. ${l_make}
  287. (mv make ..; ${l_make} clean || true; mv ../make .)
  288. )
  289. l_make="`pwd`/make-%{V_make}/make"; export l_make
  290. echo "l_make=\"$l_make\"; export l_make" >>.buildenv
  291. # bootstrap GNU patch tool
  292. ( cd patch-%{V_patch}
  293. echo 'ac_cv_func_setmode=${ac_cv_func_setmode=no}' >config.cache
  294. false=`sh $shtool path false`
  295. echo "ac_cv_path_ed_PROGRAM=\${ac_cv_path_ed_PROGRAM=$false}" >>config.cache
  296. CC="${l_cc}" ./configure --disable-largefile
  297. ${l_make}
  298. (mv patch ..; ${l_make} clean || true; mv ../patch .)
  299. )
  300. l_patch="`pwd`/patch-%{V_patch}/patch"; export l_patch
  301. echo "l_patch=\"$l_patch\"; export l_patch" >>.buildenv
  302. # apply OpenPKG patches to RPM distribution tree
  303. ( cd rpm-%{V_rpm}
  304. ${l_patch} -p0 <`SOURCE rpm.patch.bugfix`
  305. ${l_patch} -p0 <`SOURCE rpm.patch.feature`
  306. ${l_patch} -p0 <`SOURCE rpm.patch.porting`
  307. ${l_patch} -p0 <`SOURCE rpm.patch.regen`
  308. touch aclocal.m4 configure
  309. )
  310. # apply OpenPKG patches to DB distribution tree
  311. ( cd db-%{V_db}
  312. ${l_patch} -p0 <`SOURCE db.patch`
  313. )
  314. %build
  315. # skip in bootstrap phase 2 (see openpkg.boot)
  316. [ ".$OPENPKG_BOOT" = .1 ] && exit 0
  317. # switch into a temporary build area
  318. cd %{name}-%{version}
  319. . ./.buildenv
  320. # build GNU bash tool
  321. ( cd bash-%{V_bash}
  322. CC="${l_cc}"
  323. ./configure \
  324. --prefix=%{l_prefix} \
  325. --without-curses \
  326. --without-gnu-malloc \
  327. --disable-nls
  328. ${l_make} || exit $?
  329. (mv bash ..; ${l_make} clean || true; mv ../bash .)
  330. )
  331. # build GNU tar tool
  332. ( cd tar-%{V_tar}
  333. echo 'am_cv_func_iconv=${am_cv_func_iconv=no}' >config.cache
  334. echo 'am_cv_lib_iconv=${am_cv_lib_iconv=no}' >config.cache
  335. echo 'am_cv_func_iconv=${am_cv_func_iconv=no}' >config.cache
  336. CC="${l_cc}"
  337. ../bash-%{V_bash}/bash \
  338. ./configure \
  339. --config-cache \
  340. --prefix=%{l_prefix} \
  341. --disable-nls
  342. ${l_make} || exit $?
  343. (mv src/tar ..; ${l_make} clean || true; mv ../tar src/)
  344. )
  345. # build cURL tool
  346. ( cd curl-%{V_curl}
  347. CC="${l_cc}" \
  348. ./configure \
  349. --without-ssl \
  350. --disable-shared \
  351. --disable-thread \
  352. --disable-ipv6
  353. ${l_make} || exit $?
  354. (mv src/curl ..; ${l_make} clean || true; mv ../curl ./src)
  355. )
  356. # build BZIP2 library
  357. ( cd bzip2-%{V_bzip2}
  358. ${l_make} CC="${l_cc}" CFLAGS="-O" libbz2.a bzip2 || exit $?
  359. )
  360. # build ZLIB library
  361. ( cd zlib-%{V_zlib}
  362. CC="${l_cc}" CFLAGS="-O" ./configure
  363. ${l_make} CC="${l_cc}" CFLAGS="-O" libz.a || exit $?
  364. )
  365. # build Berkeley-DB library
  366. ( cd db-%{V_db}/build_unix
  367. case `sh ../dist/config.guess` in
  368. *-*-osf* ) echo 'db_cv_mutex=${db_cv_mutex=UNIX/msem_init}' >config.cache ;; # avoid dependency to pthread
  369. esac
  370. CC="${l_cc}" ../dist/configure
  371. ${l_make} libdb.a || exit $?
  372. ln libdb.a libdbXXX.a # workaround for Tru64
  373. )
  374. # build RPM
  375. # - we make sure RPM builds without NLS/gettext problems :-(
  376. # - we make sure RPM finds and uses our own BZIP2/ZLIB/DB libraries
  377. # - we speed up building by skipping the NLS/gettext data
  378. ( br=`pwd`
  379. cd rpm-%{V_rpm}
  380. sed -e 's;(aclocal --version);false;' \
  381. -e 's;(automake --version);false;' \
  382. -e 's;(autoconf --version);false;' \
  383. -e 's;(autoheader --version);false;' \
  384. -e 's;(makeinfo --version);false;' \
  385. -e 's;/lib/rpm;/lib/openpkg;' \
  386. <configure >configure.n && \
  387. mv configure.n configure
  388. sed -e 's;@INTLLIBS@;@INTLLIBS@ @LIBMISC@;' \
  389. <tools/Makefile.in >tools/Makefile.in.n && \
  390. mv tools/Makefile.in.n tools/Makefile.in
  391. sed -e 's;^\(SUBDIRS[ ]*=.*\) po \(.*\)$;\1 \2;' \
  392. -e 's;^\(SUBDIRS[ ]*=.*\) tools \(.*\)$;\1 \2;' \
  393. -e 's;^\(LIBS[ ]*=\).*;\1 @LIBS@ $(EXTRA_LIBS);' \
  394. <Makefile.in >Makefile.in.n && mv Makefile.in.n Makefile.in
  395. sed -e 's;^\(SUBDIRS[ ]*=.*\) po$;\1;' \
  396. <popt/Makefile.in >popt/Makefile.in.n && \
  397. mv popt/Makefile.in.n popt/Makefile.in
  398. sed -e 's;BUFSIZ;8192;g' \
  399. <rpmio/macro.c >rpmio/macro.c.n && \
  400. mv rpmio/macro.c.n rpmio/macro.c
  401. ( echo 'ac_cv_path_MSGFMT=${ac_cv_path_MSGFMT=no}'
  402. echo 'ac_cv_path_GMSGFMT=${ac_cv_path_GMSGFMT=no}'
  403. ) >config.cache
  404. case `sh ./config.guess` in
  405. *-*-linux* ) nlsopt="--disable-nls" ;;
  406. * ) nlsopt="--enable-nls --with-included-gettext" ;;
  407. esac
  408. nlsopt="--disable-nls"
  409. CC="${l_cc} -DOPENPKG -I$br/db-%{V_db}/build_unix -I$br/zlib-%{V_zlib} -I$br/bzip2-%{V_bzip2}" \
  410. CFLAGS="-DOPENPKG -I$br/db-%{V_db}/build_unix -I$br/zlib-%{V_zlib} -I$br/bzip2-%{V_bzip2}" \
  411. CPPFLAGS="-DOPENPKG -I$br/db-%{V_db}/build_unix -I$br/zlib-%{V_zlib} -I$br/bzip2-%{V_bzip2}" \
  412. LDFLAGS="-L$br/db-%{V_db}/build_unix -L$br/zlib-%{V_zlib} -L$br/bzip2-%{V_bzip2}" \
  413. LIBS="-L$br/db-%{V_db}/build_unix -ldbXXX -L$br/zlib-%{V_zlib} -lz -L$br/bzip2-%{V_bzip2} -lbz2" \
  414. sh ./configure \
  415. --prefix=%{l_prefix} \
  416. --disable-shared \
  417. --disable-db1 \
  418. --with-glob \
  419. $nlsopt
  420. ${l_make} \
  421. EXTRA_LIBS="-L$br/db-%{V_db}/build_unix -ldbXXX -L$br/zlib-%{V_zlib} -lz -L$br/bzip2-%{V_bzip2} -lbz2"
  422. )
  423. %install
  424. # skip in bootstrap phase 2 (see openpkg.boot)
  425. [ ".$OPENPKG_BOOT" = .1 ] && exit 0
  426. # switch into a temporary build area
  427. cd %{name}-%{version}
  428. . ./.buildenv
  429. # create installation hierarchy
  430. rm -rf $RPM_BUILD_ROOT
  431. sh $shtool mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}
  432. for dir in bin etc include info lib libexec man sbin share var cgi pub local; do
  433. test -d $RPM_BUILD_ROOT%{l_prefix}/$dir || \
  434. mkdir $RPM_BUILD_ROOT%{l_prefix}/$dir
  435. done
  436. for i in 1 2 3 4 5 6 7 8 9; do
  437. test -d $RPM_BUILD_ROOT%{l_prefix}/man/man$i || \
  438. mkdir $RPM_BUILD_ROOT%{l_prefix}/man/man$i
  439. test -d $RPM_BUILD_ROOT%{l_prefix}/man/cat$i || \
  440. mkdir $RPM_BUILD_ROOT%{l_prefix}/man/cat$i
  441. done
  442. for dir in PKG bin etc include info lib man sbin; do
  443. test -d $RPM_BUILD_ROOT%{l_prefix}/local/$dir || \
  444. mkdir $RPM_BUILD_ROOT%{l_prefix}/local/$dir
  445. done
  446. for i in 1 2 3 4 5 6 7 8 9; do
  447. test -d $RPM_BUILD_ROOT%{l_prefix}/local/man/man$i || \
  448. mkdir $RPM_BUILD_ROOT%{l_prefix}/local/man/man$i
  449. test -d $RPM_BUILD_ROOT%{l_prefix}/local/man/cat$i || \
  450. mkdir $RPM_BUILD_ROOT%{l_prefix}/local/man/cat$i
  451. done
  452. test -d $RPM_BUILD_ROOT%{l_prefix}/RPM || \
  453. mkdir $RPM_BUILD_ROOT%{l_prefix}/RPM
  454. for dir in SRC PKG DB TMP; do
  455. test -d $RPM_BUILD_ROOT%{l_prefix}/RPM/$dir || \
  456. mkdir $RPM_BUILD_ROOT%{l_prefix}/RPM/$dir
  457. done
  458. # install RPM into installation hierarchy
  459. ( cd rpm-%{V_rpm}
  460. ${l_make} DESTDIR="$RPM_BUILD_ROOT" install
  461. )
  462. # strip RPM installation
  463. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* \
  464. $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/* >/dev/null 2>&1 || true
  465. for dir in man/ja man/pl man/ru man/sk src; do
  466. rm -rf $RPM_BUILD_ROOT%{l_prefix}/$dir >/dev/null 2>&1 || true
  467. done
  468. for file in rpmbuild rpmdb rpme rpmi rpmsign rpmu rpmverify rpmquery gendiff; do
  469. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/$file >/dev/null 2>&1 || true
  470. done
  471. rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/* >/dev/null 2>&1 || true
  472. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/* >/dev/null 2>&1 || true
  473. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man3/* >/dev/null 2>&1 || true
  474. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/rpmpopt >/dev/null 2>&1 || true
  475. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/rpmrc >/dev/null 2>&1 || true
  476. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/lib*.la >/dev/null 2>&1 || true
  477. rm -rf $RPM_BUILD_ROOT%{l_prefix}/var/lib >/dev/null 2>&1 || true
  478. for file in \
  479. u_pkg.sh vpkg-provides.sh vpkg-provides2.sh rpmdiff.cgi rpmdiff \
  480. perl.prov perl.req mkinstalldirs magic.prov magic.req http.req \
  481. getpo.sh get_magic.pl find-requires.perl find-req.pl find-provides.perl \
  482. find-prov.pl find-lang.sh cpanflute convertrpmrc.sh check-prereqs \
  483. rpmputtext rpmgettext brp-compress brp-redhat brp-sparc64-linux \
  484. brp-strip brp-strip-shared brp-strip-comment-note rpmrc \
  485. config.guess config.sub; do
  486. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/$file >/dev/null 2>&1 || true
  487. done
  488. # add additional development files
  489. cp zlib-%{V_zlib}/zlib.h $RPM_BUILD_ROOT%{l_prefix}/include/rpm/
  490. cp zlib-%{V_zlib}/libz.a $RPM_BUILD_ROOT%{l_prefix}/lib/librpmz.a
  491. cp db-%{V_db}/build_unix/db.h $RPM_BUILD_ROOT%{l_prefix}/include/rpm/
  492. cp db-%{V_db}/build_unix/libdb.a $RPM_BUILD_ROOT%{l_prefix}/lib/librpmdb.a
  493. # post-adjust RPM installation (namespace-clean POPT inclusion)
  494. mv $RPM_BUILD_ROOT%{l_prefix}/lib/libpopt.a \
  495. $RPM_BUILD_ROOT%{l_prefix}/lib/librpmpopt.a
  496. mv $RPM_BUILD_ROOT%{l_prefix}/include/popt.h \
  497. $RPM_BUILD_ROOT%{l_prefix}/include/rpm/popt.h
  498. # replace symlinks with hardlinks
  499. for entry in rpme:rpmi rpmt:rpmb rpmu:rpmi rpmv:rpmq; do
  500. eval `echo $entry | sed -e 's/^\(.*\):\(.*\)$/dst=\1; src=\2/'`
  501. rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/$dst
  502. ln $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/$src \
  503. $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/$dst
  504. done
  505. # install lsync tool
  506. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  507. <`SOURCE lsync` \
  508. >$RPM_BUILD_ROOT%{l_prefix}/sbin/lsync
  509. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/sbin/lsync
  510. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  511. <`SOURCE dot.lsyncrc` \
  512. >$RPM_BUILD_ROOT%{l_prefix}/local/.lsyncrc
  513. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  514. <`SOURCE lsync.8` \
  515. >$RPM_BUILD_ROOT%{l_prefix}/man/man8/lsync.8
  516. # install RPM extension
  517. ( cd curl-%{V_curl}
  518. cp src/curl $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/curl
  519. strip $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/curl
  520. )
  521. ( cd bzip2-%{V_bzip2}
  522. cp bzip2 $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bzip2
  523. strip $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bzip2
  524. )
  525. ( cd gzip-%{V_gzip}
  526. cp gzip $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/gzip
  527. strip $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/gzip
  528. )
  529. ( cd patch-%{V_patch}
  530. cp patch $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/patch
  531. strip $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/patch
  532. )
  533. ( cd tar-%{V_tar}
  534. cp src/tar $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/tar
  535. strip $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/tar
  536. )
  537. ( cd bash-%{V_bash}
  538. cp bash $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bash
  539. strip $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bash
  540. )
  541. sed -e "s;@l_prefix@;%{l_prefix};g" \
  542. <`SOURCE rpmx.sh` >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmx.sh
  543. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmx.sh
  544. sed -e "s;@l_prefix@;%{l_prefix};g" \
  545. <`SOURCE rpmx.pl` >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmx.pl
  546. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmx.pl
  547. sed -e "s;@l_prefix@;%{l_prefix};g" \
  548. <`SOURCE mkproxyrpm.pl` >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/mkproxyrpm.pl
  549. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/mkproxyrpm.pl
  550. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  551. <`SOURCE rpmtool` >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmtool
  552. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmtool
  553. # install an own copy of shtool
  554. cp $shtool $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/shtool
  555. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/shtool
  556. # install GNU config scripts
  557. cp `SOURCE config.guess` $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/
  558. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/config.guess
  559. cp `SOURCE config.sub` $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/
  560. chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/config.sub
  561. # install a few README files
  562. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  563. <`SOURCE root.README` \
  564. >$RPM_BUILD_ROOT%{l_prefix}/README
  565. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  566. <`SOURCE local.README` \
  567. >$RPM_BUILD_ROOT%{l_prefix}/local/README
  568. # install Bash environment
  569. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  570. <`SOURCE dot.bashrc` \
  571. >$RPM_BUILD_ROOT%{l_prefix}/.bashrc
  572. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  573. <`SOURCE dot.bash_login` \
  574. >$RPM_BUILD_ROOT%{l_prefix}/.bash_login
  575. # install Run-Command files
  576. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  577. <`SOURCE rc` \
  578. >$RPM_BUILD_ROOT%{l_prefix}/etc/rc
  579. chmod 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc
  580. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  581. <`SOURCE rc.conf` \
  582. >$RPM_BUILD_ROOT%{l_prefix}/etc/rc.conf
  583. chmod 644 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.conf
  584. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  585. <`SOURCE rc.func` \
  586. >$RPM_BUILD_ROOT%{l_prefix}/etc/rc.func
  587. chmod 644 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.func
  588. mkdir $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  589. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  590. <`SOURCE rc.openpkg` \
  591. >$RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/rc.openpkg
  592. chmod 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/rc.openpkg
  593. # hard-code RPM tool for installation hierarchy
  594. # and adjust RPM configuration files
  595. mv $RPM_BUILD_ROOT%{l_prefix}/bin/rpm \
  596. $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpm
  597. ( echo "#!/bin/sh";
  598. echo "exec %{l_prefix}/lib/openpkg/rpm --rcfile %{l_prefix}/etc/openpkg/rpmrc \${1+\"\$@\"}"
  599. ) >$RPM_BUILD_ROOT%{l_prefix}/bin/rpm
  600. chmod 755 $RPM_BUILD_ROOT%{l_prefix}/bin/rpm
  601. cat `SOURCE rpmpopt` \
  602. >>$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmpopt-%{V_rpm}
  603. test -d $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg || \
  604. mkdir $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg
  605. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  606. <`SOURCE rpmrc` \
  607. >$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/rpmrc
  608. sed -e "s:@l_prefix@:%{l_prefix}:g" \
  609. -e "s;@l_build_path@;$l_build_path;g" \
  610. -e "s;@l_build_ldlp@;$l_build_ldlp;g" \
  611. -e "s;@l_build_ulim@;$l_build_ulim;g" \
  612. -e "s:@LOC@:$loc:g" \
  613. -e "s:@SUSR@:$susr:g" \
  614. -e "s:@SGRP@:$sgrp:g" \
  615. -e "s:@MUSR@:$musr:g" \
  616. -e "s:@MGRP@:$mgrp:g" \
  617. -e "s:@RUSR@:$rusr:g" \
  618. -e "s:@RGRP@:$rgrp:g" \
  619. -e "s:@NUSR@:$nusr:g" \
  620. -e "s:@NGRP@:$ngrp:g" \
  621. <`SOURCE rpmmacros` \
  622. >$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/rpmmacros
  623. cp `SOURCE openpkg.pgp` \
  624. $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/openpkg.pgp
  625. %files
  626. %defattr(-,%{?l_musr}%{!?l_musr:%{l_fsusr}},%{?l_mgrp}%{!?l_mgrp:%{l_fsgrp}})
  627. %{l_prefix}/README
  628. %{l_prefix}/.bashrc
  629. %{l_prefix}/.bash_login
  630. %dir %{l_prefix}/RPM
  631. %dir %{l_prefix}/RPM/SRC
  632. %dir %{l_prefix}/RPM/PKG
  633. %dir %{l_prefix}/RPM/DB
  634. %dir %{l_prefix}/RPM/TMP
  635. %dir %{l_prefix}/cgi
  636. %dir %{l_prefix}/bin
  637. %{l_prefix}/bin/rpm2cpio
  638. %{l_prefix}/bin/rpm
  639. %dir %{l_prefix}/etc
  640. %{l_prefix}/etc/rc
  641. %config %{l_prefix}/etc/rc.conf
  642. %{l_prefix}/etc/rc.func
  643. %dir %{l_prefix}/etc/rc.d
  644. %{l_prefix}/etc/rc.d/rc.openpkg
  645. %dir %{l_prefix}/etc/openpkg
  646. %config %{l_prefix}/etc/openpkg/rpmmacros
  647. %config %{l_prefix}/etc/openpkg/rpmrc
  648. %{l_prefix}/etc/openpkg/openpkg.pgp
  649. %dir %{l_prefix}/include
  650. %dir %{l_prefix}/include/rpm
  651. %{l_prefix}/include/rpm/popt.h
  652. %{l_prefix}/include/rpm/header.h
  653. %{l_prefix}/include/rpm/misc.h
  654. %{l_prefix}/include/rpm/rpmbuild.h
  655. %{l_prefix}/include/rpm/rpmerr.h
  656. %{l_prefix}/include/rpm/rpmio.h
  657. %{l_prefix}/include/rpm/rpmlib.h
  658. %{l_prefix}/include/rpm/rpmlog.h
  659. %{l_prefix}/include/rpm/rpmmacro.h
  660. %{l_prefix}/include/rpm/rpmmessages.h
  661. %{l_prefix}/include/rpm/rpmspec.h
  662. %{l_prefix}/include/rpm/rpmurl.h
  663. %{l_prefix}/include/rpm/stringbuf.h
  664. %{l_prefix}/include/rpm/ugid.h
  665. %{l_prefix}/include/rpm/db.h
  666. %{l_prefix}/include/rpm/zlib.h
  667. %dir %{l_prefix}/info
  668. %dir %{l_prefix}/lib
  669. %dir %{l_prefix}/lib/openpkg
  670. %{l_prefix}/lib/openpkg/bash
  671. %{l_prefix}/lib/openpkg/bzip2
  672. %{l_prefix}/lib/openpkg/curl
  673. %{l_prefix}/lib/openpkg/find-provides
  674. %{l_prefix}/lib/openpkg/find-requires
  675. %{l_prefix}/lib/openpkg/gzip
  676. %{l_prefix}/lib/openpkg/macros
  677. %{l_prefix}/lib/openpkg/mkproxyrpm.pl
  678. %{l_prefix}/lib/openpkg/patch
  679. %{l_prefix}/lib/openpkg/rpm
  680. %{l_prefix}/lib/openpkg/rpmb
  681. %{l_prefix}/lib/openpkg/rpmdb
  682. %{l_prefix}/lib/openpkg/rpme
  683. %{l_prefix}/lib/openpkg/rpmi
  684. %{l_prefix}/lib/openpkg/rpmk
  685. %{l_prefix}/lib/openpkg/rpmpopt-%{V_rpm}
  686. %{l_prefix}/lib/openpkg/rpmq
  687. %{l_prefix}/lib/openpkg/rpmt
  688. %{l_prefix}/lib/openpkg/rpmtool
  689. %{l_prefix}/lib/openpkg/rpmu
  690. %{l_prefix}/lib/openpkg/rpmv
  691. %{l_prefix}/lib/openpkg/rpmx.pl
  692. %{l_prefix}/lib/openpkg/rpmx.sh
  693. %{l_prefix}/lib/openpkg/shtool
  694. %{l_prefix}/lib/openpkg/tar
  695. %{l_prefix}/lib/openpkg/config.guess
  696. %{l_prefix}/lib/openpkg/config.sub
  697. %{l_prefix}/lib/librpmpopt.a
  698. %{l_prefix}/lib/librpm.a
  699. %{l_prefix}/lib/librpmbuild.a
  700. %{l_prefix}/lib/librpmio.a
  701. %{l_prefix}/lib/librpmz.a
  702. %{l_prefix}/lib/librpmdb.a
  703. %dir %{l_prefix}/libexec
  704. %dir %{l_prefix}/man
  705. %dir %{l_prefix}/man/man1
  706. %dir %{l_prefix}/man/man2
  707. %dir %{l_prefix}/man/man3
  708. %dir %{l_prefix}/man/man4
  709. %dir %{l_prefix}/man/man5
  710. %dir %{l_prefix}/man/man6
  711. %dir %{l_prefix}/man/man7
  712. %dir %{l_prefix}/man/man8
  713. %dir %{l_prefix}/man/man9
  714. %dir %{l_prefix}/man/cat1
  715. %dir %{l_prefix}/man/cat2
  716. %dir %{l_prefix}/man/cat3
  717. %dir %{l_prefix}/man/cat4
  718. %dir %{l_prefix}/man/cat5
  719. %dir %{l_prefix}/man/cat6
  720. %dir %{l_prefix}/man/cat7
  721. %dir %{l_prefix}/man/cat8
  722. %dir %{l_prefix}/man/cat9
  723. %{l_prefix}/man/man8/rpm.8
  724. %{l_prefix}/man/man8/rpm2cpio.8
  725. %{l_prefix}/man/man8/lsync.8
  726. %dir %{l_prefix}/sbin
  727. %dir %{l_prefix}/pub
  728. %dir %{l_prefix}/share
  729. %dir %{l_prefix}/var
  730. %{l_prefix}/sbin/lsync
  731. %dir %{l_prefix}/local
  732. %{l_prefix}/local/README
  733. %{l_prefix}/local/.lsyncrc
  734. %dir %{l_prefix}/local/PKG
  735. %dir %{l_prefix}/local/bin
  736. %dir %{l_prefix}/local/etc
  737. %dir %{l_prefix}/local/include
  738. %dir %{l_prefix}/local/info
  739. %dir %{l_prefix}/local/lib
  740. %dir %{l_prefix}/local/man
  741. %dir %{l_prefix}/local/man/man1
  742. %dir %{l_prefix}/local/man/man2
  743. %dir %{l_prefix}/local/man/man3
  744. %dir %{l_prefix}/local/man/man4
  745. %dir %{l_prefix}/local/man/man5
  746. %dir %{l_prefix}/local/man/man6
  747. %dir %{l_prefix}/local/man/man7
  748. %dir %{l_prefix}/local/man/man8
  749. %dir %{l_prefix}/local/man/man9
  750. %dir %{l_prefix}/local/man/cat1
  751. %dir %{l_prefix}/local/man/cat2
  752. %dir %{l_prefix}/local/man/cat3
  753. %dir %{l_prefix}/local/man/cat4
  754. %dir %{l_prefix}/local/man/cat5
  755. %dir %{l_prefix}/local/man/cat6
  756. %dir %{l_prefix}/local/man/cat7
  757. %dir %{l_prefix}/local/man/cat8
  758. %dir %{l_prefix}/local/man/cat9
  759. %dir %{l_prefix}/local/sbin
  760. %clean
  761. # skip in bootstrap phase 2 (see openpkg.boot)
  762. [ ".$OPENPKG_BOOT" = .1 ] && exit 0
  763. # cleanup after building
  764. rm -rf $RPM_BUILD_ROOT
  765. rm -rf %{name}-%{version}
  766. %pre
  767. # always performed for upgrades and because it doesn't harm!
  768. #[ ".$1" != .1 ] && exit 0
  769. # this procedure is only usable with root priviledges
  770. # (for non-root installations it is not required at all)
  771. cusr=`(id -un) 2>/dev/null ||\
  772. (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
  773. (whoami) 2>/dev/null ||\
  774. (who am i | cut "-d " -f1) 2>/dev/null ||\
  775. echo $LOGNAME`
  776. # determine runtime details (for both inside and outside RPM!!)
  777. # - bootstrapping: $xxx is set from aux.wrapbin.sh
  778. # - upgrading new: %{l_[smrn]{usr,grp}} is set via rpmmacros
  779. # - upgrading old: %{l_[smrn]{usr,grp}} is not set at all
  780. [ ".$susr" = . ] && susr="%{?l_susr}%{!?l_susr:root}"
  781. [ ".$sgrp" = . ] && sgrp="%{?l_sgrp}%{!?l_sgrp:wheel}"
  782. [ ".$musr" = . ] && musr="%{?l_musr}%{!?l_musr:%{l_fsusr}}"
  783. [ ".$mgrp" = . ] && mgrp="%{?l_mgrp}%{!?l_mgrp:%{l_fsgrp}}"
  784. [ ".$rusr" = . ] && rusr="%{?l_rusr}%{!?l_rusr:%{l_fsusr}-r}"
  785. [ ".$rgrp" = . ] && rgrp="%{?l_rgrp}%{!?l_rgrp:%{l_fsgrp}-r}"
  786. [ ".$nusr" = . ] && nusr="%{?l_nusr}%{!?l_nusr:%{l_fsusr}-n}"
  787. [ ".$ngrp" = . ] && ngrp="%{?l_ngrp}%{!?l_ngrp:%{l_fsgrp}-n}"
  788. # determine prefix
  789. [ ".$prefix" = . ] && prefix="%{l_prefix}"
  790. prefix=`echo "$prefix" | sed -e 's;//*;/;g' -e 's;/$;;'`
  791. # determine user/group ids
  792. for class in s m r n; do
  793. eval "xusr=\"\$${class}usr\""
  794. eval "xgrp=\"\$${class}grp\""
  795. eval "xuid=\"\$${class}uid\""
  796. eval "xgid=\"\$${class}gid\""
  797. if [ ".$xuid" = . ]; then
  798. xuid=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
  799. grep "^${xusr}:" | awk -F: '{ print $3; }'`
  800. if [ ".$xuid" = . ]; then
  801. # seek for a reasonably uid/gid pair
  802. xuid=1000
  803. ok=0
  804. while [ ".$ok" = .0 ]; do
  805. eval "u_exists=\$u_exists_$xuid"
  806. if [ ".$u_exists" = . ]; then
  807. u_exists=`(cat /etc/passwd; ypcat passwd) 2>/dev/null | grep "^[^:]*:[^:]*:$xuid:"`
  808. fi
  809. eval "g_exists=\$g_exists_$xuid"
  810. if [ ".$g_exists" = . ]; then
  811. g_exists=`(cat /etc/group; ypcat group) 2>/dev/null | grep "^[^:]*:[^:]*:$xuid:"`
  812. fi
  813. if [ ".$u_exists" = . -a ".$g_exists" = . ]; then
  814. ok=1
  815. break
  816. fi
  817. xuid=`expr $xuid + 1`
  818. done
  819. eval "u_exists_$xuid=yes"
  820. eval "g_exists_$xuid=yes"
  821. fi
  822. fi
  823. if [ ".$xgid" = . ]; then
  824. xgid=`(cat /etc/group; ypcat group) 2>/dev/null |\
  825. grep "^${xgrp}:" | awk -F: '{ print $3; }'`
  826. if [ ".$xgid" = . ]; then
  827. xgid="$xuid"
  828. fi
  829. fi
  830. eval "${class}uid=\"$xuid\""
  831. eval "${class}gid=\"$xgid\""
  832. done
  833. # determine platform id
  834. s=`(uname -s) 2>/dev/null` || s='Unknown'
  835. r=`(uname -r) 2>/dev/null` || r='0.0'
  836. plid="${s}/${r}"
  837. # add entry to /etc/shells
  838. shell="${prefix}/lib/openpkg/bash"
  839. exists=`cat /etc/shells 2>/dev/null | grep "^$shell"`
  840. if [ ".$exists" = . ]; then
  841. if [ ".$cusr" != ".root" ]; then
  842. echo "openpkg:WARNING: skipping addition of $shell to /etc/shells" 1>&2
  843. echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
  844. else
  845. echo "${shell}" >>/etc/shells
  846. fi
  847. fi
  848. # create the hierarchy user/group
  849. for req in "superuser:${susr}:${suid}:${sgrp}:${sgid}" \
  850. "management:${musr}:${muid}:${mgrp}:${mgid}" \
  851. "restricted:${rusr}:${ruid}:${rgrp}:${rgid}" \
  852. "non-priviledged:${nusr}:${nuid}:${ngrp}:${ngid}"; do
  853. # split request into class/usr/uid/grp/gid
  854. OIFS="$IFS"; IFS=":"; set -- $req; IFS="$OIFS"
  855. class="$1"; usr="$2"; uid="$3"; grp="$4"; gid="$5"
  856. # check whether user already exists
  857. exists=`(cat /etc/passwd; ypcat passwd) 2>/dev/null | grep "^$usr:"`
  858. if [ ".$exists" = . ]; then
  859. if [ ".$cusr" != ".root" ]; then
  860. echo "openpkg:WARNING: skipping creation of OpenPKG $class user $usr" 1>&2
  861. echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
  862. else
  863. # add entry to passwd database
  864. realname="${prefix} OpenPKG ($class)"
  865. case "$plid" in
  866. FreeBSD/* | NetBSD/* )
  867. file=/etc/master.passwd
  868. entry="${usr}:*:${uid}:${gid}::0:0:${realname}:${prefix}:${shell}"
  869. update="(PATH=\$PATH:/usr/sbin; pwd_mkdb -p /etc/master.passwd)"
  870. ;;
  871. Linux/* )
  872. file=/etc/passwd
  873. entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
  874. update="(PATH=\$PATH:/usr/sbin; pwconv)"
  875. ;;
  876. SunOS/5.* )
  877. file=/etc/passwd
  878. entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
  879. update="(PATH=\$PATH:/usr/sbin; pwconv)"
  880. ;;
  881. OSF1/V5.* )
  882. file=/etc/passwd
  883. entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
  884. update="(PATH=\$PATH:/usr/sbin; mkpasswd /etc/passwd)"
  885. ;;
  886. HP-UX/* )
  887. file=/etc/passwd
  888. entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
  889. update=":"
  890. ;;
  891. esac
  892. cp $file $file.bak && \
  893. (grep -v '^+:' $file.bak; echo $entry; grep '^+:' $file.bak) >$file
  894. rm -f $file.bak >/dev/null 2>&1
  895. eval $update
  896. fi
  897. fi
  898. # check whether group already exists
  899. exists=`(cat /etc/group; ypcat group) 2>/dev/null | grep "^$grp:"`
  900. if [ ".$exists" = . ]; then
  901. if [ ".$cusr" != ".root" ]; then
  902. echo "openpkg:WARNING: skipping creation of OpenPKG $class group $grp" 1>&2
  903. echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
  904. else
  905. # add entry to group database
  906. file=/etc/group
  907. entry="${grp}:*:${gid}:${usr}"
  908. cp $file $file.bak && \
  909. (grep -v '^+:' $file.bak; echo $entry; grep '^+:' $file.bak) >$file
  910. rm -f $file.bak >/dev/null 2>&1
  911. fi
  912. fi
  913. done
  914. # create the startup/shutdown transfer script
  915. name=`echo "$prefix" | sed -e 's;/;;g'`
  916. if [ ".$cusr" != ".root" ]; then
  917. echo "openpkg:WARNING: skipping creation of system run-command hooks" 1>&2
  918. echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
  919. else
  920. case "$plid" in
  921. FreeBSD/* )
  922. if [ ! -f /etc/rc.d/${name}.sh ]; then
  923. # make sure /etc/rc.d exists
  924. if [ ! -d /etc/rc.d ]; then
  925. mkdir /etc/rc.d
  926. fi
  927. # make sure /etc/rc.d is activated
  928. ( . /etc/defaults/rc.conf
  929. . /etc/rc.conf
  930. found=0
  931. for p in ${local_startup-x}; do
  932. if [ ".$p" = "./etc/rc.d" ]; then
  933. found=1
  934. break
  935. fi
  936. done
  937. if [ ".$found" = .0 ]; then
  938. cp -p /etc/rc.conf /etc/rc.conf.bak
  939. (
  940. grep -v local_startup /etc/rc.conf.bak
  941. echo "local_startup=\"/etc/rc.d $local_startup\""
  942. ) >/etc/rc.conf
  943. fi
  944. )
  945. # install transfer script
  946. rm -f /etc/rc.d/${name}.sh >/dev/null 2>&1
  947. ( echo "#!/bin/sh"
  948. echo "#"
  949. echo "# ${name}.sh -- startup/shutdown transfer script for ${prefix} OpenPKG hierarchy"
  950. echo "#"
  951. echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  952. echo "case \$1 in"
  953. echo " start ) exec ${prefix}/etc/rc all start ;;"
  954. echo " stop ) exec ${prefix}/etc/rc all stop ;;"
  955. echo "esac"
  956. ) >/etc/rc.d/${name}.sh
  957. chmod 755 /etc/rc.d/${name}.sh
  958. fi
  959. ;;
  960. NetBSD/* )
  961. if [ ! -f /etc/rc.d/${name} ]; then
  962. ( echo "#!/bin/sh"
  963. echo "#"
  964. echo "# ${name} -- startup/shutdown transfer script for ${prefix} OpenPKG hierarchy"
  965. echo "#"
  966. echo "# PROVIDE: ${name}"
  967. echo "# REQUIRE: DAEMON LOGIN NETWORK SERVERS"
  968. echo "#"
  969. echo ""
  970. echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  971. echo "case \$1 in"
  972. echo " start ) exec ${prefix}/etc/rc all start ;;"
  973. echo " stop ) exec ${prefix}/etc/rc all stop ;;"
  974. echo " restart ) exec ${prefix}/etc/rc all stop start ;;"
  975. echo " status ) ;;"
  976. echo "esac"
  977. ) >/etc/rc.d/${name}
  978. chmod 755 /etc/rc.d/${name}
  979. fi
  980. ;;
  981. Linux/* )
  982. # sroot: script root directory
  983. # lroot: link root directory
  984. if [ -f /etc/debian_version ]; then
  985. sroot=/etc/init.d
  986. lroot=/etc/rc%d.d
  987. elif [ -f /etc/redhat-release -o -f /etc/mandrake-release ]; then
  988. sroot=/etc/rc.d/init.d
  989. lroot=/etc/rc.d/rc%d.d
  990. else
  991. echo "WARNING: you are not running one of the supported standard" 1>&2
  992. echo "WARNING: Linux platforms (Debian, RedHat). We are trying" 1>&2
  993. echo "WARNING: to guess the location of the system init scripts!" 1>&2
  994. sroot=""
  995. lroot=""
  996. for sr in /etc/rc.d/init.d /etc/init.d /sbin/init.d; do
  997. if [ -d $sr ]; then
  998. sroot="$sr"
  999. break
  1000. fi
  1001. done
  1002. for lr in /etc/rc.d/rc2.d /etc/rc2.d /sbin/init.d/rc2.d; do
  1003. if [ -d $lr ]; then
  1004. lroot="`echo $lr | sed -e 's;2;%d;'`"
  1005. break
  1006. fi
  1007. done
  1008. if [ ".$sroot" = . -o ".$lroot" = . ]; then
  1009. echo "ERROR: Failed to guess the location of the system init scripts!" 1>&2
  1010. exit 1
  1011. fi
  1012. fi
  1013. if [ ! -f $sroot/${name} ]; then
  1014. # install transfer script
  1015. ( echo "#!/bin/sh"
  1016. echo "#"
  1017. echo "# ${name} -- startup/shutdown transfer script for ${prefix} OpenPKG hierarchy"
  1018. echo "#"
  1019. echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  1020. echo "case \$1 in"
  1021. echo " start ) exec ${prefix}/etc/rc all start ;;"
  1022. echo " stop ) exec ${prefix}/etc/rc all stop ;;"
  1023. echo "esac"
  1024. ) >$sroot/${name}
  1025. chmod 755 $sroot/${name}
  1026. # create corresponding symbolic links
  1027. for i in 2 3 4 5; do
  1028. ln -s $sroot/${name} `echo $lroot | sed -e "s;%d;$i;"`/S99${name}
  1029. done
  1030. for i in 0 1 6; do
  1031. ln -s $sroot/${name} `echo $lroot | sed -e "s;%d;$i;"`/K00${name}
  1032. done
  1033. fi
  1034. ;;
  1035. SunOS/5.* )
  1036. if [ ! -f /etc/init.d/${name} ]; then
  1037. # install transfer script
  1038. ( echo "#!/bin/sh"
  1039. echo "#"
  1040. echo "# ${name} -- startup/shutdown transfer script for ${prefix} OpenPKG hierarchy"
  1041. echo "#"
  1042. echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  1043. echo "case \$1 in"
  1044. echo " start ) exec ${prefix}/etc/rc all start ;;"
  1045. echo " stop ) exec ${prefix}/etc/rc all stop ;;"
  1046. echo "esac"
  1047. ) >/etc/init.d/${name}
  1048. chmod 755 /etc/init.d/${name}
  1049. # create corresponding symbolic links
  1050. ( cd /etc
  1051. ln init.d/${name} rc3.d/S99${name}
  1052. ln init.d/${name} rc0.d/K00${name}
  1053. ln init.d/${name} rc1.d/K00${name}
  1054. )
  1055. fi
  1056. ;;
  1057. OSF1/V5.* )
  1058. if [ ! -f /sbin/init.d/${name} ]; then
  1059. # install transfer script
  1060. ( echo "#!/bin/sh"
  1061. echo "#"
  1062. echo "# ${name} -- startup/shutdown transfer script for ${prefix} OpenPKG hierarchy"
  1063. echo "#"
  1064. echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  1065. echo "case \$1 in"
  1066. echo " start ) exec ${prefix}/etc/rc all start ;;"
  1067. echo " stop ) exec ${prefix}/etc/rc all stop ;;"
  1068. echo "esac"
  1069. ) >/sbin/init.d/${name}
  1070. chmod 755 /sbin/init.d/${name}
  1071. # create corresponding symbolic links
  1072. ( cd /sbin
  1073. ln -s ../init.d/${name} rc3.d/S99${name}
  1074. ln -s ../init.d/${name} rc0.d/K00${name}
  1075. )
  1076. fi
  1077. ;;
  1078. HP-UX/* )
  1079. if [ ! -f /sbin/init.d/${name} ]; then
  1080. # install transfer script
  1081. ( echo "#!/bin/sh"
  1082. echo "#"
  1083. echo "# ${name} -- startup/shutdown transfer script for ${prefix} OpenPKG hierarchy"
  1084. echo "#"
  1085. echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  1086. echo "case \$1 in"
  1087. echo " start ) exec ${prefix}/etc/rc all start ;;"
  1088. echo " stop ) exec ${prefix}/etc/rc all stop ;;"
  1089. echo "esac"
  1090. ) >/sbin/init.d/${name}
  1091. chmod 755 /sbin/init.d/${name}
  1092. # create corresponding symbolic links
  1093. ( cd /sbin
  1094. ln -s ../init.d/${name} rc2.d/S900${name}
  1095. ln -s ../init.d/${name} rc1.d/K100${name}
  1096. )
  1097. fi
  1098. ;;
  1099. esac
  1100. fi
  1101. # create the cron transfer entries
  1102. if [ ".$cusr" != ".root" ]; then
  1103. echo "openpkg:WARNING: skipping creation of system cron hooks" 1>&2
  1104. echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
  1105. else
  1106. case "$plid" in
  1107. FreeBSD/* | Linux/* )
  1108. exists=`grep "$prefix/etc/rc" /etc/crontab`
  1109. if [ ".$exists" = . ]; then
  1110. ( echo "# <OpenPKG prefix=$prefix pkg=openpkg>"
  1111. echo "# chronological tasks of ${prefix} OpenPKG hierarchy"
  1112. echo "0 0 1 * * root [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all monthly"
  1113. echo "0 0 * * 0 root [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all weekly"
  1114. echo "0 0 * * * root [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all daily"
  1115. echo "0 * * * * root [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all hourly"
  1116. echo "*/15 * * * * root [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all quarterly"
  1117. echo "# </OpenPKG>"
  1118. ) >>/etc/crontab
  1119. fi
  1120. ;;
  1121. SunOS/5.* | OSF1/V5.* | NetBSD/* | HP-UX/* )
  1122. exists=`crontab -l | grep "$prefix/etc/rc"`
  1123. if [ ".$exists" = . ]; then
  1124. EDITOR=/tmp/vipw.$$
  1125. VISUAL="$EDITOR"
  1126. export EDITOR
  1127. export VISUAL
  1128. ( echo "#!/bin/sh"
  1129. echo "( echo \"# <OpenPKG prefix=$prefix pkg=openpkg>\""
  1130. echo " echo \"# chronological tasks of ${prefix} OpenPKG hierarchy\""
  1131. echo " echo \"0 0 1 * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all monthly\""
  1132. echo " echo \"0 0 * * 0 [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all weekly\""
  1133. echo " echo \"0 0 * * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all daily\""
  1134. echo " echo \"0 * * * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all hourly\""
  1135. echo " echo \"0,15,30,45 * * * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all quarterly\""
  1136. echo " echo \"# </OpenPKG>\""
  1137. echo ") >>\$1"
  1138. ) >$EDITOR
  1139. chmod a+x $EDITOR
  1140. (PATH="$PATH:/usr/bin"; crontab -e)
  1141. rm -f $EDITOR
  1142. fi
  1143. ;;
  1144. esac
  1145. fi
  1146. %post
  1147. # Finally, rebuild the RPM database with the newly installed RPM
  1148. # program on upgrades. Because of RPM internal database locking we
  1149. # have to play a little trick here and delay the operation until RPM
  1150. # thinks this "post" script has already terminated.
  1151. if [ ".$1" = .2 ]; then
  1152. ( sleep 2
  1153. %{l_prefix}/bin/rpm --rebuilddb
  1154. chown %{l_musr}:%{l_mgrp} %{l_prefix}/RPM/DB/* || true
  1155. ) </dev/null >/dev/null 2>/dev/null &
  1156. fi
  1157. %preun
  1158. [ ".$1" != .0 ] && exit 0
  1159. # remove files which are not RPM controlled
  1160. rm -rf %{l_prefix}/RPM/TMP/* >/dev/null 2>&1 || true
  1161. rm -rf %{l_prefix}/RPM/SRC/* >/dev/null 2>&1 || true
  1162. rm -rf %{l_prefix}/RPM/PKG/* >/dev/null 2>&1 || true
  1163. rm -rf %{l_prefix}/RPM/DB/* >/dev/null 2>&1 || true
  1164. ##
  1165. ## The following code usually would be done in a %postun section.
  1166. ## But because we already had to remove the database in this %preun
  1167. ## section (see the 'rm' commands above) in order to make RPM happy
  1168. ## inside its own removal procedure, RPM would no longer find the
  1169. ## %postun script (because it's recorded in the database files). So
  1170. ## we have to perform the procedure already in this %preun script.
  1171. ## except for the removal of the top-level directory it does not
  1172. ## matter. But the top-level directory can only be removed after
  1173. ## the RPM removal procedure took place, so we play a little delay
  1174. ## trick below.
  1175. ##
  1176. # determine current user
  1177. cusr=`(id -un) 2>/dev/null ||\
  1178. (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
  1179. (whoami) 2>/dev/null ||\
  1180. (who am i | cut "-d " -f1) 2>/dev/null ||\
  1181. echo $LOGNAME`
  1182. # determine runtime details (for both inside and outside RPM!!)
  1183. user="%{l_musr}"
  1184. group="%{l_mgrp}"
  1185. prefix="%{l_prefix}"
  1186. prefix=`echo "$prefix" | sed -e 's;//*;/;g' -e 's;/$;;'`
  1187. # determine platform id
  1188. s=`(uname -s) 2>/dev/null` || s='Unknown'
  1189. r=`(uname -r) 2>/dev/null` || r='0.0'
  1190. plid="${s}/${r}"
  1191. # remove entry in /etc/shells
  1192. shell="${prefix}/lib/openpkg/bash"
  1193. exists=`cat /etc/shells 2>/dev/null | grep "^$shell"`
  1194. if [ ".$exists" != . ]; then
  1195. if [ ".$cusr" != ".root" ]; then
  1196. echo "openpkg:WARNING: skipping deletion of $shell from /etc/shells" 1>&2
  1197. echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
  1198. else
  1199. cp /etc/shells /etc/shells.bak && \
  1200. grep -v "^${shell}" /etc/shells.bak >/etc/shells
  1201. fi
  1202. fi
  1203. # remove the hierarchy user/group
  1204. for req in "super-user:%{l_susr}:%{l_suid}:%{l_sgrp}:%{l_sgid}" \
  1205. "management:%{l_musr}:%{l_muid}:%{l_mgrp}:%{l_mgid}" \
  1206. "restricted:%{l_rusr}:%{l_ruid}:%{l_rgrp}:%{l_rgid}" \
  1207. "non-priviledged:%{l_nusr}:%{l_nuid}:%{l_ngrp}:%{l_ngid}"; do
  1208. # split request into class/usr/uid/grp/gid
  1209. OIFS="$IFS"; IFS=":"; set -- $req; IFS="$OIFS"
  1210. class="$1"; usr="$2"; uid="$3"; grp="$4"; gid="$5"
  1211. # check whether user already exists
  1212. exists=`(cat /etc/passwd; ypcat passwd) 2>/dev/null | grep "^$usr:"`
  1213. if [ ".$exists" != . ]; then
  1214. if [ ".$cusr" != ".root" ]; then
  1215. echo "openpkg:WARNING: skipping deletion of OpenPKG $class user $usr" 1>&2
  1216. echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
  1217. elif [ ".$usr" = ".root" ]; then
  1218. echo "openpkg:WARNING: skipping deletion of OpenPKG $class user $usr" 1>&2
  1219. echo "openpkg:WARNING: (would remove system standard user)" 1>&2
  1220. else
  1221. case "$plid" in
  1222. FreeBSD/* | NetBSD/* )
  1223. cp /etc/master.passwd /etc/master.passwd.bak && \
  1224. grep -v "^${usr}:" /etc/master.passwd.bak >/etc/master.passwd
  1225. (PATH="$PATH:/usr/sbin"; pwd_mkdb -p /etc/master.passwd)
  1226. ;;
  1227. Linux/* | SunOS/5.* )
  1228. cp /etc/passwd /etc/passwd.bak && \
  1229. grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
  1230. (PATH="$PATH:/usr/sbin"; pwconv)
  1231. ;;
  1232. OSF1/V5.* )
  1233. cp /etc/passwd /etc/passwd.bak && \
  1234. grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
  1235. (PATH="$PATH:/usr/sbin"; mkpasswd /etc/passwd)
  1236. ;;
  1237. HP-UX/* )
  1238. cp /etc/passwd /etc/passwd.bak && \
  1239. grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
  1240. ;;
  1241. esac
  1242. fi
  1243. fi
  1244. # check whether group already exists
  1245. exists=`(cat /etc/group; ypcat group) 2>/dev/null | grep "^$grp:"`
  1246. if [ ".$exists" = . ]; then
  1247. if [ ".$cusr" != ".root" ]; then
  1248. echo "openpkg:WARNING: skipping deletion of OpenPKG $class group $grp" 1>&2
  1249. echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
  1250. elif [ ".$usr" = ".root" ] || [ ".$grp" = ".root" ] || [ ".$grp" = ".wheel" ]; then
  1251. echo "openpkg:WARNING: skipping deletion of OpenPKG $class group $grp" 1>&2
  1252. echo "openpkg:WARNING: (would remove system standard group)" 1>&2
  1253. else
  1254. # delete group entry
  1255. cp /etc/group /etc/group.bak && \
  1256. grep -v "^${grp}:" /etc/group.bak >/etc/group
  1257. fi
  1258. fi
  1259. done
  1260. # remove the startup/shutdown transfer ripts
  1261. name=`echo "$prefix" | sed -e 's;/;;g'`
  1262. if [ ".$cusr" != ".root" ]; then
  1263. echo "openpkg:WARNING: skipping deletion of system run-command hooks" 1>&2
  1264. echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
  1265. else
  1266. case "$plid" in
  1267. FreeBSD/* )
  1268. rm -f /etc/rc.d/${name}.sh >/dev/null 2>&1
  1269. ;;
  1270. NetBSD/* )
  1271. rm -f /etc/rc.d/${name} >/dev/null 2>&1
  1272. ;;
  1273. Linux/* )
  1274. # sroot: script root directory
  1275. # lroot: link root directory
  1276. if [ -f /etc/debian_version ]; then
  1277. sroot=/etc/init.d
  1278. lroot=/etc/rc%d.d
  1279. elif [ -f /etc/redhat-release -o -f /etc/mandrake-release ]; then
  1280. sroot=/etc/rc.d/init.d
  1281. lroot=/etc/rc.d/rc%d.d
  1282. else
  1283. echo "WARNING: you are not running one of the supported standard" 1>&2
  1284. echo "WARNING: Linux platforms (Debian, RedHat). We are trying" 1>&2
  1285. echo "WARNING: to guess the location of the system init scripts!" 1>&2
  1286. sroot=""
  1287. lroot=""
  1288. for sr in /etc/rc.d/init.d /etc/init.d /sbin/init.d; do
  1289. if [ -d $sr ]; then
  1290. sroot="$sr"
  1291. break
  1292. fi
  1293. done
  1294. for lr in /etc/rc.d/rc2.d /etc/rc2.d /sbin/init.d/rc2.d; do
  1295. if [ -d $lr ]; then
  1296. lroot="`echo $lr | sed -e 's;2;%d;'`"
  1297. break
  1298. fi
  1299. done
  1300. if [ ".$sroot" = . -o ".$lroot" = . ]; then
  1301. echo "ERROR: Failed to guess the location of the system init scripts!" 1>&2
  1302. exit 1
  1303. fi
  1304. fi
  1305. rm -f ${sroot}/${name} >/dev/null 2>&1
  1306. for i in 2 3 4 5; do
  1307. rm -f `echo $lroot | sed -e "s;%d;$i;"`/S99${name} >/dev/null 2>&1
  1308. done
  1309. for i in 0 1 6; do
  1310. rm -f `echo $lroot | sed -e "s;%d;$i;"`/K00${name} >/dev/null 2>&1
  1311. done
  1312. ;;
  1313. SunOS/5.* )
  1314. rm -f /etc/init.d/${name} >/dev/null 2>&1
  1315. rm -f /etc/rc3.d/S99${name} >/dev/null 2>&1
  1316. rm -f /etc/rc0.d/K00${name} >/dev/null 2>&1
  1317. rm -f /etc/rc1.d/K00${name} >/dev/null 2>&1
  1318. ;;
  1319. OSF1/V5.* )
  1320. rm -f /sbin/init.d/${name} >/dev/null 2>&1
  1321. rm -f /sbin/rc3.d/S99${name} >/dev/null 2>&1
  1322. rm -f /sbin/rc0.d/K00${name} >/dev/null 2>&1
  1323. ;;
  1324. HP-UX/* )
  1325. rm -f /sbin/init.d/${name} >/dev/null 2>&1
  1326. rm -f /etc/rc2.d/S900${name} >/dev/null 2>&1
  1327. rm -f /etc/rc1.d/K100${name} >/dev/null 2>&1
  1328. ;;
  1329. esac
  1330. fi
  1331. # remove the cron transfer entries
  1332. if [ ".$cusr" != ".root" ]; then
  1333. echo "openpkg:WARNING: skipping deletion of system cron hooks" 1>&2
  1334. echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
  1335. else
  1336. case "$plid" in
  1337. FreeBSD/* | Linux/* )
  1338. exists=`grep "<OpenPKG prefix=$prefix pkg=openpkg>" /etc/crontab`
  1339. if [ ".$exists" != . ]; then
  1340. p=`echo $prefix | sed -e 's;/;\\\\/;g'`
  1341. cp /etc/crontab /etc/crontab.bak
  1342. cat /etc/crontab.bak |\
  1343. sed -e "/<OpenPKG prefix=$p pkg=openpkg>/,/<\\/OpenPKG>/d" \
  1344. >/etc/crontab
  1345. fi
  1346. ;;
  1347. SunOS/5.* | OSF1/V5.* | NetBSD/* | HP-UX/* )
  1348. EDITOR=/tmp/vipw.$$
  1349. VISUAL="$EDITOR"
  1350. export EDITOR
  1351. export VISUAL
  1352. p=`echo $prefix | sed -e 's;/;\\\\\\\\/;g'`
  1353. ( echo "cp \$1 \$1.bak"
  1354. echo "cat \$1.bak | sed -e \"/<OpenPKG prefix=$p pkg=openpkg>/,/<\\\\/OpenPKG>/d\" >\$1"
  1355. echo "rm -f \$1.bak"
  1356. ) >$EDITOR
  1357. chmod a+x $EDITOR
  1358. (PATH="$PATH:/usr/bin"; crontab -e)
  1359. rm -f $EDITOR
  1360. ;;
  1361. esac
  1362. fi
  1363. # delayed removal of top-level directory.
  1364. ( sleep 10
  1365. rmdir %{l_prefix} >/dev/null 2>&1 || true
  1366. ) </dev/null >/dev/null 2>/dev/null &