1

Package names are stored in a text file and grouped by row symbol #step{1,2,3...}, what I'd like to do is : step1)to execute emerge --pretend package, step2) manually collect USE flags from pretendedly emerging execution result shown on the screen, set make.conf, and then step3) execute emerge package. Charles gave me an excellent demonstration of how to deal with row symbol #step at here.

My question is if the text file looks like below which only contained with packagenames, is it possible to use Charles' demonstration, or how should I rewrite it? In the function getSteps() at the line printf '%s\n' "$line", I've modified it a little bit, it didn't work.

Any ideas? Thank you! The text file contained with package names:

#step1
grub
genkernel
sys-kernel/gentoo-sources
sys-apps/pciutils
...
#step2
dev-libs/boost
sys-cluster/ceph
sys-fs/lvm2
...

Charles' demonstration is at: here

What I'd like to have is something like:

getSteps() {
  local running=0
  while read -r line; do
    if (( running )); then
      if [[ $line = "#"* ]]; then
        return
      else
 #       printf '%s\n' "$line"
         #step 1)
         emerge --pretend $line
         #step 2)
         select packageType in "PACKAGEUSE" "PACKAGEKEYWORDS" "PACKAGELICENSE"
         do
             case $REPLY in 
             1) read USE flags as an input
                set make.conf
                #step 3)
                emerge $line
                ;;
             2) ....
         done
      fi
    else
      [[ $line = "#"$1 ]] && running=1
    fi
  done <stepFile
}

This line below worked, but the problem is the 'while loop' will keep going, there is no way for user to select an option and then continue. Any ideas?

printf '%s\n' "emerge --pretend $line" | sh -

Furthermore, is it possible to store the output into a variable for further analysis?

Tao Wang
  • 186
  • 1
  • 18
  • The reason why I have to separate these packages into different steps is that, at step1, I'm able to remotely emerge packages in another computer, which is convenient for me to collect USE flags, but at step2, especially when I was trying to emerge boost and ceph, I'm unable to do so remotely. And even more, I have to compile kernel first and then emerge them. – Tao Wang Nov 13 '15 at 20:42
  • What does the output of `emerge --pretend` look like? How are you planning to get the `USE` flags out of it? Are you intending to do all three steps for each line before moving on to the next line? (That's fine and probably the right idea it just isn't the only way you might want to do this.) What does `setting make.conf` mean exactly? – Etan Reisner Nov 13 '15 at 20:43
  • `livecd / # emerge --pretend ceph These are the packages that would be merged, in order: Calculating dependencies... done! [ebuild N ] dev-libs/libaio-0.3.110 USE="static-libs {-test}" [ebuild N ] dev-libs/lzo-2.09 USE="static-libs -examples" ... ` It's just showing what kind of USE flag or KEYWORDS you're gonna need to emerge these package, it won't do nothing. – Tao Wang Nov 13 '15 at 20:44
  • `emerge` is a command line to install certain package in Gentoo Linux. `--pretend` is its option for showing compiler parameters and other stuff that you should have for installation. – Tao Wang Nov 13 '15 at 20:49
  • Yes, I know what `emerge` is and assumed what `--pretend` was going to do. I just didn't know the output at all. Your current code displays the `emerge --pretend` output on the screen but does not capture it at all... unless you intend for the user to copy and paste it back to you. You'll need to handle that. What's the selection between `PACKAGEUSE`, etc. about? – Etan Reisner Nov 13 '15 at 20:53
  • Yes, exactly. I'm about to ask another question about how to capture the output of `emerge --pretend`. At `#step 1)` of getSteps(), currently I have to copy and paste every critical USE flags, and package.use. – Tao Wang Nov 13 '15 at 21:00
  • Before you ask the question look around the site. There are **tons** of questions about doing that sort of thing on here (as well as on the broader internet). – Etan Reisner Nov 13 '15 at 21:04
  • PACKAGEUSE is for package.use, in my case, it's located in `/usr/portage/profiles/default/linux/package.use`, PACKAGEKEYWORDS is for USE flags, PACKAGELICENSE is rarely used, only for emerging Oracle JDK, in my case, it's located in `/etc/portage/package.license`. – Tao Wang Nov 13 '15 at 21:04
  • Check out `equery` from `app-portage/gentoolkit` and `eix` from `app-portage/eix`. Specifically `equery u ` may do what you want. – ti7 Nov 15 '15 at 17:53

1 Answers1

0

Problem solved by trying this. Add (your code here) </dev/tty in between of your code, as shown below.

   getSteps() {
      local running=0
      while read -r line; do
(        if (( running )); then
          if [[ $line = "#"* ]]; then
            return
          else

     #       printf '%s\n' "$line"
             #step 1)
             emerge --pretend $line
             #step 2)
             select packageType in "PACKAGEUSE" "PACKAGEKEYWORDS" "PACKAGELICENSE"
             do
                 case $REPLY in 
                 1) read USE flags as an input
                    set make.conf
                    #step 3)
                    emerge $line
                    ;;
                 2) ....
             done) </dev/tty
          fi
        else
          [[ $line = "#"$1 ]] && running=1
        fi
      done <stepFile
    }
Community
  • 1
  • 1
Tao Wang
  • 186
  • 1
  • 18