Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2004
    Location
    france
    Posts
    4

    Question Unanswered: a cvs module dependencies script

    i have troubles with the function ver () from a script of which the goal is to produce a structured/ ordered build list dependencies from cvsdb (a modules database)
    i show you all needed scripts (exept the builds scripts which are not needed to run test via 'build --mad' )

    i would be happy to understand what's wrong because i'm a little lost in this raw produced script

    #!/bin/bash
    #/usr/sbin/build
    #this is the core of BUILD CVS
    # bliscat.sirtakys@tele2.fr GPL
    #need functions cvs_db cvsdb cvs wget gawk patch make (build scripts are made for LFS-CVS-20040601 (gcc-3.4.1))
    export RD=/var/cvs
    SCRIPT=/etc/scripts
    source $SCRIPT/fonctions

    case "$1" in
    --mad)
    mad
    ;;
    esac

    now the fuction referencies for build script

    #this is the function definition for BUILD CVS
    # bliscat.sirtakys@tele2.fr GPL
    # there are bugs in function ver (), ver2 () and probably mkd ()
    #be aware of the fact we use an binary result in test so anything else from YES/NO generaly produce an error

    dat () # return the date + hour
    {
    date '+%y%m%d%H'
    }
    ccr () # check for required dirs / make it / cd to
    {
    if [ ! -d "$RD/$1" ] ; then rm -f "$RD/$1" ; install -d "$RD/$1" ; fi
    cd "$RD/$1"
    }
    csd () # change directory to source directory + ccr ()
    {
    ccr "$1"
    cd "$RD/$1/$1"
    }
    run () # return the name of the build script
    {
    cvs_db --script "$1"
    }
    typ () # return the type of the requested module CVS or Tarball
    {
    cvs_db --type "$1"
    }
    dep () # return a list containing the DIRECT dependancies of the requested module
    {
    cvs_db --deps "$1"
    }
    url () # return the needed parameter to get the source from CVS or the URL for the Tarball
    {
    cvs_db --server "$1"
    }
    moe () # check if module exist
    {
    if [ -z "$(cvs_db --type "$1")" ] ; then echo "NO" ; else echo "YES" ; fi
    }
    mfp () # check if module was successfully updated by us
    {
    ccr $1
    if [ -f "$1.sync" ] ; then echo "YES"; else echo "NO" ; fi
    }
    mkc () # just mark module source directory to said that we have get module successfully
    {
    csd "$1" ; dat > ../"$1".sync
    }

    # fonctions de niveau 2
    mup () # check if anything look good to build the requested module now
    {
    ccr "$1"
    if [ $"(mfp "$1")" = "YES" ] && [ "`cat "$1.sync"`" = "dat" ]
    then echo "YES"
    else echo "NO"
    fi
    }
    mau () # check if anything look good to build the requested module after "having" updated it
    {
    ccr "$1"
    if [ "$(mfp "$1")" = "YES" ] && [ "`cat "$1.sync"`" != "dat" ]
    then echo "YES"
    else echo "NO"
    fi
    }
    get () # just get or download
    {
    ccr "$1"
    if [ "$(typ "$1")" = "CVS" ]
    then cvs -q -z3 -d"$(url "$1")" get "$1" 2>&1 > /dev/null ; mkc "$1" ; fi
    if [ "$(typ "$1")" = "SRC" ]
    then csd $RD "$1" ; wget "$(url "$1")" 2>&1 > /dev/null ; mkc "$1" ; fi
    }
    gmf ()
    {
    if [ "$(moe "$1")" = "YES" ] ; then get "$1" 2>&1 > /dev/null ; fi
    }
    upm () # just update or download
    {
    csd "$1"
    if [ "$(typ "$1")" = "CVS" ]
    then cvs -q -z3 -d"$(url "$1")" update 2>&1 > /dev/null ; mkc "$1" ; fi
    if [ "$(typ "$1")" = "SRC" ]
    then get "$1" 2>&1 > /dev/null ; fi
    }
    mku () # this little function decides how to make modules able to build
    {
    ccr "$1"
    if [ "$(run "$1")" = "NO" ] ; then echo "YES" ; return 0 ; fi
    if [ "$(moe "$1")" = "YES" ] ; then
    if [ "$(mup "$1")" = "YES" ] ; then echo "YES" ; fi
    if [ "$(mau "$1")" = "YES" ] ; then upm "$1" 2>&1 > /dev/null && echo "YES"
    else gmf "$1" 2>&1 > /dev/null && echo "YES"
    fi
    else
    echo "NO"
    fi
    }
    ext ()
    {
    gawk -v MOD="$1" '{FS=" "}
    $1 == MOD { print "DUPLICATED" }' "$2.dep.raw"
    }
    mcl () # kindly one of the most important things : reorder the build list
    {
    ccr "$1"
    cat "$1.dep.raw" | tac > "$1.dep"
    }

    ddb ()
    {
    gawk -v MOD="$1" '{FS=" "}
    $1 == MOD { print "DUPLICATING" }' "$RD/MODULES.LOCK"
    }

    # Argh now one checks the order of the dependences for each dependence of the preceding list of not ordered dependence
    # if "$(moe "$DEPS")" is null/empty so it need nothing
    # HERE COMES THE BUG
    isgood () # an other sipmle use of gawk witch aims to accelerate the process
    {
    gawk -v MOD="$1" '{FS="#"}
    $1 == MOD { print "YES" }' "$2.dep.good"
    }
    ver2 () # whooo matters with '#' ? not in off but sed made some on name like gimp and gimp-print it's why i use those protection symbols
    {
    for MODP in `cat "$1.dep.nogood"`
    do
    teu () # i guess but i prefer KOF
    {
    for DEPS in `cat "$(echo "$RD/$1/$1.dep" | sed 's/\#//g' )"`
    do
    if [ -z "$(isgood "$DEPS" "$2")" ]
    then echo "NO"
    break
    fi
    done
    }
    if [ "$(teu "$MODP" "$1")" != "NO" ]
    then echo "$MODP" | sed 's/\#//g' >> "$1.dep.good"
    sed -i '/\#\'"$MODP"'\#/d' "$1.dep.nogood"
    echo -n "."
    fi
    done
    while [ -n "$(cat "$1.dep.nogood")" ]
    do
    echo -n "#"
    ver2 "$1"
    done
    }
    ver ()
    {
    echo -n "Checking dependency order ..."
    ccr "$1"
    rm -f "$1.dep."*
    if [ "$(cat "$1.dep")" != "$1" ]
    then
    for MOD in `cat "$1.dep"`
    do
    if [ -z "$(dep "$MOD")" ] ; then echo "$MOD" >> "$1.dep.good"
    echo -n "."
    else echo "#$MOD#" >> "$1.dep.nogood" ; fi
    done
    ver2 "$1"
    echo " done"
    sed 's/\#//g' "$1.dep.good" > "$1.dep"
    rm -f "$1.dep."*
    else
    echo " done"
    fi
    }

    # argh ! my nightmare : the dependencies... ( just have a look to the db) (this is why i have made thoses scripts)
    # so, first put the name of our mod to the build list
    # second, put recursively each dependencies... and check before they exist and more that they weren't build before
    # this will really increase the speed of the process ( you should before test your db by --test-db option in cvs_db)

    mkd ()
    {
    echo -n "Making dependencies for $1"
    if [ ! -f "$RD/MODULES.LOCK" ] ; then echo "" > "$RD/MODULES.LOCK" ; fi # prevent from output error from ddb
    ccr "$1" # go to dir
    echo "$1" > "$1.dep.raw" # put the name in bl (build list)
    BM="$1" # save the final module
    dal () # define the recursive function
    {
    for DEPS in $(dep "$1")
    do
    if [ "$(moe "$DEPS")" = "YES" ] ; then
    if [ ! -z "$DEPS" ] && [ "$(ext "$DEPS" "$BM")" != "DUPLICATED" ] # same as upper
    then echo "$DEPS" >> "$BM.dep.raw"
    echo -n "." # artistic output
    fi
    for MOD in $(dep "$DEPS")
    do
    if [ ! -z "$MOD" ] && [ "$(ext "$MOD" "$BM")" != "DUPLICATED" ]
    then echo "$MOD" >> "$BM.dep.raw"
    echo -n "." # artistic output
    dal "$MOD"
    fi
    done
    fi
    done
    }
    dal "$1"
    mcl "$1" # reorder bl
    rm -f "$1.dep.raw" # clean unnecessary file
    echo " done"
    ver "$1"
    }
    ece () # fonction d'arret sur erreur
    {
    echo " ERROR"
    less "$RD/$1/build.log"
    exit 1
    }
    # izi zest kaboul
    mkb_2 ()
    {
    if [ "$(moe "$1")" = "YES" ] #0
    then
    ccr "$1"
    for MOD in `cat "$1.dep"`
    do
    if [ $MOD != $1 ] #1
    then mkb_2 $MOD
    else
    if [ "$(ddb "$MOD")" != "DUPLICATING" ] #2
    then
    echo -n "Updating $MOD ..."
    if [ "$(mku "$MOD")" = "YES" ] #3
    then
    echo " YES"
    echo -n "Building $MOD ..."
    if [ "$(run "$1")" = "NO" ] #4
    then
    echo "FORBIDEN"
    else csd $MOD
    cp $SCRIPT/libtool ./
    cp $SCRIPT/mkinstalldirs ./
    sh "$SCRIPT/$(run "$MOD")" 2>&1 > "../build.log" &&
    echo " YES" &&
    echo "$MOD" >> "$RD/MODULES.LOCK" || ece $MOD
    fi #4
    else
    echo "UPDATE FAILS ##CVS/WGET## DATABASE URL ERROR OR CHECK CVS LOGIN CODE"
    exit
    fi #3
    fi #2
    fi #1
    done
    else echo "Module $1 not found in database"
    fi #0
    }
    mkb ()
    {
    mkd "$1"
    mkb_2 "$1"
    }
    mad ()
    {
    echo "Updating build list dependencies for each module "
    for all in $(cvs_db --all-mods)
    do
    mkd $all
    done
    echo "Updating build list dependencies for each module : done"
    }

    now the cvs_db script for testind build script

    #!/bin/bash
    #/usr/sbin/cvs_db
    #un truc bien marrant voire utile...
    #this is the core of CVS_DB an cvs module database reader (STABLE / no bug)
    # bliscat.sirtakys@tele2.fr GPL
    #need gawk cvsdb (build scripts are made for LFS-CVS-20040601 (gcc-3.4.1))
    export DBNAME=cvsdb
    export DBDIR=/etc
    case "$1" in
    --all-mods)
    echo -e $(echo $(gawk '{FS=" "};{ print $1 }' $DBDIR/$DBNAME) | sed 's/ / \\n/g')
    ;;
    --test-db)
    #supressed for space... here only
    ;;
    --deps)
    #aie aie aie...
    #bon, posons un principe: separation des dependances par un :
    # et,
    #on utilise sed pour virer les : par des <<\n >> glib\ atk\ pango
    # l'info DEPS est en 5eme col
    echo -e $(echo $(gawk -v MOD=$2 '{FS=" "};$1 == MOD { print $5 }' $DBDIR/$DBNAME) | sed 's/:/ \\n/g')
    ;;
    --server)
    # l'info SERVER est en 4eme col
    gawk -v MOD=$2 '{FS=" "}
    $1 == MOD { print $4 }' $DBDIR/$DBNAME
    ;;
    --type)
    # l'info TYPE est en 3eme col
    gawk -v MOD=$2 '{FS=" "}
    $1 == MOD { print $3 }' $DBDIR/$DBNAME
    ;;
    --script)
    # l'info SCRIPT est en 2nd col
    gawk -v MOD=$2 '{FS=" "}
    $1 == MOD { print $2 }' $DBDIR/$DBNAME
    ;;

    esac
    #fin de cvs_db

    and a little part the database cvsdb but nice to show error


    atk cvsgnome CVS :pserver:anonymous@anoncvs.gnome.org:/cvs/gnome glib
    gtk-doc cvsgnome CVS :pserver:anonymous@anoncvs.gnome.org:/cvs/gnome gnome-common:libxslt
    gtk+ cvsgnome CVS :pserver:anonymous@anoncvs.gnome.org:/cvs/gnome pango:atk:glib
    libxml2 NO CVS :pserver:anonymous@anoncvs.gnome.org:/cvs/gnome
    libxslt NO CVS :pserver:anonymous@anoncvs.gnome.org:/cvs/gnome
    pango cvsgnome CVS :pserver:anonymous@anoncvs.gnome.org:/cvs/gnome glib
    pkgconfig NO CVS :pserver:anoncvs@pdx.freedesktop.org:/cvs/pkgconfig
    glib cvsgnome CVS :pserver:anonymous@anoncvs.gnome.org:/cvs/gnome pkgconfig:gtk-doc
    Last edited by blx; 06-13-04 at 07:36. Reason: spell correction

  2. #2
    Join Date
    Jun 2004
    Location
    france
    Posts
    4

    Lightbulb resolved

    the right form is:

    isgood ()
    {
    gawk -v MOD="$1" '{FS=" "}
    $1 == MOD { print "YES" }' "$2.dep.good"
    }

    teu ()
    {
    for DEPS in `cat "$(echo "$RD/$1/$1.dep" | sed 's/#//g' )"`
    do
    DEPSP="#$DEPS#"
    if [ "$(isgood "$DEPSP" "$2")" = "YES" ]
    then echo "NO"
    break
    else echo "YES"
    fi
    done
    }

    ver2 ()
    {
    if [ ! -e "$1.dep.nogood" ] ; then return 0 ; fi # necessary not to cause errors in the case of an already clean list
    for MODP in `cat "$1.dep.nogood"`
    do
    if [ "$(teu "$MODP" "$1")" != "NO" ]
    then echo "$MODP" | sed 's/#//g' >> "$1.dep.good"
    sed -i '/\'$MODP'/d' "$1.dep.nogood"
    echo -n "."
    fi
    done
    while [ -n "$(cat "$1.dep.nogood")" ]
    do
    echo "#"
    echo "nogood:"
    cat "$1.dep.nogood"
    echo "good:"
    cat "$1.dep.good"
    sleep 10
    ver2 "$1"
    done
    }
    ver ()
    {
    echo -n "Checking dependency order ..."
    ccr "$1"
    rm -f "$1.dep."*
    if [ "$(cat "$1.dep")" != "$1" ]
    then
    for MOD in `cat "$1.dep"`
    do
    if [ -z "$(dep "$MOD")" ] ; then echo "$MOD" >> "$1.dep.good"
    echo -n "."
    else echo "#$MOD#" >> "$1.dep.nogood" ; fi
    done
    ver2 "$1"
    echo " done"
    sed 's/#//g' "$1.dep.good" > "$1.dep"
    rm -f "$1.dep."*
    else
    echo " done"
    fi
    }
    Last edited by blx; 06-13-04 at 07:43. Reason: if [ ! -e "$1.dep.nogood" ] ; then return 0 ; fi # necessary not to cause errors in the case of an already clean list

  3. #3
    Join Date
    Jun 2004
    Location
    france
    Posts
    4

    Thumbs up the rewriting of mkd is done

    i know, i'm alone but for those who ...
    but i have rewrited (completely) function mkdeps ( aka mkd)
    dal () is now out of mkd ()

    and better still, the list of the dependences once sorted by the function ver is perfect

    (i love myself)

    now it is:

    dal ()
    {
    for DEPS in $(dep "$1")
    do
    if [ -n "$(dep "$DEPS")" ] && [ "$(moe "$DEPS")" = "YES" ]
    then
    dal "$DEPS"
    else
    if [ "$(ext "$DEPS" "$FM")" != "DUPLICATED" ] && [ "$(moe "$DEPS")" = "YES" ]
    then
    echo "$DEPS" >> "$FM.dep.raw"
    echo -n "."
    fi
    fi
    done
    if [ "$(ext "$1" "$FM")" != "DUPLICATED" ] && [ "$(moe "$1")" = "YES" ]
    then
    echo "$1" >> "$FM.dep.raw"
    echo -n ":"
    fi
    }

    mkd ()
    {
    echo -n "Making dependences for $1"
    if [ ! -f "$RD/MODULES.LOCK" ] ; then echo "" > "$RD/MODULES.LOCK" ; fi # prevent from output error from ddb
    rm -f "$1.dep.raw"
    ccr "$1" # go to dir
    export FM=$1
    echo "" > "$1.dep.raw" # put module in list
    dal "$1" "$1" # build the dependencies list
    mv "$1.dep.raw" "$1.dep" # move necessary file (updated for the new dal () )
    echo " done"
    if [ "$NOVERIFY" != 1 ] ; then ver "$1" ; fi
    }

    so i'm having fun
    Last edited by blx; 06-12-04 at 20:54. Reason: wrong affirmation wrong englissssh

  4. #4
    Join Date
    Jun 2004
    Location
    france
    Posts
    4

    Post cvsdb database syntax change

    no space in db just '#'

    so we need to update cvs_db

    it's now little less stable but work fine

    #!/bin/bash
    #/usr/sbin/cvs_db
    #un truc bien marrant voire utile...
    #this is the core of CVS_DB an cvs module database reader (STABLE / no bug)
    # bliscat.sirtakys@tele2.fr GPL
    #need gawk cvsdb (build scripts are made for LFS-CVS-20040601 (gcc-3.4.1))

    export DBNAME=cvsdb
    export DBDIR=/etc
    # gawk '! /\/\*/, /\*\// { print $0 }' $DBDIR/$DB > /etc/cvsdb.dat

    case "$1" in
    --give-me-all-fucking-modules|--all-mods)
    echo -e $(echo $(gawk '{FS="#"};{ print $1 }' $DBDIR/$DBNAME) | sed 's/ / \\n/g')
    ;;
    --test-db)
    #Argh! faut le faire...
    #j'ai creer une sortie simple de --deps et de --server
    # utilisons les...
    # 1) je sors les modules 1 à un et verifie l'existence de leurs dependances sans recursion
    for MOD in $(gawk '{FS="#"};{ print $1 }' $DBDIR/$DBNAME)
    do
    echo $MOD
    for DEP in `echo $($0 --deps $MOD)`
    do
    echo "------------>"$DEP" ?"
    if [ -z $(gawk -v MOD=$DEP '{FS="#"};$1 == MOD { print $1 }' $DBDIR/$DBNAME) ]
    then
    echo "ECHEC de la dependance "$DEP" pour "$MOD && exit

    else
    echo "SUCCES"
    fi
    done
    done
    ;;
    --test-db-rc)
    #creation de la fonction recursive ( une boucle parametrable en sorte )
    BLI="-"
    BL="-"
    function recursive
    {
    for MOD in $1
    do
    echo $BL"> "$MOD
    for DEP in `echo $($0 --deps $MOD)`
    do
    BL=$BLI$BL
    if [ -z $(gawk -v MOD=$DEP '{FS="#"};$1 == MOD { print $1 }' $DBDIR/$DBNAME) ]
    then
    echo "ECHEC de la dependance "$DEP" pour "$MOD && exit
    else
    echo $BL"> "$MOD
    fi

    recursive $DEP
    done
    done
    }

    for MODS in $(gawk '{FS="#"};{ print $1 }' $DBDIR/$DBNAME)
    do
    BL=$BLI
    echo $MODS
    recursive $MODS
    done

    echo "CVSDB est valable test de recursion passe"
    ;;
    --deps)
    #aie aie aie...
    #bon, posons un principe: separation des dependances par un :
    # et,
    #on utilise sed pour virer les : par des <<\n >> glib\ atk\ pango

    # l'info DEPS est en 5eme col
    # -v permet de passer $2 à MOD dans gawk
    # g dit à sed de tout traiter pas seulement le premier
    echo -e $(echo $(gawk -v MOD=$2 '{FS="#"};$1 == MOD { print $5 }' $DBDIR/$DBNAME) | sed 's/:/ \\n/g')






    ;;
    --server)
    # l'info SERVER est en 4eme col
    gawk -v MOD=$2 '{FS="#"}
    $1 == MOD { print $4 }' $DBDIR/$DBNAME
    ;;
    --type)
    # l'info TYPE est en 3eme col
    gawk -v MOD=$2 '{FS="#"}
    $1 == MOD { print $3 }' $DBDIR/$DBNAME
    ;;
    --script)
    # l'info SCRIPT est en 2nd col
    gawk -v MOD=$2 '{FS="#"}
    $1 == MOD { print $2 }' $DBDIR/$DBNAME
    ;;
    --set-deps)
    #set-dep permet d'attribué des dépendances à un module
    TL="$(gawk -v MOD=$2 '{FS="#"};$1 == MOD { print $0 }' $DBDIR/$DBNAME)"
    DEPSO="$(gawk -v MOD=$2 '{FS="#"};$1 == MOD { print $5 }' $DBDIR/$DBNAME)"
    TLF="$(echo $TL | sed 's/\'$DEPSO'//')"
    echo "$DEPSO"
    read DEPS
    echo $DEPS
    if [ ! -z "$DEPS" ] && [ "$DEPS" != " " ] ; then
    TLFN="$TLF$DEPS"
    echo "$TLFN"
    sleep 10
    else
    echo "CANCELED"
    exit 1
    fi
    ;;
    --asetdep)
    #set-dep permet d'attribué des dépendances à un module automatiquement
    export RD=/var/cvs
    SCRIPT=/etc/scripts
    source $SCRIPT/fonctions # fonction venant de build
    mad # creation de la liste des dependances
    echo -n "Wrinting new database "
    rm -f /root/cvsdb.new
    echo "" > /root/cvsdb.new
    for MOD in $($0 --all-mods)
    do
    echo -n "."
    ccr $MOD
    DEPSO="$($0 --deps "$MOD")"
    if [ -n "$DEPSO" ]
    then
    MODDEP=""
    for DEPS in $(cat "$MOD.dep")
    do
    if [ "$DEPS" = "$MOD" ] ; then break ; fi
    if [ -n "$MODDEP" ] ; then PRO=":" ; fi
    MODDEP="$MODDEP$PRO$DEPS"
    done
    TL="$(gawk -v MOD=$MOD '{FS="#"};$1 == MOD { print $0 }' $DBDIR/$DBNAME)"
    TLF="$MOD#$($0 --script "$MOD")#$($0 --type "$MOD")#$($0 --server "$MOD")"
    TLFN="$TLF#$MODDEP"
    echo $TLFN >> /root/cvsdb.new
    else
    echo "$MOD#$($0 --script "$MOD")#$($0 --type "$MOD")#$($0 --server "$MOD")" >> /root/cvsdb.new
    fi
    done
    echo " done"
    ;;
    esac
    #fin de cvs_db

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •