williamr/delete_builds.pl
author William Roberts <williamr@symbian.org>
Thu, 30 Sep 2010 11:52:34 +0100
changeset 297 c52fbeec9580
parent 291 66b0448c2de4
permissions -rw-r--r--
Add naviengine.nec and codecs.aricent to the package lists
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
281
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
     1
#! perl
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
     2
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
     3
# Copyright (c) 2010 Symbian Foundation Ltd
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
     4
# This component and the accompanying materials are made available
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
     6
# which accompanies this distribution, and is available
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
     8
#
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
     9
# Initial Contributors:
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    10
# Symbian Foundation Ltd - initial contribution.
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    11
# 
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    12
# Contributors:
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    13
#
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    14
# Description:
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    15
# Delete a directory full of builds, making space as quickly as possible by
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    16
# deleting known regions of massive files first
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    17
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    18
use strict;
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    19
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    20
# List directory subtrees containing mostly big files, biggest first
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    21
my @rich_pickings = (
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    22
  'output/zips',
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    23
  'output/logs',
291
66b0448c2de4 Add more high-density subtrees
William Roberts <williamr@symbian.org>
parents: 282
diff changeset
    24
  'epoc32/release/armv5/udeb',
66b0448c2de4 Add more high-density subtrees
William Roberts <williamr@symbian.org>
parents: 282
diff changeset
    25
  # Would be worth finding and deleting just the armv5 subtrees in epoc32\build
66b0448c2de4 Add more high-density subtrees
William Roberts <williamr@symbian.org>
parents: 282
diff changeset
    26
  'epoc32/build/avkon',
66b0448c2de4 Add more high-density subtrees
William Roberts <williamr@symbian.org>
parents: 282
diff changeset
    27
  'epoc32/build/hitchcock',
66b0448c2de4 Add more high-density subtrees
William Roberts <williamr@symbian.org>
parents: 282
diff changeset
    28
  'epoc32/build/aknlayout2',
66b0448c2de4 Add more high-density subtrees
William Roberts <williamr@symbian.org>
parents: 282
diff changeset
    29
  'epoc32/build/hb',
66b0448c2de4 Add more high-density subtrees
William Roberts <williamr@symbian.org>
parents: 282
diff changeset
    30
  'epoc32/build/qt',
66b0448c2de4 Add more high-density subtrees
William Roberts <williamr@symbian.org>
parents: 282
diff changeset
    31
  'epoc32/build/browserui',
66b0448c2de4 Add more high-density subtrees
William Roberts <williamr@symbian.org>
parents: 282
diff changeset
    32
  'sf/mw/uiresources/layouts',
66b0448c2de4 Add more high-density subtrees
William Roberts <williamr@symbian.org>
parents: 282
diff changeset
    33
  'epoc32/release/tools2',
66b0448c2de4 Add more high-density subtrees
William Roberts <williamr@symbian.org>
parents: 282
diff changeset
    34
  'epoc32/data/media',
66b0448c2de4 Add more high-density subtrees
William Roberts <williamr@symbian.org>
parents: 282
diff changeset
    35
  'sf/os/security/securityanddataprivacytools/securitytools/openssllib',
66b0448c2de4 Add more high-density subtrees
William Roberts <williamr@symbian.org>
parents: 282
diff changeset
    36
  'sf/mw/appinstall/secureswitools/openssllib',
66b0448c2de4 Add more high-density subtrees
William Roberts <williamr@symbian.org>
parents: 282
diff changeset
    37
  'sf/os/mm/mmapitest/mmsvs/testdata/mmf',
66b0448c2de4 Add more high-density subtrees
William Roberts <williamr@symbian.org>
parents: 282
diff changeset
    38
  'sf/os/mm/devsound/a3fintegrationtest',
66b0448c2de4 Add more high-density subtrees
William Roberts <williamr@symbian.org>
parents: 282
diff changeset
    39
  'sf/app/homescreentools',
66b0448c2de4 Add more high-density subtrees
William Roberts <williamr@symbian.org>
parents: 282
diff changeset
    40
  'sf/mw/qt',
66b0448c2de4 Add more high-density subtrees
William Roberts <williamr@symbian.org>
parents: 282
diff changeset
    41
  'sf/os/deviceplatformrelease',
66b0448c2de4 Add more high-density subtrees
William Roberts <williamr@symbian.org>
parents: 282
diff changeset
    42
  'epoc32/release/winscw/udeb',
66b0448c2de4 Add more high-density subtrees
William Roberts <williamr@symbian.org>
parents: 282
diff changeset
    43
  'rnd'
281
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    44
  );
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    45
  
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    46
if (scalar @ARGV == 0)
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    47
  {
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    48
  print <<'EOF';
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    49
Usage: perl delete_builds.pl dir1 [dir2 ...]
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    50
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    51
Delete one or more builds, making free space as quickly as possible
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    52
by deleting a few selected directories first
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    53
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    54
You can use wildcards in the directory names, and they can be either
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    55
individual builds or directories of builds. A build is identified by
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    56
the present of an "output" subdirectory. 
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    57
EOF
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    58
  exit(1);
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    59
  }
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    60
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    61
my @builds = ();
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    62
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    63
@ARGV = map {glob} @ARGV;
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    64
foreach my $dir (@ARGV)
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    65
  {
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    66
  $dir =~ s/\\/\//g;  # unix separators
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    67
  $dir =~ s/\/+$//;   # remove trailing /
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    68
  if (!-d $dir)
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    69
    {
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    70
    print "Ignoring $dir - not a directory\n";
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    71
    next;
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    72
    }
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    73
  if (!-d "$dir/output")
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    74
    {
282
a265a2da5fcb Fix handling of directories of builds
William Roberts <williamr@symbian.org>
parents: 281
diff changeset
    75
    # not a build - perhaps a directory of builds?
a265a2da5fcb Fix handling of directories of builds
William Roberts <williamr@symbian.org>
parents: 281
diff changeset
    76
    opendir DIR, $dir;
a265a2da5fcb Fix handling of directories of builds
William Roberts <williamr@symbian.org>
parents: 281
diff changeset
    77
    my @files = grep !/^\.\.?$/, readdir DIR;
a265a2da5fcb Fix handling of directories of builds
William Roberts <williamr@symbian.org>
parents: 281
diff changeset
    78
    closedir DIR;
a265a2da5fcb Fix handling of directories of builds
William Roberts <williamr@symbian.org>
parents: 281
diff changeset
    79
    
a265a2da5fcb Fix handling of directories of builds
William Roberts <williamr@symbian.org>
parents: 281
diff changeset
    80
    my @subbuilds = ();
a265a2da5fcb Fix handling of directories of builds
William Roberts <williamr@symbian.org>
parents: 281
diff changeset
    81
    foreach my $file (@files)
a265a2da5fcb Fix handling of directories of builds
William Roberts <williamr@symbian.org>
parents: 281
diff changeset
    82
      {
a265a2da5fcb Fix handling of directories of builds
William Roberts <williamr@symbian.org>
parents: 281
diff changeset
    83
      next if (!-d "$dir/$file");
a265a2da5fcb Fix handling of directories of builds
William Roberts <williamr@symbian.org>
parents: 281
diff changeset
    84
      next if (!-d "$dir/$file/output");
a265a2da5fcb Fix handling of directories of builds
William Roberts <williamr@symbian.org>
parents: 281
diff changeset
    85
      push @subbuilds, "$dir/$file";
a265a2da5fcb Fix handling of directories of builds
William Roberts <williamr@symbian.org>
parents: 281
diff changeset
    86
      }
a265a2da5fcb Fix handling of directories of builds
William Roberts <williamr@symbian.org>
parents: 281
diff changeset
    87
    if (scalar @subbuilds == 0)
a265a2da5fcb Fix handling of directories of builds
William Roberts <williamr@symbian.org>
parents: 281
diff changeset
    88
      {
a265a2da5fcb Fix handling of directories of builds
William Roberts <williamr@symbian.org>
parents: 281
diff changeset
    89
      print "Ignoring $dir - not a build and contains no builds\n";
a265a2da5fcb Fix handling of directories of builds
William Roberts <williamr@symbian.org>
parents: 281
diff changeset
    90
      next;
a265a2da5fcb Fix handling of directories of builds
William Roberts <williamr@symbian.org>
parents: 281
diff changeset
    91
      }
a265a2da5fcb Fix handling of directories of builds
William Roberts <williamr@symbian.org>
parents: 281
diff changeset
    92
    push @builds, @subbuilds;
281
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    93
    }
282
a265a2da5fcb Fix handling of directories of builds
William Roberts <williamr@symbian.org>
parents: 281
diff changeset
    94
  else
a265a2da5fcb Fix handling of directories of builds
William Roberts <williamr@symbian.org>
parents: 281
diff changeset
    95
    {
a265a2da5fcb Fix handling of directories of builds
William Roberts <williamr@symbian.org>
parents: 281
diff changeset
    96
    push @builds, $dir;
a265a2da5fcb Fix handling of directories of builds
William Roberts <williamr@symbian.org>
parents: 281
diff changeset
    97
    }
281
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    98
  }
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
    99
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
   100
foreach my $subdir (@rich_pickings)
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
   101
  {
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
   102
  foreach my $build (@builds)
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
   103
    {
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
   104
    my $victim = "$build/$subdir";
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
   105
    next if (!-d $victim);  # nothing to delete
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
   106
    $victim =~ s/\//\\/g;   # windows separators again (sigh!)
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
   107
    print "* rmdir /s/q $victim\n";
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
   108
    system("rmdir","/s/q",$victim);
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
   109
    }
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
   110
  }
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
   111
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
   112
foreach my $build (@builds)
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
   113
  {
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
   114
  $build =~ s/\//\\/g;
282
a265a2da5fcb Fix handling of directories of builds
William Roberts <williamr@symbian.org>
parents: 281
diff changeset
   115
  print "* rmdir /s/q $build\n";
281
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
   116
  system("rmdir","/s/q",$build);   
c62bd4f9dbce Add delete_builds.pl - a utility for making space quickly on build machines
William Roberts <williamr@symbian.org>
parents:
diff changeset
   117
  }