-# Get the URL for the production /etc/yum.conf file. XXX When MAs
-# begin deploying their own boot servers and/or code, this will have
-# to change.
-YUM_CONF=http://boot.planet-lab.org/$(curl --silent --insecure --form node_id=0 --form file=/etc/yum.conf https://boot.planet-lab.org/db/plnodeconf/getsinglefile.php)
+# Get the production /etc/yum.conf file. XXX When MAs begin deploying
+# their own boot servers and/or code, this will have to change.
+curl --silent http://boot.planet-lab.org/$(curl --silent --insecure --form node_id=0 --form file=/etc/yum.conf https://boot.planet-lab.org/db/plnodeconf/getsinglefile.php) > yum.conf
+
+# 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
+ # Remove any [PlanetLab*] sections
+ sed -i -f - yum.conf <<EOF
+# Match lines between [PlanetLab*] and the next [*
+/\[PlanetLab.*\]/I,/^\[/{
+# Delete [PlanetLab*]
+/\[PlanetLab.*\]/Id
+# Done when we see [*
+/^\[/b
+# Otherwise delete
+d
+}
+EOF
+
+ # And replace them with a section for the RPMS that were just built
+ cat >> yum.conf <<EOF
+[Bootstrap]
+name=Bootstrap RPMS -- $(dirname $RPM_BUILD_DIR)/RPMS/
+baseurl=file://$(dirname $RPM_BUILD_DIR)/RPMS/
+EOF
+fi