Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[PORTAGE] administrer les distfiles (RESOLU)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index French
View previous topic :: View next topic  
Author Message
zdra
Veteran
Veteran


Joined: 30 Nov 2003
Posts: 1693
Location: Bruxelles, Belgique

PostPosted: Sat Sep 18, 2004 10:57 am    Post subject: [PORTAGE] administrer les distfiles (RESOLU) Reply with quote

Bonjour,

Voilà je cherche une méthode (un script ?) pour gerer /usr/portage/distfiles. Le but étant de ne garder que les fichiers des packets installé, et de supprimer les vieilles versions. Est-ce possible de le faire lors d'une update ? il devrait automatiquement supprimer les distfiles des packets lors d'un unmerge...

Merci d'avance !


Last edited by zdra on Sun Sep 19, 2004 8:43 am; edited 1 time in total
Back to top
View user's profile Send private message
ghoti
Advocate
Advocate


Joined: 30 Dec 2002
Posts: 3636
Location: Belgium

PostPosted: Sat Sep 18, 2004 12:12 pm    Post subject: Reply with quote

Tu pourras peut-être piocher des idées dans ce thread ...
Back to top
View user's profile Send private message
gim
Guru
Guru


Joined: 29 Apr 2003
Posts: 418
Location: milky-way

PostPosted: Sat Sep 18, 2004 2:01 pm    Post subject: Reply with quote

Tiens moi aussi la question m'embetait, alors au vu de ce thread, j'ai commencé a essayer un petit outil:

--edit:version 2 quelques posts plus loin !

Code:

#!/bin/bash

source /etc/make.globals
source /etc/make.conf
source /sbin/functions.sh

DCTMPDIR=/tmp/distfiles-clean
USEDDIR=$DCTMPDIR/used
LISTFILE=$DCTMPDIR/list

ewarn "using DCTMPDIR=$DCTMPDIR"
ewarn "using DISTDIR=$DISTDIR"

ebegin "Scanning PKG database"
FILES=$(find /var/db/pkg -name environment.bz2 | xargs bzgrep -h --max-count=1 -e "^A=" | sed -e 's/^A=//' | tr "'\n" "  ")
FILES="$FILES svn-src cvs-src"
eend $? Failed

ebegin "Building curently-used distfiles directory"
rm -rf $USEDDIR
mkdir -p $USEDDIR
for i in $FILES; do ln -sf $DISTDIR/$i $USEDDIR/$i; done
eend $? Failed

ebegin "Generating obsolete distfiles list"
rm -f $LISTFILE; touch $LISTFILE
cd $DISTDIR; for i in *; do [ -L $USEDDIR/$i ] || echo $DISTDIR/$i >> $LISTFILE; done
eend $? Failed

NB=$(cat $LISTFILE | wc -l)
ewarn "$NB files are obsolete"
ewarn "They can be removed using:"
ewarn " # cat $LISTFILE | xargs rm"


Si qqun connait la différence entre "A" et "AA" dans les "environment.bz2" merci de bien vouloir me l'indiquer ;)


Sinon, je crois que ce script permet de faire exactement ce que tu veux.


Last edited by gim on Sat Sep 18, 2004 10:06 pm; edited 1 time in total
Back to top
View user's profile Send private message
zdra
Veteran
Veteran


Joined: 30 Nov 2003
Posts: 1693
Location: Bruxelles, Belgique

PostPosted: Sat Sep 18, 2004 3:45 pm    Post subject: Reply with quote

en effet c'est ce que je cherchais ! MERCI ! :D
Back to top
View user's profile Send private message
sireyessire
Advocate
Advocate


Joined: 20 Mar 2003
Posts: 2991
Location: back in Paris, France

PostPosted: Sat Sep 18, 2004 3:51 pm    Post subject: Reply with quote

gim wrote:


Si qqun connait la différence entre "A" et "AA" dans les "environment.bz2" merci de bien vouloir me l'indiquer ;)

joli script, effectivement je n'ai vu encore aucune différence entre les lignes A et AA de ces fichiers, c'est un peu bizarre :o
_________________
I never think of the future. It comes soon enough.
Albert Einstein

Try simpler first
Shockley
Back to top
View user's profile Send private message
CryoGen
Veteran
Veteran


Joined: 11 Feb 2004
Posts: 1426
Location: Bamako - Mali - Afrique

PostPosted: Sat Sep 18, 2004 4:24 pm    Post subject: Reply with quote

