openpkg.spec 57 KB

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