sdcard-write: tab -> space
Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
This commit is contained in:
@@ -8,144 +8,139 @@
|
||||
# select card device a dialog based GUI is used.
|
||||
|
||||
SelectKernel() {
|
||||
# OE environment found?
|
||||
if [ -z $BUILDDIR ]; then
|
||||
echo "The environment variable BUILDDIR is not set. It is usually set before running bitbake."
|
||||
exit 1
|
||||
fi
|
||||
iCount=0
|
||||
strSelection=
|
||||
for grep_result in `grep -h TMPDIR $BUILDDIR/conf/*.conf | sed -e s/' '/''/g -e s/'\"'/''/g`; do
|
||||
# exclude comments
|
||||
tmp_dir=`echo $grep_result | grep '^TMPDIR='`
|
||||
if [ ! -z $tmp_dir ]; then
|
||||
TMPDIR=`echo $tmp_dir | sed -e s/'TMPDIR='/''/g`
|
||||
fi
|
||||
done
|
||||
for BuildPath in ${TMPDIR}-*; do
|
||||
# Find avaliable kernels
|
||||
for i in `find ${BuildPath}/deploy/images/${MACHINE} -name ${KERNEL_IMAGE_TYPE}-abiversion-* | sort` ; do
|
||||
iCount=`expr $iCount + 1`
|
||||
KernelNameArr[${iCount}]=$i
|
||||
strSelection="$strSelection $iCount "`basename $i`
|
||||
done
|
||||
done
|
||||
# OE environment found?
|
||||
if [ -z $BUILDDIR ]; then
|
||||
echo "The environment variable BUILDDIR is not set. It is usually set before running bitbake."
|
||||
exit 1
|
||||
fi
|
||||
iCount=0
|
||||
strSelection=
|
||||
for grep_result in `grep -h TMPDIR $BUILDDIR/conf/*.conf | sed -e s/' '/''/g -e s/'\"'/''/g`; do
|
||||
# exclude comments
|
||||
tmp_dir=`echo $grep_result | grep '^TMPDIR='`
|
||||
if [ ! -z $tmp_dir ]; then
|
||||
TMPDIR=`echo $tmp_dir | sed -e s/'TMPDIR='/''/g`
|
||||
fi
|
||||
done
|
||||
for BuildPath in ${TMPDIR}-*; do
|
||||
# Find avaliable kernels
|
||||
for i in `find ${BuildPath}/deploy/images/${MACHINE} -name ${KERNEL_IMAGE_TYPE}-abiversion-* | sort` ; do
|
||||
iCount=`expr $iCount + 1`
|
||||
KernelNameArr[${iCount}]=$i
|
||||
strSelection="$strSelection $iCount "`basename $i`
|
||||
done
|
||||
done
|
||||
|
||||
# were files found?
|
||||
if [ $iCount -eq 0 ]; then
|
||||
echo "No kernel images found in ${TMPDIR}-\*"
|
||||
exit 1
|
||||
fi
|
||||
# were files found?
|
||||
if [ $iCount -eq 0 ]; then
|
||||
echo "No kernel images found in ${TMPDIR}-\*"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dialog --title 'Select kernel'\
|
||||
--menu 'Move using [UP] [DOWN],[Enter] to select' 30 100 $iCount\
|
||||
${strSelection}\
|
||||
2>/tmp/menuitem.$$
|
||||
--menu 'Move using [UP] [DOWN],[Enter] to select' 30 100 $iCount\
|
||||
${strSelection}\
|
||||
2>/tmp/menuitem.$$
|
||||
|
||||
# get OK/Cancel
|
||||
sel=$?
|
||||
# get selected menuitem
|
||||
menuitem=`cat /tmp/menuitem.$$`
|
||||
rm -f /tmp/menuitem.$$
|
||||
# get OK/Cancel
|
||||
sel=$?
|
||||
# get selected menuitem
|
||||
menuitem=`cat /tmp/menuitem.$$`
|
||||
rm -f /tmp/menuitem.$$
|
||||
|
||||
# Cancel Button or <ESC>
|
||||
if [ $sel -eq 1 -o $sel -eq 255 ] ; then
|
||||
echo Cancel selected 1
|
||||
return 1
|
||||
fi
|
||||
KernelImage=${KernelNameArr[$menuitem]}
|
||||
# Cancel Button or <ESC>
|
||||
if [ $sel -eq 1 -o $sel -eq 255 ] ; then
|
||||
echo Cancel selected 1
|
||||
return 1
|
||||
fi
|
||||
KernelImage=${KernelNameArr[$menuitem]}
|
||||
}
|
||||
|
||||
run_user() {
|
||||
if [ -z $DevicePath ]; then
|
||||
# DevicePath for memory card
|
||||
SelectCardDevice || exit 1
|
||||
fi
|
||||
if [ -z $DevicePath ]; then
|
||||
# DevicePath for memory card
|
||||
SelectCardDevice || exit 1
|
||||
fi
|
||||
|
||||
if [ -z $KernelImage ]; then
|
||||
# select rootfs
|
||||
SelectKernel || exit 1
|
||||
fi
|
||||
RootParams="$DevicePath $KernelImage $KERNEL_IMAGE_TYPE"
|
||||
if [ -z $KernelImage ]; then
|
||||
# select rootfs
|
||||
SelectKernel || exit 1
|
||||
fi
|
||||
RootParams="$DevicePath $KernelImage $KERNEL_IMAGE_TYPE"
|
||||
}
|
||||
|
||||
run_root() {
|
||||
# device node valid?
|
||||
if [ ! -b $DevicePath ] ; then
|
||||
echo "$DevicePath is not a valid block device!"
|
||||
exit 1
|
||||
fi
|
||||
# rootfs valid?
|
||||
if [ ! -e $KernelImage ] ; then
|
||||
echo "$KernelImage can not be found!"
|
||||
exit 1
|
||||
fi
|
||||
# device node valid?
|
||||
if [ ! -b $DevicePath ] ; then
|
||||
echo "$DevicePath is not a valid block device!"
|
||||
exit 1
|
||||
fi
|
||||
# rootfs valid?
|
||||
if [ ! -e $KernelImage ] ; then
|
||||
echo "$KernelImage can not be found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IMAGEDIR=$(dirname $KernelImage)
|
||||
IMAGEDIR=$(dirname $KernelImage)
|
||||
|
||||
# check if the card is currently mounted
|
||||
MOUNTSTR=$(mount | grep $DevicePath)
|
||||
if [ -n "$MOUNTSTR" ] ; then
|
||||
echo -e "\n$DevicePath is mounted. Unmounting..."
|
||||
umount -f ${DevicePath}?*
|
||||
fi
|
||||
# check if the card is currently mounted
|
||||
chk_umount $DevicePath
|
||||
|
||||
# create temp mount path
|
||||
if [ ! -d /tmp/tmp_mount$$ ] ; then
|
||||
mkdir /tmp/tmp_mount$$
|
||||
fi
|
||||
# create temp mount path
|
||||
if [ ! -d /tmp/tmp_mount$$ ] ; then
|
||||
mkdir /tmp/tmp_mount$$
|
||||
fi
|
||||
|
||||
# initial kernel
|
||||
mount ${DevicePath}1 /tmp/tmp_mount$$ || exit 1
|
||||
echo "Writing initial kernel and devicetrees to boot partition"
|
||||
rm -f /tmp/tmp_mount$$/${KernelImageType}*
|
||||
cp -f $KernelImage /tmp/tmp_mount$$/$KernelImageType
|
||||
|
||||
# initial kernel
|
||||
mount ${DevicePath}1 /tmp/tmp_mount$$ || exit 1
|
||||
echo "Writing initial kernel and devicetrees to boot partition"
|
||||
rm -f /tmp/tmp_mount$$/${KernelImageType}*
|
||||
cp -f $KernelImage /tmp/tmp_mount$$/$KernelImageType
|
||||
|
||||
# devicetrees
|
||||
# devicetrees
|
||||
rm -f /tmp/tmp_mount$$/*.dtb
|
||||
for dtb in `find ${IMAGEDIR} -name "${KernelImageType}*.dtb" -type l`; do
|
||||
for dtb in `find ${IMAGEDIR} -name "${KernelImageType}*.dtb" -type l`; do
|
||||
dtbname=`basename $dtb | sed 's:'${KernelImageType}'-::'`
|
||||
cp -f $dtb /tmp/tmp_mount$$/${dtbname}
|
||||
done
|
||||
cp -f $dtb /tmp/tmp_mount$$/${dtbname}
|
||||
done
|
||||
|
||||
sleep 1
|
||||
umount ${DevicePath}1 || exit 1
|
||||
sleep 1
|
||||
umount ${DevicePath}1 || exit 1
|
||||
|
||||
# rootfs/boot
|
||||
mount ${DevicePath}2 /tmp/tmp_mount$$ || exit 1
|
||||
echo "Writing kernel to rootfs"
|
||||
rm -f /tmp/tmp_mount$$/boot/${KernelImageType}*
|
||||
# rootfs/boot
|
||||
mount ${DevicePath}2 /tmp/tmp_mount$$ || exit 1
|
||||
echo "Writing kernel to rootfs"
|
||||
rm -f /tmp/tmp_mount$$/boot/${KernelImageType}*
|
||||
KernelWithAbiName=`basename $KernelImage | sed -e 's:-abiversion-::'`
|
||||
cp $KernelImage /tmp/tmp_mount$$/boot/$KernelWithAbiName
|
||||
cp $KernelImage /tmp/tmp_mount$$/boot/$KernelWithAbiName
|
||||
ln -sf $KernelWithAbiName /tmp/tmp_mount$$/boot/$KernelImageType
|
||||
|
||||
# rootfs/lib/modules
|
||||
echo "Writing modules to rootfs..."
|
||||
# rootfs/lib/modules
|
||||
echo "Writing modules to rootfs..."
|
||||
kernel_abi_ver=`echo $KernelWithAbiName | sed 's:'${KernelImageType}'::g'`
|
||||
|
||||
for modules in `find ${IMAGEDIR} -name "modules-${MACHINE}.tgz"`; do
|
||||
tar xvzf ${modules} -C /tmp/tmp_mount$$/
|
||||
done
|
||||
# run depmod (stolen from dempodwrapper
|
||||
sys_map=`realpath ${IMAGEDIR}/../../../pkgdata/${MACHINE}/kernel-depmod/System.map-$kernel_abi_ver`
|
||||
echo "Running depmod on modules"
|
||||
depmod -a -b /tmp/tmp_mount$$ -F "$sys_map" "$kernel_abi_ver"
|
||||
for modules in `find ${IMAGEDIR} -name "modules-${MACHINE}.tgz"`; do
|
||||
tar xvzf ${modules} -C /tmp/tmp_mount$$/
|
||||
done
|
||||
# run depmod (stolen from dempodwrapper
|
||||
sys_map=`realpath ${IMAGEDIR}/../../../pkgdata/${MACHINE}/kernel-depmod/System.map-$kernel_abi_ver`
|
||||
echo "Running depmod on modules"
|
||||
depmod -a -b /tmp/tmp_mount$$ -F "$sys_map" "$kernel_abi_ver"
|
||||
|
||||
echo "Unmount / write cache..."
|
||||
umount ${DevicePath}2 || exit 1
|
||||
echo "Unmount / write cache..."
|
||||
umount ${DevicePath}2 || exit 1
|
||||
|
||||
rm -rf /tmp/tmp_mount$$
|
||||
rm -rf /tmp/tmp_mount$$
|
||||
}
|
||||
|
||||
. `dirname $0`/machine.inc
|
||||
. `dirname $0`/../tools.inc
|
||||
|
||||
if [ -z $MACHINE ]; then
|
||||
MACHINE=$DEFAULT_MACHINE
|
||||
MACHINE=$DEFAULT_MACHINE
|
||||
fi
|
||||
if [ -z $KERNEL_IMAGE_TYPE ]; then
|
||||
KERNEL_IMAGE_TYPE=$DEFAULT_KERNEL_IMAGE_TYPE
|
||||
KERNEL_IMAGE_TYPE=$DEFAULT_KERNEL_IMAGE_TYPE
|
||||
fi
|
||||
|
||||
DevicePath=$1
|
||||
|
||||
@@ -7,52 +7,48 @@
|
||||
# This script writes image to sdcard and aligns rootfs partition to max size.
|
||||
|
||||
run_user() {
|
||||
if [ -z $DevicePath ]; then
|
||||
# DevicePath for memory card
|
||||
SelectCardDevice || exit 1
|
||||
fi
|
||||
if [ -z $DevicePath ]; then
|
||||
# DevicePath for memory card
|
||||
SelectCardDevice || exit 1
|
||||
fi
|
||||
|
||||
if [ -z $RootFsFile ]; then
|
||||
# select rootfs
|
||||
SelectRootfs '-name *.sdcard -o -name *.wic.gz -type l' || exit 1
|
||||
fi
|
||||
RootParams="$DevicePath $RootFsFile"
|
||||
if [ -z $RootFsFile ]; then
|
||||
# select rootfs
|
||||
SelectRootfs '-name *.sdcard -o -name *.wic.gz -type l' || exit 1
|
||||
fi
|
||||
RootParams="$DevicePath $RootFsFile"
|
||||
}
|
||||
|
||||
run_root() {
|
||||
# device node valid?
|
||||
if [ ! -b $DevicePath ] ; then
|
||||
echo "$DevicePath is not a valid block device!"
|
||||
exit 1
|
||||
fi
|
||||
# rootfs valid?
|
||||
if [ ! -e $RootFsFile ] ; then
|
||||
echo "$RootFsFile can not be found!"
|
||||
exit 1
|
||||
fi
|
||||
# device node valid?
|
||||
if [ ! -b $DevicePath ] ; then
|
||||
echo "$DevicePath is not a valid block device!"
|
||||
exit 1
|
||||
fi
|
||||
# rootfs valid?
|
||||
if [ ! -e $RootFsFile ] ; then
|
||||
echo "$RootFsFile can not be found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IMAGEDIR=$(dirname $RootFsFile)
|
||||
IMAGEDIR=$(dirname $RootFsFile)
|
||||
|
||||
# check if the card is currently mounted
|
||||
MOUNTSTR=$(mount | grep $DevicePath)
|
||||
if [ -n "$MOUNTSTR" ] ; then
|
||||
echo -e "\n$DevicePath is mounted. Unmounting..."
|
||||
umount -f ${DevicePath}?*
|
||||
fi
|
||||
# check if the card is currently mounted
|
||||
chk_umount $DevicePath
|
||||
|
||||
# rootfs write/resize to card fit
|
||||
time(
|
||||
echo "Writing $RootFsFile to $DevicePath..."
|
||||
if echo $RootFsFile | grep -q '.wic.gz'; then
|
||||
gunzip -c $RootFsFile | dd of=$DevicePath bs=1024K
|
||||
else
|
||||
dd of=$DevicePath if=$RootFsFile bs=1024K
|
||||
fi
|
||||
sync
|
||||
# rootfs write/resize to card fit
|
||||
time(
|
||||
echo "Writing $RootFsFile to $DevicePath..."
|
||||
if echo $RootFsFile | grep -q '.wic.gz'; then
|
||||
gunzip -c $RootFsFile | dd of=$DevicePath bs=1024K
|
||||
else
|
||||
dd of=$DevicePath if=$RootFsFile bs=1024K
|
||||
fi
|
||||
sync
|
||||
echo "Resizing ${DevicePath}2..."
|
||||
parted -s $DevicePath -- resizepart 2 -0
|
||||
resize2fs "${DevicePath}2"
|
||||
)
|
||||
parted -s $DevicePath -- resizepart 2 -0
|
||||
resize2fs "${DevicePath}2"
|
||||
)
|
||||
}
|
||||
|
||||
# includes
|
||||
@@ -65,7 +61,7 @@ CheckPrerequisite "parted"
|
||||
CheckPrerequisite "resize2fs"
|
||||
|
||||
if [ -z $MACHINE ]; then
|
||||
MACHINE=$DEFAULT_MACHINE
|
||||
MACHINE=$DEFAULT_MACHINE
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -7,48 +7,44 @@
|
||||
# This script writes image to sdcard and aligns rootfs partition to max size.
|
||||
|
||||
run_user() {
|
||||
if [ -z $DevicePath ]; then
|
||||
# DevicePath for memory card
|
||||
SelectCardDevice || exit 1
|
||||
fi
|
||||
if [ -z $DevicePath ]; then
|
||||
# DevicePath for memory card
|
||||
SelectCardDevice || exit 1
|
||||
fi
|
||||
|
||||
if [ -z $RootFsFile ]; then
|
||||
# select rootfs
|
||||
SelectRootfs '-name *.rpi-sdimg -type l' || exit 1
|
||||
fi
|
||||
RootParams="$DevicePath $RootFsFile"
|
||||
if [ -z $RootFsFile ]; then
|
||||
# select rootfs
|
||||
SelectRootfs '-name *.rpi-sdimg -type l' || exit 1
|
||||
fi
|
||||
RootParams="$DevicePath $RootFsFile"
|
||||
}
|
||||
|
||||
run_root() {
|
||||
# device node valid?
|
||||
if [ ! -b $DevicePath ] ; then
|
||||
echo "$DevicePath is not a valid block device!"
|
||||
exit 1
|
||||
fi
|
||||
# rootfs valid?
|
||||
if [ ! -e $RootFsFile ] ; then
|
||||
echo "$RootFsFile can not be found!"
|
||||
exit 1
|
||||
fi
|
||||
# device node valid?
|
||||
if [ ! -b $DevicePath ] ; then
|
||||
echo "$DevicePath is not a valid block device!"
|
||||
exit 1
|
||||
fi
|
||||
# rootfs valid?
|
||||
if [ ! -e $RootFsFile ] ; then
|
||||
echo "$RootFsFile can not be found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IMAGEDIR=$(dirname $RootFsFile)
|
||||
IMAGEDIR=$(dirname $RootFsFile)
|
||||
|
||||
# check if the card is currently mounted
|
||||
MOUNTSTR=$(mount | grep $DevicePath)
|
||||
if [ -n "$MOUNTSTR" ] ; then
|
||||
echo -e "\n$DevicePath is mounted. Unmounting..."
|
||||
umount -f ${DevicePath}?*
|
||||
fi
|
||||
# check if the card is currently mounted
|
||||
chk_umount $DevicePath
|
||||
|
||||
# rootfs write/resize to card fit
|
||||
time(
|
||||
echo "Writing $RootFsFile to $DevicePath..."
|
||||
dd of=$DevicePath if=$RootFsFile bs=1024K
|
||||
sync
|
||||
echo "Resizing ${DevicePath}2..."
|
||||
parted -s $DevicePath -- resizepart 2 -0
|
||||
resize2fs "${DevicePath}2"
|
||||
)
|
||||
# rootfs write/resize to card fit
|
||||
time(
|
||||
echo "Writing $RootFsFile to $DevicePath..."
|
||||
dd of=$DevicePath if=$RootFsFile bs=1024K
|
||||
sync
|
||||
echo "Resizing ${DevicePath}2..."
|
||||
parted -s $DevicePath -- resizepart 2 -0
|
||||
resize2fs "${DevicePath}2"
|
||||
)
|
||||
}
|
||||
|
||||
# includes
|
||||
@@ -61,7 +57,7 @@ CheckPrerequisite "parted"
|
||||
CheckPrerequisite "resize2fs"
|
||||
|
||||
if [ -z $MACHINE ]; then
|
||||
MACHINE=$DEFAULT_MACHINE
|
||||
MACHINE=$DEFAULT_MACHINE
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -51,13 +51,13 @@ CheckPrerequisite() {
|
||||
# SelectCardDevice() creates a dialog to select one of all available removable
|
||||
# devices. The path to the selected device is stored in the variale DevicePath.
|
||||
SelectCardDevice() {
|
||||
iCount=0
|
||||
for dev in /dev/sd[a-z] ; do
|
||||
DeviceFile=`basename $dev`
|
||||
# we are only interested in removable devices
|
||||
if [ `cat /sys/block/$DeviceFile/removable` = '1' ] && [ `cat /sys/block/$DeviceFile/size` -gt "0" ]; then
|
||||
iCount=`expr $iCount + 1`
|
||||
DevicePathArr[${iCount}]=$dev
|
||||
iCount=0
|
||||
for dev in /dev/sd[a-z] ; do
|
||||
DeviceFile=`basename $dev`
|
||||
# we are only interested in removable devices
|
||||
if [ `cat /sys/block/$DeviceFile/removable` = '1' ] && [ `cat /sys/block/$DeviceFile/size` -gt "0" ]; then
|
||||
iCount=`expr $iCount + 1`
|
||||
DevicePathArr[${iCount}]=$dev
|
||||
# pretify display
|
||||
secondline=
|
||||
display=
|
||||
@@ -74,7 +74,7 @@ SelectCardDevice() {
|
||||
secondline="2"
|
||||
# second line - header + partition
|
||||
display="$display / partitions: $line"
|
||||
else
|
||||
else
|
||||
# second line - separator + partition
|
||||
display="$display + $line"
|
||||
fi
|
||||
@@ -86,132 +86,145 @@ SelectCardDevice() {
|
||||
|
||||
unset IFS
|
||||
menuitems+=( "$iCount" "$display" )
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $iCount -eq 0 ]; then
|
||||
ErrorOut 'No removable devices found!'
|
||||
fi
|
||||
if [ $iCount -eq 0 ]; then
|
||||
ErrorOut 'No removable devices found!'
|
||||
fi
|
||||
|
||||
dialog --title 'Select card device'\
|
||||
--menu 'Move using [UP] [DOWN],[Enter] to select' 10 100 $iCount\
|
||||
"${menuitems[@]}"\
|
||||
2>/tmp/menuitem.$$
|
||||
dialog --title 'Select card device'\
|
||||
--menu 'Move using [UP] [DOWN],[Enter] to select' 10 100 $iCount\
|
||||
"${menuitems[@]}"\
|
||||
2>/tmp/menuitem.$$
|
||||
|
||||
# get OK/Cancel
|
||||
sel=$?
|
||||
# get selected menuitem
|
||||
menuitem=`cat /tmp/menuitem.$$`
|
||||
rm -f /tmp/menuitem.$$
|
||||
# get OK/Cancel
|
||||
sel=$?
|
||||
# get selected menuitem
|
||||
menuitem=`cat /tmp/menuitem.$$`
|
||||
rm -f /tmp/menuitem.$$
|
||||
|
||||
# Cancel Button or <ESC>
|
||||
if [ $sel -eq 1 -o $sel -eq 255 ] ; then
|
||||
echo 'Cancel selected SelectCardDevice()'
|
||||
return 1
|
||||
fi
|
||||
DevicePath=${DevicePathArr[$menuitem]}
|
||||
# Cancel Button or <ESC>
|
||||
if [ $sel -eq 1 -o $sel -eq 255 ] ; then
|
||||
echo 'Cancel selected SelectCardDevice()'
|
||||
return 1
|
||||
fi
|
||||
DevicePath=${DevicePathArr[$menuitem]}
|
||||
}
|
||||
|
||||
# SelectRootfs() opens a dialog to select file containing rootfs. It expects
|
||||
# one parameter which contains find parameters e.g for raspberrypi: '
|
||||
SelectRootfs() {
|
||||
# OE environment found?
|
||||
if [ -z $BUILDDIR ]; then
|
||||
ErrorOut "The environment variable BUILDDIR is not set. It is usually set before running bitbake."
|
||||
fi
|
||||
iCount=0
|
||||
strSelection=
|
||||
for grep_result in `grep -h TMPDIR $BUILDDIR/conf/*.conf | sed -e s/' '/''/g -e s/'\"'/''/g`; do
|
||||
# exclude comments
|
||||
tmp_dir=`echo $grep_result | grep '^TMPDIR='`
|
||||
if [ ! -z $tmp_dir ]; then
|
||||
TMPDIR=`echo $tmp_dir | sed -e s/'TMPDIR='/''/g`
|
||||
fi
|
||||
done
|
||||
for BuildPath in ${TMPDIR}-*; do
|
||||
for i in `find ${BuildPath}/deploy/images/${MACHINE} $1 | sort` ; do
|
||||
iCount=`expr $iCount + 1`
|
||||
RootFileNameArr[${iCount}]=$i
|
||||
strSelection="$strSelection $iCount "`basename $i`
|
||||
done
|
||||
done
|
||||
# OE environment found?
|
||||
if [ -z $BUILDDIR ]; then
|
||||
ErrorOut "The environment variable BUILDDIR is not set. It is usually set before running bitbake."
|
||||
fi
|
||||
iCount=0
|
||||
strSelection=
|
||||
for grep_result in `grep -h TMPDIR $BUILDDIR/conf/*.conf | sed -e s/' '/''/g -e s/'\"'/''/g`; do
|
||||
# exclude comments
|
||||
tmp_dir=`echo $grep_result | grep '^TMPDIR='`
|
||||
if [ ! -z $tmp_dir ]; then
|
||||
TMPDIR=`echo $tmp_dir | sed -e s/'TMPDIR='/''/g`
|
||||
fi
|
||||
done
|
||||
for BuildPath in ${TMPDIR}-*; do
|
||||
for i in `find ${BuildPath}/deploy/images/${MACHINE} $1 | sort` ; do
|
||||
iCount=`expr $iCount + 1`
|
||||
RootFileNameArr[${iCount}]=$i
|
||||
strSelection="$strSelection $iCount "`basename $i`
|
||||
done
|
||||
done
|
||||
|
||||
# were files found?
|
||||
if [ $iCount -eq 0 ]; then
|
||||
ErrorOut "No rootfs files found in ${TMPDIR}-\*"
|
||||
fi
|
||||
# were files found?
|
||||
if [ $iCount -eq 0 ]; then
|
||||
ErrorOut "No rootfs files found in ${TMPDIR}-\*"
|
||||
fi
|
||||
|
||||
dialog --title 'Select rootfs'\
|
||||
--menu 'Move using [UP] [DOWN],[Enter] to select' 30 100 $iCount\
|
||||
${strSelection}\
|
||||
2>/tmp/menuitem.$$
|
||||
dialog --title 'Select rootfs'\
|
||||
--menu 'Move using [UP] [DOWN],[Enter] to select' 30 100 $iCount\
|
||||
${strSelection}\
|
||||
2>/tmp/menuitem.$$
|
||||
|
||||
# get OK/Cancel
|
||||
sel=$?
|
||||
# get selected menuitem
|
||||
menuitem=`cat /tmp/menuitem.$$`
|
||||
rm -f /tmp/menuitem.$$
|
||||
# get OK/Cancel
|
||||
sel=$?
|
||||
# get selected menuitem
|
||||
menuitem=`cat /tmp/menuitem.$$`
|
||||
rm -f /tmp/menuitem.$$
|
||||
|
||||
# Cancel Button or <ESC>
|
||||
if [ $sel -eq 1 -o $sel -eq 255 ] ; then
|
||||
echo Cancel selected 1
|
||||
return 1
|
||||
fi
|
||||
RootFsFile=${RootFileNameArr[$menuitem]}
|
||||
echo
|
||||
# Cancel Button or <ESC>
|
||||
if [ $sel -eq 1 -o $sel -eq 255 ] ; then
|
||||
echo Cancel selected 1
|
||||
return 1
|
||||
fi
|
||||
RootFsFile=${RootFileNameArr[$menuitem]}
|
||||
echo
|
||||
}
|
||||
|
||||
|
||||
# chk_root() tests if we are running as root. If not, it calls run_user and then
|
||||
# asks operator how to log on as root. Then the main script is started as root
|
||||
chk_root() {
|
||||
# we are not already root?
|
||||
if [ ! $( id -u ) -eq 0 ]; then
|
||||
# do all non root operations
|
||||
run_user
|
||||
# abort in case run_user was performed without success
|
||||
if [ $? -ne 0 ] ; then
|
||||
return 1
|
||||
fi
|
||||
# we are not already root?
|
||||
if [ ! $( id -u ) -eq 0 ]; then
|
||||
# do all non root operations
|
||||
run_user
|
||||
# abort in case run_user was performed without success
|
||||
if [ $? -ne 0 ] ; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
dialog --title 'Select how you want to logon as root'\
|
||||
--menu 'Move using [UP] [DOWN],[Enter] to select' 10 100 2 1 su 2 sudo \
|
||||
2>/tmp/menuitem.$$
|
||||
dialog --title 'Select how you want to logon as root'\
|
||||
--menu 'Move using [UP] [DOWN],[Enter] to select' 10 100 2 1 su 2 sudo \
|
||||
2>/tmp/menuitem.$$
|
||||
|
||||
# get OK/Cancel
|
||||
sel=$?
|
||||
# get selected menuitem
|
||||
menuitem=`cat /tmp/menuitem.$$`
|
||||
rm -f /tmp/menuitem.$$
|
||||
# get OK/Cancel
|
||||
sel=$?
|
||||
# get selected menuitem
|
||||
menuitem=`cat /tmp/menuitem.$$`
|
||||
rm -f /tmp/menuitem.$$
|
||||
|
||||
# Cancel Button or <ESC>
|
||||
if [ $sel -eq 1 -o $sel -eq 255 ] ; then
|
||||
echo 'Cancel selected chk_root()'
|
||||
return 1
|
||||
fi
|
||||
# Cancel Button or <ESC>
|
||||
if [ $sel -eq 1 -o $sel -eq 255 ] ; then
|
||||
echo 'Cancel selected chk_root()'
|
||||
return 1
|
||||
fi
|
||||
|
||||
clear
|
||||
if [ "x$1" = "x" ] ; then
|
||||
echo "All data currenly stored on $DevicePath will be overwritten!!"
|
||||
else
|
||||
echo $1 | sed "s|\%DevicePath\%|$DevicePath|"
|
||||
fi
|
||||
clear
|
||||
if [ "x$1" = "x" ] ; then
|
||||
echo "All data currenly stored on $DevicePath will be overwritten!!"
|
||||
else
|
||||
echo $1 | sed "s|\%DevicePath\%|$DevicePath|"
|
||||
fi
|
||||
|
||||
if [ $menuitem -eq 1 ]; then
|
||||
echo -e "\nEnter valid root password if you are sure you want to continue"
|
||||
# Call this prog as root
|
||||
exec su -c "${0} $RootParams"
|
||||
else
|
||||
echo -e "\nEnter valid sudo password if you are sure you want to continue"
|
||||
sudo -k
|
||||
# Call this prog as root
|
||||
exec sudo ${0} $RootParams
|
||||
fi
|
||||
return 1 # sice we're 'execing' above, we wont reach this exit
|
||||
# unless something goes wrong.
|
||||
fi
|
||||
if [ $menuitem -eq 1 ]; then
|
||||
echo -e "\nEnter valid root password if you are sure you want to continue"
|
||||
# Call this prog as root
|
||||
exec su -c "${0} $RootParams"
|
||||
else
|
||||
echo -e "\nEnter valid sudo password if you are sure you want to continue"
|
||||
sudo -k
|
||||
# Call this prog as root
|
||||
exec sudo ${0} $RootParams
|
||||
fi
|
||||
return 1 # sice we're 'execing' above, we wont reach this exit
|
||||
# unless something goes wrong.
|
||||
fi
|
||||
}
|
||||
|
||||
# chk_umount() tests if a device partition is mounted. If so partition is
|
||||
# unmounted. Devic name is expected in first parameter.
|
||||
chk_umount() {
|
||||
# check if the card is currently mounted
|
||||
MOUNTSTR=$(mount | grep $1)
|
||||
if [ -n "$MOUNTSTR" ] ; then
|
||||
echo -en "\n$1 is mounted. Unmounting..."
|
||||
umount -f ${1}?*
|
||||
echo " done"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# common prerequisites
|
||||
CheckPrerequisite "dialog"
|
||||
CheckPrerequisite "lsblk"
|
||||
|
||||
Reference in New Issue
Block a user