source: branches/contrib/bitten/scripts/clean.sh @ 429

Last change on this file since 429 was 429, checked in by amain, 10 years ago

bitten: fix clean script keep-last feature to actually preserve the last build

  • Property svn:executable set to *
File size: 1.3 KB
Line 
1#!/bin/bash
2#
3# Copyright (C) 2012 Johan van Zoomeren <amain@debwrt.net>
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18if [ "${2}" == "" ]
19then
20cat <<EOF
21usage: $(basename $0) method architecture:system:profile
22
23   method       keep-last: keep last build in <build-dir>
24   architecture mips, mipsel, ...
25   system       ar71xx, ...
26   profile      ubntrspro, ....
27
28example:
29
30  clean.sh keep-last mips:ar71xx:ubntrspro
31
32EOF
33   
34   exit 1
35fi
36
37
38method=${1}
39work=~/build/${2//:/\/}
40
41function keep-last()
42{
43   echo "I: cleaning directory ${work}"
44
45   find ${work} -maxdepth 1 -name "build_user*"  \
46     | sort \
47     | head -n -2 \
48     | while read dir
49       do
50          echo -n "   ${dir}..."
51          sudo rm -rf ${dir}
52          echo "done"
53       done
54}
55
56${method}
57
Note: See TracBrowser for help on using the repository browser.