pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: make clean vs find work dir and delete



On 05/03/18 16:09, John Nemeth wrote:
On May 1,  1:23pm, Mayuresh wrote:
}
} If I wish to clean pkgsrc area, typically to conserve disk space, I run
} something like this.
}
} # find /usr/pkgsrc -type d -name work -exec rm -rf {} \;
}
} Instead if I do "make clean" in /usr/pkgsrc, which sounds more appropriate
} method, it takes much longer.
}
} I am curious what pkgsrc users would do for above scenario. Or is there
} any way to achieve the result faster.

      I do cd /usr/pkgsrc && rm -r */*/work .  That seems to be the
fastest way.  I suppose one could do something like set PKGOBJDIR(?)
to /usr/pkgobj then just do rm -r /usr/pkgobj.

}-- End of excerpt from Mayuresh

I use the attached scripts.

I'm leaning toward replacing the rm -rf */*/work with a loop containing (cd $pkg && bmake clean).  I think where there's an interface provided for something, it should generally be used and developed rather than reinvented, especially if there may be edge cases.

#!/bin/sh -e

##########################################################################
#   Script description:
#       
#   Arguments:
#       
#   Returns:
#       
#   History:
#   Date        Name        Modification
#   2015-05-13  root        Begin
##########################################################################

usage()
{
    printf "Usage: $0 [pkgsrc-dir]\n"
    exit 1
}


##########################################################################
#   Main
##########################################################################

case $# in
0)
    pkgsrc=`auto-pkgsrc-dir`
    ;;
1)
    pkgsrc="$1"
    ;;
*)
    usage
    ;;
esac


if which pkgin; then
    printf "Cleaning pkg cache...\n"
    pkgin clean
fi

cd "$pkgsrc"

printf "Cleaning $pkgsrc...\n"
if [ `uname` = Linux ]; then
    df_flags=-Pm
else
    df_flags=-m
fi

before=`df $df_flags . | awk '$1 != "Filesystem" { print $4 }'`

for dir in */*/work; do
    printf "$dir\n"
    rm -rf $dir
done

printf "Remove distfiles? y/[n] "
read dist
if [ 0$dist = 0y ]; then
    rm -rf distfiles/*
fi

after=`df $df_flags . | awk '$1 != "Filesystem" { print $4 }'`
printf "Initial free space: %d\n" $before
printf "Final free space: %d\n" $after
diff=$(($after - $before))
printf "%d megabytes freed.\n" $diff
#!/bin/sh -e

prefix=`auto-pkgsrc-prefix`
printf ${prefix} | sed 's|pkg|pkgsrc|'


Home | Main Index | Thread Index | Old Index