RPMArchives=/media/cdrom/Fedora/RPMS
InstallRoot=/mnt/temp/fedora
-installpackages="bash coreutils yum"
+installpackages="filesystem basesystem coreutils yum redhat-release"
ourcachedirectory=$(mktemp -d)
architecture=$(uname -m)
export ARCH=$architecture
+case $architecture in
+ x86_64)
+ architecture="x86_64,i686,i586,i486,i386"
+ ;;
+ i686)
+ architecture="i686,i586,i486,i386"
+ ;;
+ i586)
+ architecture="i586,i486,i386"
+ ;;
+ i486)
+ architecture="i486,i386"
+ ;;
+esac
+
function displayHelp() {
cat <<END
Usage: $0 [options]
exit $1
}
+function startswithmm() {
+ if [ "${1##--*}" == "" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+function containsequals() {
+ if [ "${1//*=*}" == "" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
argcommand=""
for option in $@; do
- if [[ ! $option =~ ^-- ]]; then
+ if ( ! startswithmm $option ); then
if [ "x$argcommand" == "xinstall-root" ]; then
InstallRoot=$option
elif [ "x$argcommand" == "xrpm-archives" ]; then
fi
fi
else
- if [[ $option =~ [=] ]]; then
+ if ( containsequals $option ); then
argcommand=${option%%=*}
argcommand=${argcommand##--}
option=${option##*=}
function buildcache() {
cd $RPMArchives
- for file in *.{noarch,$architecture}.rpm; do
- rpm -qpl $file | sed 's#^#'$file':#' >> $ourcachedirectory/files-cache
- rpm -qp --provides $file | cut -d " " -f 1 | sed 's#^#'$file':#' >> $ourcachedirectory/package-cache
+ for arch in noarch $(echo $architecture | sed -e 's/,/\n/g'); do
+ for file in *.$arch.rpm; do
+ rpm -qpl $file | sed 's#^#'$file':#' >> $ourcachedirectory/files-cache
+ rpm -qp --provides $file | cut -d " " -f 1 | sed 's#^#'$file':#' >> $ourcachedirectory/package-cache
+ done
done
}
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)
+ packages="$(findrpm $package)"
+ echo rpm -r ${InstallRoot} --ignorearch --install "${packages}" >> $ourcachedirectory/install-log
+ echo "${packages}" >> $ourcachedirectory/packages-installed
+ cd ${RPMArchives} && rpm -r ${InstallRoot} --ignorearch --install ${packages}
fi
else
echo " Failed to find the RPM providing $package - skipping"
read -p "Remove cache directory ($ourcachedirectory)? [Yn]: " cleanup
-if [[ $cleanup =~ ^[Nn] ]]; then
+cleanup=${cleanup:0:1}
+
+if [ "$cleanup" == "N" ] || [ "$cleanup" == "n" ] ; then
echo leaving logs in $ourcachedirectory
else
echo removing logs directory