Slightly updated, deal with x86_64 and fix bug in arch handling
authorBrett Parker <iDunno@sommitrealweird.co.uk>
Tue, 11 Nov 2014 15:02:33 +0000 (15:02 +0000)
committerBrett Parker <iDunno@sommitrealweird.co.uk>
Tue, 11 Nov 2014 15:02:33 +0000 (15:02 +0000)
rpmbased-dist-chroot.sh

index 7fd9a19..2349b2e 100755 (executable)
@@ -24,7 +24,7 @@
 
 RPMArchives=/media/cdrom/Fedora/RPMS
 InstallRoot=/mnt/temp/fedora
-installpackages="bash coreutils yum"
+installpackages="bash coreutils yum basesystem redhat-release"
 
 ourcachedirectory=$(mktemp -d)
 
@@ -32,6 +32,9 @@ architecture=$(uname -m)
 export ARCH=$architecture
 
 case $architecture in
+       x86_64)
+               architecture="x86_64,i686,i586,i486,i386"
+               ;;
        i686)
                architecture="i686,i586,i486,i386"
                ;;
@@ -126,9 +129,11 @@ echo "InstallRoot     : $InstallRoot"
 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
 }
 
@@ -216,8 +221,10 @@ for package in $installpackages; do
                
                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"