openpkg.spec 57 KB

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