Re: shell script question

From: Keve Nagy (NO_SPAM_at_poliod.hu)
Date: 04/19/04

  • Next message: Vlad D. Markov: "Re: I managed to trash my X somehow"
    Date: Mon, 19 Apr 2004 11:41:52 +0200
    
    

    Alan Hicks wrote:

    > While others here have both pointed you to a shell related newsgroup
    > and offered you a solution as to your problem, I'm curious as to
    > exactly what it is you've got in that text file. It sounds to me like
    > you're looking at something similar to the multi-column output of ls.

    No Alan, my task has nothing to do with the multi-column ls.
    If you are interested, here is the story:
    I use this script to install apps. from the ports. As I am playing with
    FreeBSD on 3-4 different maschines, from time to time I need to
    re-install one or the other, mostly just because there has been a couple
    of newer releases since and I want to use the latest one. As there is a
    general set of ports I always use, I sort of automated (or simplified)
    the basic installation. After I installed the base system from CD1, I
    run this script and it installs all the ports I generally use. (of
    course I do a cvsup beforehand).
    What I did, is to collect the directory names related to the ports dir,
    and placed them into a textfile. Something like:

    x11/XFree86-4
    x11/kde3

    archivers/unzip
    archivers/unarj

    devel/motor

    shells/bash2

    misc/mc

    ... and lines like these.
    Then comes my shell script, which amongst other things does something like:
    while read textline
       do
       cd /usr/ports/$textline
       make install clean
    done <mytextfile.txt

    So that was the concept I used until now.
    But as we all know, users like me wake up one morning and they have the
    crazy idea that they can eventually upgrade this solution and make it
    much better than it is at the moment. :-)
    My midnight vision was that I can extend the functionality of this
    script by adding some make options to certain ports on demand.
    For example, kde3 should be compiled with -DWITH_OPTIONAL_DEPENDS and
    mplayer with WITH_DVD=yes, thus I cannot use a static "make install
    clean" in the script. Therefore I decided to add the compile-time
    parameters to the corresponding lines in the textfile, then use the
    first word of the textlines as the ports dir (same as before) and the
    rest of the line as make options. So the textfile now may have lines
    like these:

    x11/XFree86-4
    multimedia/mplayer WITH_DVD=yes
    x11/kde3 -DWITH_OPTIONAL_DEPENDS
    misc/mc

    and the relevant lines of my script would change to:
    cd /usr/ports/$first_word_of_textline_which_is_the_ports_dir_itself
    make $rest_of_the_textline_used_as_make_options install clean

    So the kde3 line would become:
    make -DWITH_OPTIONAL_DEPENDS install clean
    and the generic one-word lines, like mc would still behave as:
    make install clean
    only they have two spaces between make and install.

    So, that was the concept of my upgrade plan, but my bl**dy dream did not
    tell me how to separate the textline into words, so I dared to ask
    people who probably these midnight dreams more often, therefore they are
    more experienced than me.

    And I did receive a lot of very good suggestions.
    Thanks Guys!

    Keve

    -- 
    if you need to reply directly:
    keve(at)mail(dot)poliod(dot)hu
    

  • Next message: Vlad D. Markov: "Re: I managed to trash my X somehow"