projects
/
rpmbased-dist-chroot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Slightly updated, deal with x86_64 and fix bug in arch handling
[rpmbased-dist-chroot.git]
/
rpmbased-dist-chroot.sh
diff --git
a/rpmbased-dist-chroot.sh
b/rpmbased-dist-chroot.sh
index 5aaf4eaef76cb4e11afda41fbdd6610f7e265bb4..2349b2e6a67dff734f319b5e4ca66eb936af9da3 100755
(executable)
--- a/
rpmbased-dist-chroot.sh
+++ b/
rpmbased-dist-chroot.sh
@@
-24,13
+24,28
@@
RPMArchives=/media/cdrom/Fedora/RPMS
InstallRoot=/mnt/temp/fedora
RPMArchives=/media/cdrom/Fedora/RPMS
InstallRoot=/mnt/temp/fedora
-installpackages="bash coreutils yum"
+installpackages="bash coreutils yum
basesystem redhat-release
"
ourcachedirectory=$(mktemp -d)
architecture=$(uname -m)
export ARCH=$architecture
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]
function displayHelp() {
cat <<END
Usage: $0 [options]
@@
-43,9
+58,25
@@
END
exit $1
}
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
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
if [ "x$argcommand" == "xinstall-root" ]; then
InstallRoot=$option
elif [ "x$argcommand" == "xrpm-archives" ]; then
@@
-58,7
+89,7
@@
for option in $@; do
fi
fi
else
fi
fi
else
- if
[[ $option =~ [=] ]]
; then
+ if
( containsequals $option )
; then
argcommand=${option%%=*}
argcommand=${argcommand##--}
option=${option##*=}
argcommand=${option%%=*}
argcommand=${argcommand##--}
option=${option##*=}
@@
-98,9
+129,11
@@
echo "InstallRoot : $InstallRoot"
function buildcache() {
cd $RPMArchives
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
}
done
}
@@
-188,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
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"
fi
else
echo " Failed to find the RPM providing $package - skipping"
@@
-198,7
+233,9
@@
done
read -p "Remove cache directory ($ourcachedirectory)? [Yn]: " cleanup
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
echo leaving logs in $ourcachedirectory
else
echo removing logs directory