# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-set -f
+# Default to expecting a Fedora CD mounted at /media/cdrom
+# and installing bash, coreutils and yum to /mnt/temp/fedora
RPMArchives=/media/cdrom/Fedora/RPMS
InstallRoot=/mnt/temp/fedora
architecture=$(uname -m)
export ARCH=$architecture
+function displayHelp() {
+cat <<END
+Usage: $0 [options]
+
+Options:
+ --install-root <directorytoinstallto>
+ --rpm-archives <pathtorpms>
+ --install-packages <listofpackagestoinstall>
+END
+ exit $1
+}
+
+argcommand=""
+for option in $@; do
+ if [[ ! $option =~ ^-- ]]; then
+ if [ "x$argcommand" == "xinstall-root" ]; then
+ InstallRoot=$option
+ elif [ "x$argcommand" == "xrpm-archives" ]; then
+ RPMArchives=$option
+ elif [ "x$argcommand" == "xinstall-packages" ]; then
+ if [ "x$installpackages" == "x" ]; then
+ installpackages=$option
+ else
+ installpackages="$installpackages $option"
+ fi
+ fi
+ else
+ if [[ $option =~ [=] ]]; then
+ argcommand=${option%%=*}
+ argcommand=${argcommand##--}
+ option=${option##*=}
+
+ if [ "x$argcommand" == "xinstall-root" ]; then
+ InstallRoot=$option
+ elif [ "x$argcommand" == "xrpm-archives" ]; then
+ RPMArchives=$option
+ elif [ "x$argcommand" == "xinstall-packages" ]; then
+ installpackages=$option
+ else
+ echo "Unknown option $option"
+ exit 1
+ fi
+ else
+ if [ "x$option" == "x--help" ]; then
+ displayHelp 0
+ elif [ "x$option" == "x--install-root" ]; then
+ argcommand=${option##--}
+ elif [ "x$option" == "x--rpm-archives" ]; then
+ argcommand=${option##--}
+ elif [ "x$option" == "x--install-packages" ]; then
+ argcommand=${option##--}
+ installpackages=""
+ else
+ echo "Unknown option $option"
+ exit 1
+ fi
+ fi
+ fi
+done
+
+echo "Install Packages: $installpackages"
+echo "RPMArchives : $RPMArchives"
+echo "InstallRoot : $InstallRoot"
+
function buildcache() {
cd $RPMArchives
for file in *.{noarch,$architecture}.rpm; do
- rpm -qpl $file | sed 's#^#'$file':#' >> $ourcachedirectory/fedora-files-cache
- rpm -qp --provides $file | cut -d " " -f 1 | sed 's#^#'$file':#' >> $ourcachedirectory/fedora-package-cache
+ rpm -qpl $file | sed 's#^#'$file':#' >> $ourcachedirectory/files-cache
+ rpm -qp --provides $file | cut -d " " -f 1 | sed 's#^#'$file':#' >> $ourcachedirectory/package-cache
done
}
escapename=$(echo $name | sed -e 's#\+#\\+#g; s#\.#\\.#g; s#(#\\(#g; s#)#\\)#g;')
if [ ${name:0:1} == "/" ]; then
- grep -E "^.*:$escapename\$" $ourcachedirectory/fedora-files-cache | cut -d ":" -f 1 | head -n 1
+ grep -E "^.*:$escapename\$" $ourcachedirectory/files-cache | cut -d ":" -f 1 | head -n 1
else
- grep -E "^.*:$escapename\$" $ourcachedirectory/fedora-package-cache | cut -d ":" -f 1 | head -n 1
+ grep -E "^.*:$escapename\$" $ourcachedirectory/package-cache | cut -d ":" -f 1 | head -n 1
fi
}
fname=$(findrpm $line)
packagename=$(getpackagename $fname)
if [ ! -z $name ] && [ ! -z $packagename ]; then
- if ( ! grep '^'$fname' ' $ourcachedirectory/buildfedora-packagelist > /dev/null ) && ( ! rpm -r ${InstallRoot} -qv $packagename > /dev/null ); then
- echo $fname $packagename >> $ourcachedirectory/buildfedora-packagelist
- getdependencies $fname $packagename
+ if [[ $firstpackage == 0 ]]; then
+ if ( ! grep '^'$fname' ' $ourcachedirectory/build-packagelist > /dev/null ) && ( ! rpm -r ${InstallRoot} -qv $packagename > /dev/null ); then
+ echo $fname $packagename >> $ourcachedirectory/build-packagelist
+ getdependencies $fname $packagename
+ fi
+ else
+ if ( ! grep '^'$fname' ' $ourcachedirectory/build-packagelist > /dev/null ); then
+ echo $fname $packagename >> $ourcachedirectory/build-packagelist
+ getdependencies $fname $packagename
+ fi
fi
fi
fi
rpm -r ${InstallRoot} --initdb
-# install setup and filesystem
-
-echo $(findrpm setup)
-echo $(findrpm filesystem)
-
-rpm -r ${InstallRoot} --ignorearch --install ${RPMArchives}/$(findrpm setup)
-echo rpm -r ${InstallRoot} --ignorearch --install ${RPMArchives}/$(findrpm setup) >> $ourcachedirectory/install-log
-rpm -r ${InstallRoot} --ignorearch --install ${RPMArchives}/$(findrpm filesystem)
-echo rpm -r ${InstallRoot} --ignorearch --install ${RPMArchives}/$(findrpm filesystem) >> $ourcachedirectory/install-log
+firstpackage=1
for package in $installpackages; do
- rm -f ~/.buildfedora-packagelist
- touch ~/.buildfedora-packagelist
+
+ rm -f $ourcachedirectory/build-packagelist
+ touch $ourcachedirectory/build-packagelist
echo "Installing packages required for $package"
-
- getdependencies $(findrpm $package) $package
-
- echo rpm -r ${InstallRoot} --ignorearch --install $(cat ~/.buildfedora-packagelist | cut -d ' ' -f 1) >> ~/.fedora-install-log
- cd ${RPMArchives} && rpm -r ${InstallRoot} --ignorearch --install $(cat ~/.buildfedora-packagelist | cut -d ' ' -f 1)
- if ( ! grep " $package\$" ~/.buildfedora-packagelist > /dev/null 2>/dev/null ); then
- echo rpm -r ${InstallRoot} --ignorearch --install $(findrpm $package) >> $ourcachedirectory/install-log
- cd ${RPMArchives} && rpm -r ${InstallRoot} --ignorearch --install $(findrpm $package)
+ if [[ "x$(findrpm $package)" != "x" ]]; then
+
+ getdependencies $(findrpm $package) $package
+ echo " RPM File :" $(findrpm $package)
+ echo " Dependencies:"
+ cat $ourcachedirectory/build-packagelist | cut -d ' ' -f 2 | sed -e 's#^# #;'
+
+ echo rpm -r ${InstallRoot} --ignorearch --install $(cat $ourcachedirectory/build-packagelist | cut -d ' ' -f 1) >> $ourcachedirectory/install-log
+
+ firstpackage=0
+
+ cd ${RPMArchives} && rpm -r ${InstallRoot} --ignorearch --install $(cat $ourcachedirectory/build-packagelist | cut -d ' ' -f 1)
+ if ( ! grep " $package\$" $ourcachedirectory/build-packagelist > /dev/null 2>/dev/null ); then
+ echo rpm -r ${InstallRoot} --ignorearch --install $(findrpm $package) >> $ourcachedirectory/install-log
+ cd ${RPMArchives} && rpm -r ${InstallRoot} --ignorearch --install $(findrpm $package)
+ fi
+ else
+ echo " Failed to find the RPM providing $package - skipping"
fi
done