[andrew@walrond.org: Another ruby-vim indent problem]

Gavin Sinclair gsinclair at soyabean.com.au
Tue May 3 04:31:18 EDT 2005


On Tuesday, May 3, 2005, 2:04:05 PM, Doug wrote:

> The attached file ends up way over to the right...

> [forwarded from] Andrew

Reproduced inline with my indentation settings below.

There are a couple of problems with this one.
 - line 8: very odd that it's not indented correctly
 - line 16 etc.: perhaps this comes from vim not looking far enough
                 back to work out where to start the line (no, don't
                 think so - deleting intermediate lines doesn't help)
 - line 25 etc.: lots of blank lines (not an indenting issue)
 - line 125-6: same indenting issue as line 8 - bizzare

As per the other issue, not much I can offer except consolation and
advice: write smaller methods to isolate the code fragments from each
other.

I'll try to understand what's causing these problems and fix it, but
there's not much chance I'll get anywhere.

Gavin

-----------------------------------------------------------------------

     1  # Populate the root filesystem with the basic directories and files.
     2  # Only used during bootstrap.
     3  #
     4  def populate_fs()
     5    puts('Populating root filesystem')
     6    $root.cd {
     7      umask(0) {
     8      %w{ dev etc home include lib mnt pkg proc share sys }.each { |d| d.mkdir(0755) }
     9      'etc/fstab'.ftouch('#<fs>        <mountpoint>  <type>   <opts>        <backup?> <pass #>',
    10                         '#/dev/hda1    /             ext3     noatime          0        1',
    11                         '#/dev/hda2    /mnt/root2    ext3     noauto,noatime   1        2',
    12                         '#/dev/hda3    none          swap     sw               0        0',
    13                         '#/dev/hda4    /home         ext3     noatime          1        2',
    14                         '#/dev/hdc1    /mnt/cdrom    iso9660  noauto,ro        0        0'
    15                        ).chmod(0644)
    16                        'etc/hosts'.ftouch('# Hostname-to-address mappings for the TCP/IP subsystem',
    17                                           '# IP address     FQDN             Alias(es)',
    18                                           '127.0.0.1        localhost',
    19                                           '127.0.0.1        heretic.local-domain'
    20                                          ).chmod(0644)
    21                                          'etc/host.conf'.ftouch('# Resolver configuration file',
    22                                                                 'order hosts,bind',
    23                                                                 'multi on'
    24                                                                ).chmod(0644)
    25  
    26                                                                'etc/mtab'.ftouch('').chmod(0644)
    27  
    28                                                                'etc/networks'.ftouch('# Netname-to-address mappings for the TCP/IP subsystem',
    29  
    30                                                                                      '# Netname  IP address',
    31  
    32                                                                                      'loopback   127.0.0.1'
    33  
    34                                                                                     ).chmod(0644)
    35  
    36                                                                                     'etc/nsswitch.conf'.ftouch('passwd:         db files',
    37  
    38                                                                                                                'group:          db files',
    39  
    40                                                                                                                'shadow:         db files',
    41  
    42                                                                                                                'hosts:          files dns',
    43  
    44                                                                                                                'networks:       files dns',
    45  
    46                                                                                                                'protocols:      db files',
    47  
    48                                                                                                                'services:       db files',
    49  
    50                                                                                                                'ethers:         db files',
    51  
    52                                                                                                                'rpc:            db files',
    53  
    54                                                                                                                'netgroup:       db files'
    55  
    56                                                                                                               ).chmod(0644)
    57  
    58                                                                                                               'etc/protocols'.ftouch('# Protocols available from the TCP/IP subsystem.',
    59  
    60                                                                                                                                      'ip      0       IP      # internet protocol, pseudo protocol number',
    61  
    62                                                                                                                                      'icmp    1       ICMP    # internet control message protocol',
    63  
    64                                                                                                                                      'igmp    2       IGMP    # internet group multicast protocol',
    65  
    66                                                                                                                                      'ggp     3       GGP     # gateway-gateway protocol',
    67  
    68                                                                                                                                      'tcp     6       TCP     # transmission control protocol',
    69  
    70                                                                                                                                      'pup     12      PUP     # PARC universal packet protocol',
    71  
    72                                                                                                                                      'udp     17      UDP     # user datagram protocol',
    73  
    74                                                                                                                                      'idp     22      IDP     # WhatsThis?',
    75  
    76                                                                                                                                      'raw     255     RAW     # RAW IP interface'
    77  
    78                                                                                                                                     ).chmod(0644)
    79  
    80                                                                                                                                     'etc/resolv.conf'.ftouch().chmod(0644)
    81  
    82                                                                                                                                     unless 'etc/services'.exists?
    83  
    84                                                                                                                                       path(HERETIXDIR,'port-numbers').cp('etc/services')
    85  
    86                                                                                                                                       'etc/services'.fedit { |line|
    87  
    88                                                                                                                                         line.gsub!("\C-M","")
    89  
    90                                                                                                                                         if line =~ /(^\S+)\s+(\d+)\/(\S+)\s+(\S+|$)/
    91  
    92                                                                                                                                           sname,sport,sencap,sdesc = $1,$2,$3,$4
    93  
    94                                                                                                                                           line.replace "#{$1.ljust(20)} #{$2.rjust(5)}/#{$3.ljust(6)}##{$4}\n"
    95  
    96                                                                                                                                         else
    97  
    98                                                                                                                                           line.replace("#"+line) unless line[0]==?#
    99  
   100                                                                                                                                         end
   101  
   102  
   103                                                                                                                                     end
   104  
   105                                                                                                                                     'home/public'.mkdir(01777)
   106  
   107                                                                                                                                     'home/root'.mkdir(0700)
   108  
   109                                                                                                                                     'pkg/.snapshot'.mkdir(0755)
   110  
   111                                                                                                                                     'tmp'.mkdir.chmod(01777)
   112  
   113                                                                                                                                     'usr'.symlink('.')
   114                                                                                                                                       }
   115    }
   116  end
   117  
   118  
   119  # Create the basic device files in /dev. Heretix uses hotplug/udev when booting normally,
   120  # but these devices are needed during early boot, bootstrap and chroot operation.
   121  #
   122  def make_devices()
   123    puts('Populating /dev')
   124    $root.cd {
   125      umask(0) {
   126      'dev'.cd {
   127      %w{ shm pts input rd usb isdn cpu cpu/0 cpu/1 i2o net watchdogs dri }.each { |d| d.mkdir(0755) }
   128  
   129      # Load the devices file
   130      devices = path(HERETIXDIR,'devices').fread()
   131  
   132      devices.each { |line|
   133        next unless line =~ /(\S+)\s+(\S+)\s+(\S+)\s+(\d+)\s+(\S)\s+(\d+)\s+(\d+)/
   134        raise 'makedev' unless $1.exists? or system("mknod --mode #{$4} #{$1} #{$5} #{$6} #{$7}")
   135        $1.chown(User[$2].uid,Group[$3].gid)
   136      }
   137  
   138      {
   139        '/proc/self/fd'=>'fd','fd/0'=>'stdin','fd/1'=>'stdout','fd/2'=>'stderr',
   140        '/proc/kcore'=>'core','ram0'=>'ramdisk'
   141      }.each { |s,d| d.symlink(s) }
   142    }
   143    }
   144    }
   145  end
   146  



More information about the vim-ruby-devel mailing list