2 # Bootstrap for: RawHide
5 # http://cvs.jankratochvil.net/viewcvs/nethome/src/rawhide-bootstrap?rev=HEAD
8 RPMS_URL_BASE=http://armstrong.rhts.boston.redhat.com/distros/rawhide-`uname -i`
9 wget -q -O - $RPMS_URL_BASE/GPL >/dev/null || \
10 RPMS_URL_BASE=http://sunsite.mff.cuni.cz/pub/fedora/development/`uname -i`/os
13 if test $# != 1;then echo >&2 "Syntax: $0 <target-root-directory(DELETED!)>";exit 1;fi
15 if test "${ROOT#/}" = "$ROOT";then echo >&2 "Absolute pathname required: $ROOT";exit 1;fi
23 set +x;pkgs="`set -x;wget -q -O - $RPMS_URL_BASE/Fedora/RPMS/ | sed -n 's/^.*<a href="\([^/?][^/]*\)">.*$/\1/p'`";set -x
26 for arch in `uname -m` `uname -i` noarch;do
27 r="`set +x;echo "$pkgs"|(set +e;grep -P '^\Q'"$1"'\E-[^-]+-[^-]+'".$arch.rpm"'$')`"
28 if [ `echo "$r"|wc -l` -ge 2 ];then break;fi
30 echo "$RPMS_URL_BASE/Fedora/RPMS/$r"
39 KEY=/tmp/fedora-bootstrap-$$-key
41 trap 'rm -f $KEY' EXIT
44 # wget(1) due to: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=167483
45 wget -q -O - `pkg fedora-release` >/dev/null
46 wget -q -O - `pkg fedora-release` | rpm2cpio | cpio -id
49 mkdir -p $ROOT/{etc,dev,var/log,sys}
50 cp -p /etc/resolv.conf $ROOT/etc
51 awk '/^[ \t]*[^#]/ { if ($2 == "/" || $2 == "/sys" || $2 == "/proc") { print; }}' </etc/fstab >$ROOT/etc/fstab
52 if grep -q '^LABEL=' $ROOT/etc/fstab;then
53 awk <$ROOT/etc/fstab >$ROOT/etc/fstab2 '{ if ($2 == "/") $1="/dev/root"; }{ print; }'
54 mv -f $ROOT/etc/fstab2 $ROOT/etc/fstab
56 echo 'none /selinux selinuxfs defaults 0 0' >>$ROOT/etc/fstab
57 cp -a /dev/{null,urandom,random} `awk '/^[ \t]*[^#]/ { if ($2 == "/") { print $1; }}' <$ROOT/etc/fstab` $ROOT/dev/
58 touch $ROOT/{etc/mtab,var/log/lastlog}
59 mount -tsysfs sysfs $ROOT/sys
60 rpm --root=$ROOT --initdb
61 rpm --root=$ROOT --import $KEY/etc/pki/rpm-gpg/RPM-GPG-KEY*
64 # For rpm(1) http:// downloads:
65 mkdir -p $ROOT/var/tmp
67 while read -r key val;do
68 if test -n "$val";then RPM="$RPM $key $val";fi
70 --httpproxy `echo $http_proxy|sed -n 's#^[^/]*//\([^:/]*\).*$#\1#p'`
71 --httpport `echo $http_proxy|sed -n 's#^[^/]*//[^:/]*:\([^/]*\).*$#\1#p'`
72 --ftpproxy `echo $ftp_proxy|sed -n 's#^[^/]*//\([^:/]*\).*$#\1#p'`
73 --ftpport `echo $ftp_proxy|sed -n 's#^[^/]*//[^:/]*:\([^/]*\).*$#\1#p'`
76 # Workaround coreutils: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=199840
78 cp -p /bin/{cat,rm} $ROOT/bin/
81 # matchpathcon(/var/log/lastlog) failed: No such file or directory
82 # error: %post(util-linux-2.13-0.33.x86_64) scriptlet failed, exit status 1
83 ln -s true $ROOT/bin/chcon
85 # update package: V:!grep ^`sed 's/-[^-]*-[^-]*$//'`'-[^-]*-[^-]*$' /tmp/43<cr>j
88 DOWNLOAD=/tmp/fedora-bootstrap-$$-download
90 trap 'rm -rf $DOWNLOAD $KEY' EXIT
93 wget `set +x;while read -r line;do pkg $line;done <<EOH
178 mkdir -p $ROOT/var/lock/rpm
179 mkdir -p $ROOT/{proc,selinux}
180 mount -n -t proc none $ROOT/proc
181 mount -n -t selinuxfs none $ROOT/selinux
182 $RPM --root=$ROOT -i *
189 chroot $ROOT /bin/rpm --rebuilddb
191 # Do not install yum(8) just by 'rpm --root', later --rebuilddb would:
192 # rpmdb: Program version 4.2 doesn't match environment version
193 # FIXME: Analyse and bugreport:
194 # On "http" installation AND using --httpproxy: CentOS-4.1 rpm-4.3.3-9_nonptl would crash:
195 # warning: package yum = 2.2.1-1.centos4 was already added, replacing with yum <= 2.2.1-1.centos4
197 # error: Failed dependencies:
198 # /usr/bin/python is needed by yum-2.2.1-1.centos4.noarch
200 # while with FC4 rpm-4.4.1-22 it would work fine (it would just corrupt 'rpmdb' here).
217 chroot $ROOT /usr/bin/wget `set +x;for line in $lines;do pkg $line;done`
218 chroot $ROOT /bin/rpm -i `set +x;for line in $lines;do basename $(pkg $line);done`
219 chroot $ROOT /bin/rm -f `set +x;for line in $lines;do basename $(pkg $line);done`
221 for repo in $ROOT/etc/yum.repos.d/*.repo;do
222 mv -f $repo $repo-orig
223 sed -e 's/^mirrorlist=/#&/' -e 's/^#\(baseurl=\)/\1/' \
224 -e 's#^\(baseurl=\)http://download.fedora.redhat.com/pub/fedora/linux/core/development/$basearch/os/$#\1'"$RPMS_URL_BASE"'#' \
228 chroot $ROOT mount /proc
229 chroot $ROOT /usr/bin/yum -y update
231 # For: kernel-2.6.9-11.EL.src.rpm
232 chroot $ROOT /usr/bin/yum -y install `cat <<EOH