View previous topic :: View next topic |
Author |
Message |
zdra Veteran


Joined: 30 Nov 2003 Posts: 1693 Location: Bruxelles, Belgique
|
Posted: Sat Sep 18, 2004 10:57 am Post subject: [PORTAGE] administrer les distfiles (RESOLU) |
|
|
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 |
|
 |
ghoti Advocate


Joined: 30 Dec 2002 Posts: 3636 Location: Belgium
|
Posted: Sat Sep 18, 2004 12:12 pm Post subject: |
|
|
Tu pourras peut-être piocher des idées dans ce thread ... |
|
Back to top |
|
 |
gim Guru


Joined: 29 Apr 2003 Posts: 418 Location: milky-way
|
Posted: Sat Sep 18, 2004 2:01 pm Post subject: |
|
|
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 |
|
 |
zdra Veteran


Joined: 30 Nov 2003 Posts: 1693 Location: Bruxelles, Belgique
|
Posted: Sat Sep 18, 2004 3:45 pm Post subject: |
|
|
en effet c'est ce que je cherchais ! MERCI !  |
|
Back to top |
|
 |
sireyessire Advocate


Joined: 20 Mar 2003 Posts: 2991 Location: back in Paris, France
|
Posted: Sat Sep 18, 2004 3:51 pm Post subject: |
|
|
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  _________________ I never think of the future. It comes soon enough.
Albert Einstein
Try simpler first
Shockley |
|
Back to top |
|
 |
CryoGen Veteran


Joined: 11 Feb 2004 Posts: 1426 Location: Bamako - Mali - Afrique
|
Posted: Sat Sep 18, 2004 4:24 pm Post subject: |
|
|
Excellent ce script adopté  _________________ - CryoGen` on #gentoofr@irc.freenode.net
- ~amd64 / KDE4
- I'm the bone of my sword... |
|
Back to top |
|
 |
gim Guru


Joined: 29 Apr 2003 Posts: 418 Location: milky-way
|
Posted: Sat Sep 18, 2004 10:00 pm Post subject: |
|
|
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 |
|
 |
zdra Veteran


Joined: 30 Nov 2003 Posts: 1693 Location: Bruxelles, Belgique
|
Posted: Sun Sep 19, 2004 8:42 am Post subject: |
|
|
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)  |
|
Back to top |
|
 |
guilc Bodhisattva


Joined: 15 Nov 2003 Posts: 3326 Location: Paris - France
|
Posted: Sun Sep 19, 2004 3:32 pm Post subject: |
|
|
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 |
|
 |
|