home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / boot / i386 / rescue / usr / lib / rpm / trpm < prev    next >
Text File  |  2006-11-29  |  6KB  |  334 lines

  1. #!/bin/sh
  2.  
  3. ulimit -S -c unlimited
  4. dbg=    # echo
  5.  
  6. rpm=/bin/rpm
  7. #rpm=/X/src/rpm/rpm
  8. #rpmi=mrpm
  9. #rpmi="strace -o xxx /bin/rpm"
  10. rpmi="$rpm"
  11. #rpmi=/usr/lib/rpm/rpmi
  12. rpmb=/usr/bin/rpmbuild
  13. rpmq=/usr/bin/rpmquery
  14. rpmdb=/usr/bin/rpmdb
  15. rpmk=/usr/bin/rpmsign
  16.  
  17. pgppubkey="`echo /usr/share/doc/rpm-4*/RPM-PGP-KEY`"
  18. gpgpubkey="`echo /usr/share/doc/rpm-4*/RPM-GPG-KEY`"
  19. betapubkey="`echo /usr/share/doc/rpm-4*/BETA-GPG-KEY`"
  20.  
  21. #rpm=/X/src/rpm402/rpm
  22. #rpmb=/X/src/rpm402/rpmb
  23. #rpmq=/X/src/rpm402/rpmq
  24. #rpmdb=/X/src/rpm402/rpmdb
  25.  
  26. #rpm=/X/src/rpm307/rpm
  27. #rpmb=$rpm
  28. #rpmq=$rpm
  29. #rpmdb=$rpm
  30.  
  31. dist=8.0
  32. type=min
  33. arch=`$rpm --eval '%{_arch}' | sed -e 's/i686/i386/'`
  34.  
  35. top=`pwd`
  36. root=$top/$dist
  37. sudo=sudo
  38. justdb="--justdb --noscripts --notriggers --ignoresize"
  39. dmopts="-l dmalloc.log -i 100 low"
  40. db1=
  41. rc="--rcfile $top/rpmrc-$dist"
  42. sorted=    # "| sort"
  43.  
  44. min0glob="
  45. basesystem-
  46. bash-[12]
  47. filesystem-
  48. glibc-common-
  49. glibc-2
  50. ldconfig-
  51. libtermcap-2
  52. mktemp-
  53. setup-
  54. termcap-
  55. "
  56.  
  57. min1glob="
  58. $min0glob
  59. bzip2-[01]
  60. bzip2-libs-
  61. chkconfig-
  62. coreutils-
  63. db1-1
  64. db2-2
  65. db3-3
  66. db4-4
  67. dev-
  68. diffutils-
  69. e2fsprogs-1
  70. fileutils-
  71. findutils-
  72. gawk-
  73. gdb-
  74. gdbm-1
  75. grep-
  76. gzip-
  77. info-
  78. less-
  79. libacl-2
  80. libattr-2
  81. mount-
  82. ncurses-[45]
  83. pcre-
  84. procps-2
  85. psmisc-
  86. sed-
  87. shadow-utils-
  88. readline-[24]
  89. rmt-
  90. tar-
  91. textutils-
  92. vim-common-
  93. vim-minimal-
  94. zlib-1
  95. "
  96.  
  97. min2glob="
  98. $min1glob
  99. cpio-
  100. cracklib-
  101. glib-1
  102. logrotate-
  103. mingetty-
  104. popt-
  105. pwdb-
  106. slang-[01]
  107. which-
  108. words-
  109. "
  110.  
  111. baseglob="
  112. $min2glob
  113. ash-
  114. bdflush-
  115. console-tools-
  116. cyrus-sasl-[12]
  117. cyrus-sasl-md5-
  118. elfutils-libelf-
  119. glib2-2
  120. gmp-[234]
  121. initscripts-
  122. iputils-
  123. iproute-
  124. kbd-
  125. kernel-2
  126. krb5-libs-
  127. libuser-
  128. libelf-*
  129. losetup-
  130. lvm-
  131. mkinitrd-
  132. modutils-
  133. net-tools-
  134. openldap-2
  135. openssl-0
  136. pam-0
  137. pamconfig-
  138. redhat-release-
  139. sh-utils-
  140. sysklogd-
  141. usermode-1
  142. util-linux-
  143. vixie-cron-
  144. rpm-[34]
  145. rpm-devel-[34]
  146. sash-
  147. SysVinit-
  148. "
  149.  
  150. develglob="
  151. $baseglob
  152. bzip2-devel-
  153. db1-devel-
  154. db2-devel-
  155. db3-devel-
  156. db4-devel-
  157. gdbm-devel-
  158. glibc-devel-
  159. glibc-kernheaders-
  160. gmp-devel-
  161. kernel-headers-
  162. readline-devel-[24]
  163. tcl-
  164. zlib-devel-
  165. "
  166.  
  167. buildglob="
  168. $develglob
  169. autoconf-
  170. automake-
  171. bash2-
  172. binutils-
  173. cpp-
  174. cvs-
  175. db3-utils-
  176. db4-utils-
  177. egcs-1
  178. egcs-c++-1
  179. expat-1
  180. gcc-[23]
  181. gcc-c++-[23]
  182. gettext-
  183. krb5-configs-
  184. libgcc-3
  185. libgcj-3
  186. libstdc++-
  187. libtool-
  188. make-
  189. m4-
  190. ncurses-devel-
  191. patch-
  192. perl-5
  193. perl-CGI-
  194. perl-Filter-
  195. perl-Parse-RecDescent-
  196. python-[12]
  197. rpm-build-
  198. file-3
  199. tcsh-
  200. zip-
  201. "
  202.  
  203. mozillaglob="
  204. $buildglob
  205. compat-libstdc++-7
  206. curl-
  207. fontconfig-2
  208. freetype-2
  209. gtk+-1
  210. indexhtml-
  211. libao-0
  212. libjpeg-
  213. libpng-
  214. libogg-
  215. libvorbis-
  216. mozilla-
  217. ORBit-0
  218. redhat-menus-
  219. vorbis-tools-
  220. XFree86-Mesa-libGL-
  221. XFree86-libs-[34]
  222. XFree86-libs-data-
  223. "
  224.  
  225. classes="min0 min1 min2 base devel build mozilla"
  226. notallpat="(kernel-[^2h])"
  227.  
  228. for cmd in $*
  229. do
  230.     [ $# -eq 0 ] && break
  231.     shift
  232.     echo "******** args: $*"
  233.     echo "=======> start $cmd    `date`"
  234.     case $cmd in
  235.     debug)        dbg=echo    ;;
  236.     dmalloc)        eval `dmalloc -b $dmopts`    ;;
  237.     db1)        db1="--define '%_dbapi 1'"    ;;
  238.     5.2|6.2|7.*|8.*)
  239.     dist=$cmd
  240.     root=$top/$dist
  241.     rc="--rcfile $top/rpmrc-$dist $db1"
  242.     $dbg mkdir -p $root/{dev,X/RPMS,X/SRPMS}
  243.     [ -c $root/dev/null ] || $dbg $sudo mknod $root/dev/null c 1 3
  244.     [ -f $top/rpmrc-$dist ] || cat << EOF > $top/rpmrc-$dist
  245. include:    /usr/lib/rpm/rpmrc
  246. macrofiles: /usr/lib/rpm/macros:/usr/lib/rpm/%{_target}/macros:$top/macros:$top/macros-$dist-$arch
  247. EOF
  248.     [ -f $top/macros-$dist-$arch ] || cat << EOF > $top/macros-$dist-$arch
  249. %_topdir    $root/X
  250. EOF
  251.     ;;
  252.     config)
  253.     [ -f $top/macros ] || cat << EOF > $top/macros
  254. %_ntopdir    %{_topdir}/%{name}-%{version}-%{release}
  255. %_builddir    %{_ntopdir}
  256. %_sourcedir    %{_ntopdir}
  257. %_specdir    %{_ntopdir}
  258. %_rpmfilename    %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm
  259. %_rpmdir    %{_topdir}/RPMS
  260. %_srcrpmdir    %{_topdir}/SRPMS
  261. EOF
  262.     ;;
  263.     manifest)
  264.     rm -f *-$dist-$arch
  265.     pkgs="/$dist/$arch"
  266.      ls -1 ${pkgs}/*.rpm | egrep "(noarch|$arch).rpm" > list-$dist-$arch
  267.     cat list-$dist-$arch | egrep -v $notallpat > all-$dist-$arch
  268.     $dbg $rpmq $rc -qp --qf "/$dist/SRPMS/%{sourcerpm}\\n" \
  269. `cat all-$dist-$arch` | sort | uniq > all-$dist-$arch-srpms
  270.     for l in $classes ; do
  271.         glv='$'${l}glob
  272.         glist="`eval echo $glv`"
  273.         for g in $glist ; do
  274.         ls -1 ${pkgs}/${g}*.rpm 2> /dev/null
  275.         done | egrep "(noarch|$arch).rpm" $sorted > $l-$dist-$arch
  276.         $dbg $rpmq $rc -qp --qf "/$dist/SRPMS/%{sourcerpm}\\n" \
  277. `cat $l-$dist-$arch` | sort | uniq > $l-$dist-$arch-srpms
  278.     done
  279.     ;;
  280.     clean)
  281.     $dbg rm -f $top/{rpmrc-$dist,macros-$dist-$arch,macros}
  282.     $dbg $sudo mv $root ${root}-$$ && $dbg $sudo rm -rf ${root}-$$
  283.     ;;
  284.     --rebuild)
  285.     for srpm in `cat $type-$dist-$arch-srpms` ; do
  286.         $dbg $rpmb $rc $cmd $srpm
  287.     done
  288.     ;;
  289.     --initdb)
  290.     $dbg $sudo mkdir -p $root/var/lib/rpm
  291.     $dbg $sudo mkdir -p $root/etc
  292.     $dbg $sudo touch $root/etc/fstab
  293.     $dbg $sudo touch $root/etc/mtab
  294.     $dbg $sudo $rpmdb $rc --root $root --initdb
  295.     if [ X"`$rpm --version`" = X"RPM version 4.2" ]; then
  296.         $dbg $sudo $rpmk $rc --root $root --import $pgppubkey
  297.         $dbg $sudo $rpmk $rc --root $root --import $gpgpubkey
  298.         $dbg $sudo $rpmk $rc --root $root --import $betapubkey
  299.     fi
  300.     ;;
  301.     --savedb)
  302.     ( $dbg cd $root/var/lib && $dbg $sudo tar czvf rpmdb.tar.gz rpm ; )
  303.     ;;
  304.     --rebuilddb)
  305.     $dbg $sudo $rpmdb $rc --root $root --rebuilddb -vv
  306.     ;;
  307.     --justdb)
  308.     [ -f $type-$dist-$arch ] || {
  309.         echo $type-$dist-$arch not found
  310.         exit 1
  311.     }
  312.     $dbg $sudo $rpmi $rc --root $root -Uv $justdb `cat $type-$dist-$arch`
  313.     ;;
  314.     -U*|-F*)
  315.     [ -f $type-$dist-$arch ] || {
  316.         echo $type-$dist-$arch not found
  317.         exit 1
  318.     }
  319.     $dbg $sudo $rpmi $rc --root $root $cmd $* `cat $type-$dist-$arch`
  320.     set ""
  321.     ;;
  322.     -[Vqei]*|--showrc)
  323.     $dbg $sudo $rpm $rc --root $root $cmd
  324.     ;;
  325.     chroot)
  326.     $dbg $sudo touch $root/etc/mtab
  327.     $dbg $sudo cp /etc/resolv.conf /etc/fstab $root/etc
  328.     $dbg $sudo env HOME=/root chroot $root
  329.     ;;
  330.     *)        type=$cmd    ;;
  331.     esac
  332. done
  333. echo "=======> finish    `date`"
  334.