Excellent ce script :) adopté :P
_________________
- CryoGen` on #gentoofr@irc.freenode.net
- ~amd64 / KDE4
- I'm the bone of my sword...
Back to top
View user's profile Send private message
gim
Guru
Guru


Joined: 29 Apr 2003
Posts: 418
Location: milky-way

PostPosted: Sat Sep 18, 2004 10:00 pm    Post subject: Reply with quote

Allez, j'ai même fait une version distfiles-clean "de luxe" :)

Code:
#!/bin/bash

source /etc/make.globals
source /etc/make.conf
source /sbin/functions.sh

OPTS=$(getopt -n "$0" -o paflqLv -l pretend -l ask -l force -l list -l pager -l quiet -l verbose -- $*)

ACTION=""
DISPLAY=""
VERBOSITY="verbose"
for i in $OPTS; do
case $i in
    "--pretend"|"-p") ACTION=pretend;;
    "--ask"|"-a") ACTION=ask;;
    "--force"|"-f") ACTION=proceed;;
    "--list"|"-l") DISPLAY=list;;
    "--pager"|"-L") DISPLAY=pager;;

    "--quiet"|"-q") VERBOSITY=quiet;;
    "--verbose"|"-v") VERBOSITY=verbose;;
esac
done

if [ -z "$ACTION" ] ; then
    echo -e "usage:\n\t$0 --pretend(-p) [options]\n\t$0 --ask(-a) [options]\n\t$0 --force(-f) [options]\noptions:\n\t--list(-l) --pager(-L) --quiet(-q) --verbose(-v)"; exit
fi

DCTMPDIR=/tmp/distfiles-clean
CURRENTDIR=$DCTMPDIR/used

[ -n "${DEBUG}" ] && ewarn "using DCTMPDIR=$DCTMPDIR"
[ -n "${DEBUG}" ] && ewarn "using DISTDIR=$DISTDIR"

ebegin "Scanning PKG database"
CURRENT_FILES=$(find /var/db/pkg -name environment.bz2 | xargs bzgrep -h --max-count=1 -e "^A=" | sed -e 's/^A=//' | tr "'\n" "  ")
eend $? Failed
CURRENT_FILES="${CURRENT_FILES} svn-src cvs-src"


ebegin "Building currently-used distfiles directory"
rm -rf ${CURRENTDIR}; mkdir -p ${CURRENTDIR}
for i in ${CURRENT_FILES}; do ln -sf ${DISTDIR}/$i ${CURRENTDIR}/$i; done
eend $? Failed

DIST_FILES=$(ls $DISTDIR)
ebegin "Generating obsolete files list"
OBSOLETE_FILES=$(for i in ${DIST_FILES}; do [ -L ${CURRENTDIR}/$i ] || echo ${DISTDIR}/$i; done)
eend $? Failed

NB_DIST_FILES=$(echo ${DIST_FILES} | wc -w)
NB_OBSOLETE_FILES=$(echo ${OBSOLETE_FILES} | wc -w)
case ${DISPLAY} in
    "list") du -c ${OBSOLETE_FILES};;
    "pager") du -c ${OBSOLETE_FILES} | ${PAGER};;
esac
ewarn "${NB_OBSOLETE_FILES}/${NB_DIST_FILES} files are obsolete"

case ${ACTION} in
    ask)
        echo -n "Do some cleaning [y/n] ? "; read ANS
        if [ "$ANS" != "y" ] ; then
            ewarn "Aborting";
            ACTION=""
        else
            ACTION="proceed"
        fi
        ;;
esac

if [ "${ACTION}" = "proceed" ] ; then

    einfo "Removing obsolete files"
    for i in ${OBSOLETE_FILES} ; do
        [ ${VERBOSITY} = "verbose" ] && echo "<<< " $i
        rm -f $i
    done

fi

ebegin "Cleaning temporary files"
rm -rf ${DCTMPDIR};
eend $? Failed


Enjoy :)

Code:
# ./distfiles-clean
usage:
        ./distfiles-clean --pretend(-p) [options]
        ./distfiles-clean --ask(-a) [options]
        ./distfiles-clean --force(-f) [options]
options:
        --list(-l) --pager(-L) --quiet(-q) --verbose(-v)
Back to top
View user's profile Send private message
zdra
Veteran
Veteran


Joined: 30 Nov 2003
Posts: 1693
Location: Bruxelles, Belgique

PostPosted: Sun Sep 19, 2004 8:42 am    Post subject: Reply with quote

ce genre de script devraient etre intégré dans emerge, ou dans equery ou dans je ne sais quel outil officiel de portage :)

En tout cas merci, tout ça vaut bien un ptit (RESOLU) :D
Back to top
View user's profile Send private message
guilc
Bodhisattva
Bodhisattva


Joined: 15 Nov 2003
Posts: 3326
Location: Paris - France

PostPosted: Sun Sep 19, 2004 3:32 pm    Post subject: Reply with quote

En tous cas, très bien ton script, chapeau !
Il va remplacer avantageusement mon script perl :)

MERCI :)

PS :
D'ailleurs, je rajoute que avec le nouveau portage 2.0.51, mon script perl (dans le lien donné au deuxieme post) ne fonctionne plus, a cause du changement de format de la sortie de "emerge -epf world"... Si jamais y en a qui voulaient l'utiliser :)
_________________
Merci de respecter les règles du forum.

Mon site perso : https://www.xwing.info
Mon PORTDIR_OVERLAY : https://gentoo.xwing.info ou layman -a xwing
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index French All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum