The main function execSteps
executes emerge --pretend $package
one by one, and these package's names(only names, no version information) are stored in a text file stepFile
. Some of packages may have extra need for configuring package.use, package.license, this kind of extra information will be shown up after executed emerge --pretend $package
. The second while loop in main function and function acceptPKGTypeItems
are intended to deal with this kind of extra information.
When emerging one particular package, it may depend on a couple of more packages. For example, emerge --pretend ceph
, I need to emerge more than 10 packages before ceph
gets emerged. Along with Gentoo/Linux updated, new version of package may be applied. So text file stepFile
only contained with package names which I need, and parsing the result of emerge --pretend $package
, I'm able to get updated package emerged.
At case 0)
, this while loop is intended to parse the result of emerge --pretend $line(which is from stepFile)
, for example emerge --pretend ceph
and get its dependant packages with current version, for example dev-libs/boost-1.57.0
, pass it as an argument to function emgRecursion
because dependant package dev-libs/boost-1.57.0
of package ceph
may have its own dependant packages which are dev-libs/boost-build-1.57.0
and dev-libs/boost-1.57.0
.
My problem is I get an error while : command not found
in function emgRecursion
when I enter 0 at case 0)
. Is it another different shell thing? I've added a pair parenthesis between the second while loop in main function which helped get readin answer from user for choosing package.use, package.license, or package.keywords. And I've tried to add another pair of parenthesis between the third while loop, the same problem. I've tested emgRecursion
and acceptPKGTypeItems
separately, both of them work fine and correctly.
Any ideas? Thank you very much.
function acceptPKGTypeItems() {
...
}
function emgRecursion() {
local output="$(emerge --pretend "="$1 | grep "\[ebuild")"
while read -r line;
do
done <<<"$output"
}
function execSteps() {
local running=0
while read -r line;
do
if (( running )); then
if [[ $line = "#"* ]] && [[ "${line/"step"}" = "$line" ]]; then
continue
else
if [[ ! "${line/"step"}" = "$line" ]]; then
echo "====== approaching to the next step which is not available at this time."
break
else
( output="$(emerge --pretend $line | grep "\[ebuild")"
echo "**************** $line is ready for emerging ****************"
while read -p "Which type of package would you like to add new item to (1-packageuse 2-packagelicense 3-packagekeywords 0-exit and continue)? " choice; do
case "$choice" in
1) echo "**************** $line is ready for emerging"
acceptPKGTypeItems $PACKAGEUSE
echo "**************** package.use has been updated."
;;
2) echo "**************** $line is ready for emerging"
acceptPKGTypeItems $PACKAGELICENSE
echo "**************** package.license has been updated."
;;
3) echo "**************** $line is ready for emerging"
acceptPKGTypeItems $PACKAGEKEYWORDS
echo "**************** package.keywords has been updated."
;;
0) echo "**************** $line starts emerging"
while read -r element;
do
local str="${element#*"] "}"
str="${str%%" "*}"
echo " $str is an element that need to be emerged. "
emgRecursion "$str"
done <<<"$output"
echo "**************** $line has been emerged. ****************"
break
;;
*) echo "~~~~~~~~~~~~~~~~ Invalid input, try again. ~~~~~~~~~~~~~~~~"
;;
esac
done) </dev/tty
fi
fi
else
[[ $line = "#"$1 ]] && running=1
done <$STEPS
}
execSteps step2
Nothing will stop while loop in main function, output:
livecd / # ./step1
* Last emerge --sync was 32d 23h 4m 58s ago.
**************** sys-cluster/ceph is ready for emerging ****************
Which type of package would you like to add new item to (1-packageuse 2-packagelicense 3-package.keywords 0-exit and continue)?0
**************** sys-cluster/ceph starts emerging ****************
dev-libs/libaio-0.3.110 is an element that need to be emerged.
* Last emerge --sync was 32d 23h 5m 3s ago.
./step1: line 48: while: command not found
./step1: line 49: : command not found
./step1: line 50: str=dev-libs/libaio-0.3.110: No such file or directory
Take a look at what dev-libs/libaio-0.3.110 looks like.
./step1: line 77: done: command not found
sys-libs/libunwind-1.1 is an element that need to be emerged.
* Last emerge --sync was 32d 23h 5m 5s ago.
^C
Exiting on signal 2