+ yumexclude_line=""
+ [ -n "$pkgs_yumexclude" ] && yumexclude_line="exclude=$pkgs_yumexclude"
+
+ echo "$0: candidate mirrors"
+ for mirror in $mirrors ; do
+ echo "* candidate mirror $mirror"
+ done
+
+ # the repo part of the final yum.conf
+ yum_conf_repos=$vroot/xxxmkfedora-repos.confxxx
+ if ! yumconf_mirrors $yum_conf_repos ../build/ $fcdistro "$yumexclude_line" $mirrors ; then
+ echo xxx -- error ; return 1
+ fi
+
+ # Do not tolerate errors
+ set -e
+
+ public_gpg_key=$(yumconf_gpgkey $yum_conf_repos)
+
+ ## make rpms ignore installing stuff to special fs entries like /proc
+ # Because of https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=52725
+ # you have to use at least one language beside 'C'
+ # Prevent all locales from being installed in reference image
+ mkdir -p $vroot/etc/rpm
+ pl_root_rpm_macros > $vroot/etc/rpm/macros
+
+ # Trick rpm and yum, who read the real root /etc/rpm/macros file
+ # rather than the one installed in the reference image, despite what
+ # you might expect the --root and --installroot options to mean. Both
+ # programs always read $HOME/.rpmmacros.
+ export HOME=$vroot/tmp
+ mkdir -p $vroot/tmp
+ pl_root_rpm_macros > $vroot/tmp/.rpmmacros
+
+ function mkfedora_cleanup () {
+ umount -l $vroot/proc
+ umount -l $vroot/dev/shm
+ umount -l $vroot/dev/pts
+ }
+
+ # Clean up before exiting if anything goes wrong
+ trap "mkfedora_cleanup" ERR INT
+
+ # Mount in reference image
+ mount -t devpts none $vroot/dev/pts
+ mount -t tmpfs none $vroot/dev/shm
+ mkdir -p $vroot/proc
+ mount -t proc none $vroot/proc
+
+ # Create a /var/lib dirs for yum & rpm
+ mkdir -p $vroot/var/lib/yum
+ mkdir -p $vroot/var/lib/rpm
+ mkdir -p $vroot/usr/share/info
+
+ # Create a dummy /etc/fstab in reference image
+ mkdir -p $vroot/etc
+ cat >$vroot/etc/fstab <<EOF
+# This fake fstab exists only to please df and linuxconf.
+/dev/hdv1 / ext2 defaults 1 1
+EOF
+ cp $vroot/etc/fstab $vroot/etc/mtab
+
+ # Necessary for some scripts
+ mkdir -p $vroot/etc/sysconfig
+ echo "NETWORKING=yes" > $vroot/etc/sysconfig/network
+
+ # Initialize RPM database in reference image
+ mkdir -p $vroot/var/lib/rpm
+ rpm --root $vroot --initdb
+ rpm --root $vroot --import $public_gpg_key
+
+ # Initialize yum in reference image
+ mkdir -p $vroot/var/cache/yum $vroot/var/log
+
+# yum.conf is for building only - store in different location than /etc/yum.conf
+ yum_conf=$vroot/etc/mkfedora-yum.conf
+ cat > $yum_conf <<EOF
+[main]
+cachedir=/var/cache/yum
+debuglevel=2
+logfile=/var/log/yum.log
+pkgpolicy=newest
+multilib_policy=best
+distroverpkg=redhat-release
+tolerant=1
+exactarch=1
+retries=20
+obsoletes=1
+gpgcheck=0
+# Prevent yum-2.4 from loading additional repository definitions
+# (e.g., from /etc/yum.repos.d/)
+reposdir=/dev/null
+EOF
+
+ cat $yum_conf_repos >> $yum_conf
+
+ # If we are being built as part of an automated RPM build, solve the
+ # bootstrap problem by including any just built packages in the yum
+ # configuration. This cooperates with the PlanetLab build system.
+ if [ -n "$RPM_BUILD_DIR" ] ; then
+ RPM_RPMS_DIR=$(cd $(dirname $RPM_BUILD_DIR)/RPMS && pwd -P)
+ # If run under sudo, allow user to delete the headers/ and
+ # repodata/ directories.
+ if [ -n "$SUDO_USER" ] ; then
+ chown -R $SUDO_USER $RPM_RPMS_DIR
+ fi
+ cat >> $yum_conf <<EOF
+
+[building]
+name=Building - $basearch - $RPM_RPMS_DIR/
+baseurl=file://$RPM_RPMS_DIR/
+EOF
+fi
+
+ echo "========== Dumping $yum_conf"
+ cat $yum_conf
+ echo "========== EndDump $yum_conf"
+
+ yum_options=""
+# yum --help | grep verbose &> /dev/null && yum_options="$yum_options --verbose"
+ yum_options="$yum_options -y"
+ yum_options="$yum_options -c $yum_conf"
+ yum_options="$yum_options --installroot=$vroot"
+ yum_options="$yum_options --releasever=$releasever"
+
+ # glibc must be specified explicitly for the correct arch to be
+ # chosen.
+ echo "* Installing glibc"
+ # ignore yum's return code that is basically undefined
+ yum $yum_options install glibc || :
+
+ # Go, baby, go
+ if [ -n "$pkgs_packages" ] ; then
+ echo "* Installing optional packages" $pkgs_packages
+ # ignore yum's return code that is basically undefined
+ echo "* Install options" $vroot $yum_options
+ yum $yum_options install $pkgs_packages || :
+ if ! rpm --root $vroot -q $pkgs_packages >/dev/null ; then
+ echo "* Warning: Missing packages"
+ rpm --root $vroot -q $pkgs_packages | grep "not installed"
+ fi
+ fi
+
+ if [ -n "$pkgs_groups" ] ; then
+ ## call yum sequentially to get finer-grained info on dependencies
+ for group_plus in $pkgs_groups ; do
+ group=$(echo $group_plus | sed -e "s,+++, ,g")
+ echo "* Installing optional group $group"
+ # ignore yum's return code that is basically undefined
+ yum $yum_options groupinstall "$group" || :
+ done
+ fi
+
+ # formerly in bootcd/prep.sh : to optimize footprint
+ if [ -n "$pkgs_junk" ] ; then
+ echo "* Removing unnecessary junk"
+ pushd $vroot
+ # Save precious files
+ [ -n "$pkgs_precious" ] && tar --ignore-failed-read -cpf precious.tar $pkgs_precious
+ # Remove unnecessary junk
+ [ -n "$pkgs_junk" ] && rm -rf $pkgs_junk
+ # Restore precious files
+ [ -n "$pkgs_precious" ] && tar -xpf precious.tar && rm -f precious.tar
+ popd
+ fi
+
+ # Clean yum cache
+ echo "* Cleaning up"
+
+# # NOTE: this hack is for Fedora >= 12.
+# # if kernel-debug is installed, clean it up
+# # kernel-debug manually
+# # we link to our version of kernel/initrd and clean up
+# if rpm --root $vroot --quiet -q kernel-debug ; then
+# echo "* Cleaning up kernel-debug - (workaround for f12)"
+# pushd $vroot/boot/
+# rm -rf kernel-boot kernel-bootsmp initrd-boot initrd-bootsmp
+# ln -s vmlinuz-*${pldistro}* kernel-boot
+# ln -s vmlinuz-*${pldistro}* kernel-bootsmp
+# ln -s initrd-*${pldistro}* initrd-boot
+# ln -s initrd-*${pldistro}* initrd-bootsmp
+# rpm --root $vroot --nodeps -e kernel-debug || :
+# popd
+# fi
+
+ # ignore yum's return code that is basically undefined
+ yum $yum_options clean all || :
+
+ # Clean RPM state
+ rm -f $vroot/var/lib/rpm/__db*
+
+ # Set time zone to UTC
+ if [ -f $vroot/usr/share/zoneinfo/UTC -a -f $vroot/etc/localtime ] ; then
+ rm -f $vroot/etc/localtime
+ ln -s /usr/share/zoneinfo/UTC $vroot/etc/localtime
+ fi
+
+ echo "Dumping current list of rpms in /etc/mkfedora-rpms.txt"
+ chroot $vroot rpm -aq | sort > $vroot/etc/mkfedora-rpms.txt
+
+ # remove trap handler, as we are about to call it directly.
+ trap - ERR INT
+
+ # Clean up
+ mkfedora_cleanup
+
+ return 0