loopless 0.0.9 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/README.md +20 -2
 - data/darwin/loopless +0 -0
 - data/lib/loopless.rb +47 -10
 - data/linux/loopless +0 -0
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: b43f36a2845005a4c591bec8e591b6cc824fdf36
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: afa83f16ca670d2c59d9172132d7feac2f7d3ecb
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: adac537e193ef467e17fef67b8122d278ffe5d4217c4af75717d71eeb998cf7d6674df2f4daad78cc0783cab1ddb8a8f23180120167b4ac1807ac453718c40cb
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 2bf782f913f39e7f70aea787519a4efc8ae373a646a359035503056f9420e53f4894cb436683cfec27b4633b3e70853e18e1b4475a0bf44c16d4263773e54a77
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -10,9 +10,12 @@ Currently supported on Linux and Mac OS X. 
     | 
|
| 
       10 
10 
     | 
    
         
             
            Synopsis
         
     | 
| 
       11 
11 
     | 
    
         
             
            --------
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
      
 13 
     | 
    
         
            +
            On the command line
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
       13 
15 
     | 
    
         
             
                loopless disk.img create 10000000000 # 10GB
         
     | 
| 
       14 
16 
     | 
    
         
             
                loopless disk.img create-gpt
         
     | 
| 
       15 
17 
     | 
    
         
             
                loopless disk.img create-part
         
     | 
| 
      
 18 
     | 
    
         
            +
                loopless disk.img part-info
         
     | 
| 
       16 
19 
     | 
    
         
             
                loopless disk.img:1 mkfs 
         
     | 
| 
       17 
20 
     | 
    
         
             
                loopless disk.img:1 write /syslinux.cfg 600 <<< "SAY Hello World!" 
         
     | 
| 
       18 
21 
     | 
    
         
             
                loopless disk.img:1 syslinux
         
     | 
| 
         @@ -21,6 +24,21 @@ Synopsis 
     | 
|
| 
       21 
24 
     | 
    
         
             
                loopless disk.img install-mbr
         
     | 
| 
       22 
25 
     | 
    
         
             
                loopless disk.img create-vmdk disk.vmdk
         
     | 
| 
       23 
26 
     | 
    
         | 
| 
      
 27 
     | 
    
         
            +
            Or in Ruby
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                require 'loopless'
         
     | 
| 
      
 30 
     | 
    
         
            +
                Loopless.create("disk.img", 10000000000)
         
     | 
| 
      
 31 
     | 
    
         
            +
                Loopless.create_gpt("disk.img")
         
     | 
| 
      
 32 
     | 
    
         
            +
                Loopless.create_part("disk.img")
         
     | 
| 
      
 33 
     | 
    
         
            +
                p Loopless.part_info("disk.img")
         
     | 
| 
      
 34 
     | 
    
         
            +
                Loopless.mkfs("disk.img", 1)
         
     | 
| 
      
 35 
     | 
    
         
            +
                Loopless.write("disk.img", 1, '/syslinux.cfg', '600', "SAY Hello World!" )
         
     | 
| 
      
 36 
     | 
    
         
            +
                Loopless.syslinux("disk.img", 1)
         
     | 
| 
      
 37 
     | 
    
         
            +
                p Loopless.ls("disk.img",1)
         
     | 
| 
      
 38 
     | 
    
         
            +
                Loopless.set_bootable("disk.img",1, true)
         
     | 
| 
      
 39 
     | 
    
         
            +
                Loopless.install_mbr("disk.img")
         
     | 
| 
      
 40 
     | 
    
         
            +
                Loopless.create_vmdk("disk.img", 'disk.vmdk')
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
       24 
42 
     | 
    
         
             
            Usage
         
     | 
| 
       25 
43 
     | 
    
         
             
            -----
         
     | 
| 
       26 
44 
     | 
    
         | 
| 
         @@ -48,7 +66,7 @@ loopless is comprised of a number of subcommands: 
     | 
|
| 
       48 
66 
     | 
    
         
             
             Sets or unsets the legacy_boot GPT flag on the specified partition. This flag is used by syslinux
         
     | 
| 
       49 
67 
     | 
    
         
             
             to determine the boot partition.
         
     | 
| 
       50 
68 
     | 
    
         | 
| 
       51 
     | 
    
         
            -
            ###  
     | 
| 
      
 69 
     | 
    
         
            +
            ### Ext4
         
     | 
| 
       52 
70 
     | 
    
         | 
| 
       53 
71 
     | 
    
         
             
            PART may either be a single number indicating GPT part number or a comma separated byte range
         
     | 
| 
       54 
72 
     | 
    
         | 
| 
         @@ -76,7 +94,7 @@ FILE must be the absolute path to file, including the initial '/' 
     | 
|
| 
       76 
94 
     | 
    
         
             
             recursively chmod parent directories with MODE + the executable bit set where the read bit is
         
     | 
| 
       77 
95 
     | 
    
         
             
             (e.g. 640 would become 750 for parent directories ).
         
     | 
| 
       78 
96 
     | 
    
         | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
      
 97 
     | 
    
         
            +
            ### Syslinux
         
     | 
| 
       80 
98 
     | 
    
         | 
| 
       81 
99 
     | 
    
         
             
            * `loopless FILE:PART syslinux`
         
     | 
| 
       82 
100 
     | 
    
         | 
    
        data/darwin/loopless
    CHANGED
    
    | 
         Binary file 
     | 
    
        data/lib/loopless.rb
    CHANGED
    
    | 
         @@ -1,4 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Loopless
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       2 
3 
     | 
    
         
             
              class Error < RuntimeError
         
     | 
| 
       3 
4 
     | 
    
         
             
                attr_reader :code
         
     | 
| 
       4 
5 
     | 
    
         
             
                def initialize(code)
         
     | 
| 
         @@ -27,54 +28,90 @@ module Loopless 
     | 
|
| 
       27 
28 
     | 
    
         | 
| 
       28 
29 
     | 
    
         
             
              def self.create(file,size)
         
     | 
| 
       29 
30 
     | 
    
         
             
                run file, 'create', size.to_s
         
     | 
| 
      
 31 
     | 
    
         
            +
                nil
         
     | 
| 
       30 
32 
     | 
    
         
             
              end
         
     | 
| 
       31 
33 
     | 
    
         | 
| 
       32 
34 
     | 
    
         
             
              def self.create_vmdk(file,vmdk_path)
         
     | 
| 
       33 
35 
     | 
    
         
             
                run file, 'create-vmdk', vmdk_path
         
     | 
| 
      
 36 
     | 
    
         
            +
                nil
         
     | 
| 
       34 
37 
     | 
    
         
             
              end
         
     | 
| 
       35 
38 
     | 
    
         | 
| 
       36 
39 
     | 
    
         
             
              def self.create_gpt(file)
         
     | 
| 
       37 
40 
     | 
    
         
             
                run file, 'create-gpt'
         
     | 
| 
      
 41 
     | 
    
         
            +
                nil
         
     | 
| 
       38 
42 
     | 
    
         
             
              end
         
     | 
| 
       39 
43 
     | 
    
         | 
| 
       40 
44 
     | 
    
         
             
              def self.create_part(file, part_num: nil, start: nil, size: nil, label: nil)
         
     | 
| 
       41 
45 
     | 
    
         
             
                run file, 'create-part', *[part_num,start,size,label].compact.map(&:to_s)
         
     | 
| 
      
 46 
     | 
    
         
            +
                nil
         
     | 
| 
       42 
47 
     | 
    
         
             
              end
         
     | 
| 
       43 
48 
     | 
    
         | 
| 
       44 
49 
     | 
    
         
             
              def self.part_info(file)
         
     | 
| 
       45 
     | 
    
         
            -
                run 
     | 
| 
      
 50 
     | 
    
         
            +
                run(file, 'part-info').split("\n").map do |l|
         
     | 
| 
      
 51 
     | 
    
         
            +
                  fields = l.split("\t")
         
     | 
| 
      
 52 
     | 
    
         
            +
                  {
         
     | 
| 
      
 53 
     | 
    
         
            +
                    number: fields[0].to_i,
         
     | 
| 
      
 54 
     | 
    
         
            +
                    start: fields[1].to_i,
         
     | 
| 
      
 55 
     | 
    
         
            +
                    size: fields[2].to_i,
         
     | 
| 
      
 56 
     | 
    
         
            +
                    bootable: fields[3] == 'true',
         
     | 
| 
      
 57 
     | 
    
         
            +
                    label: fields[4] != '' ? fields[4] : nil
         
     | 
| 
      
 58 
     | 
    
         
            +
                  }
         
     | 
| 
      
 59 
     | 
    
         
            +
                end
         
     | 
| 
       46 
60 
     | 
    
         
             
              end
         
     | 
| 
       47 
61 
     | 
    
         | 
| 
       48 
62 
     | 
    
         
             
              def self.install_mbr(file)
         
     | 
| 
       49 
63 
     | 
    
         
             
                run file, 'install-mbr'
         
     | 
| 
      
 64 
     | 
    
         
            +
                nil
         
     | 
| 
       50 
65 
     | 
    
         
             
              end
         
     | 
| 
       51 
66 
     | 
    
         | 
| 
       52 
67 
     | 
    
         
             
              def self.set_bootable(file,part_num,value = true)
         
     | 
| 
       53 
     | 
    
         
            -
                run "#{file}:#{part_num}" " 
     | 
| 
      
 68 
     | 
    
         
            +
                run "#{file}:#{part_num}", "set-bootable", (value ? 'true' : 'false')
         
     | 
| 
      
 69 
     | 
    
         
            +
                nil
         
     | 
| 
       54 
70 
     | 
    
         
             
              end
         
     | 
| 
       55 
71 
     | 
    
         | 
| 
       56 
     | 
    
         
            -
              def self.syslinux(file,part)
         
     | 
| 
      
 72 
     | 
    
         
            +
              def self.syslinux(file,part=nil)
         
     | 
| 
       57 
73 
     | 
    
         
             
                run_part file,part,'syslinux'
         
     | 
| 
      
 74 
     | 
    
         
            +
                nil
         
     | 
| 
       58 
75 
     | 
    
         
             
              end
         
     | 
| 
       59 
76 
     | 
    
         | 
| 
       60 
     | 
    
         
            -
              def self.mkfs(file,part)
         
     | 
| 
      
 77 
     | 
    
         
            +
              def self.mkfs(file,part=nil)
         
     | 
| 
       61 
78 
     | 
    
         
             
                run_part file,part,'mkfs'
         
     | 
| 
      
 79 
     | 
    
         
            +
                nil
         
     | 
| 
       62 
80 
     | 
    
         
             
              end
         
     | 
| 
       63 
81 
     | 
    
         | 
| 
       64 
     | 
    
         
            -
              def self.ls(file,part)
         
     | 
| 
       65 
     | 
    
         
            -
                run_part 
     | 
| 
      
 82 
     | 
    
         
            +
              def self.ls(file,part=nil)
         
     | 
| 
      
 83 
     | 
    
         
            +
                run_part(file,part,'ls').split("\n")
         
     | 
| 
       66 
84 
     | 
    
         
             
              end
         
     | 
| 
       67 
85 
     | 
    
         | 
| 
       68 
     | 
    
         
            -
              def self.rm(file,part,path)
         
     | 
| 
      
 86 
     | 
    
         
            +
              def self.rm(file,part=nil,path)
         
     | 
| 
       69 
87 
     | 
    
         
             
                run_part file,part,'rm',fix_path(path)
         
     | 
| 
      
 88 
     | 
    
         
            +
                nil
         
     | 
| 
       70 
89 
     | 
    
         
             
              end
         
     | 
| 
       71 
90 
     | 
    
         | 
| 
       72 
     | 
    
         
            -
              def self.read(file,part,path)
         
     | 
| 
      
 91 
     | 
    
         
            +
              def self.read(file,part=nil,path)
         
     | 
| 
       73 
92 
     | 
    
         
             
                run_part file,part,'read',fix_path(path)
         
     | 
| 
       74 
93 
     | 
    
         
             
              end
         
     | 
| 
       75 
94 
     | 
    
         | 
| 
       76 
     | 
    
         
            -
              def self.write(file 
     | 
| 
       77 
     | 
    
         
            -
                 
     | 
| 
      
 95 
     | 
    
         
            +
              def self.write(file,*args)#part=nil,path,perm='644',input)
         
     | 
| 
      
 96 
     | 
    
         
            +
                part = nil
         
     | 
| 
      
 97 
     | 
    
         
            +
                perm = '644'
         
     | 
| 
      
 98 
     | 
    
         
            +
                case args.size
         
     | 
| 
      
 99 
     | 
    
         
            +
                when 2 then path,input = args
         
     | 
| 
      
 100 
     | 
    
         
            +
                when 3
         
     | 
| 
      
 101 
     | 
    
         
            +
                  has_perm = args[1].to_s =~ /^[0-8]{3}$/
         
     | 
| 
      
 102 
     | 
    
         
            +
                  has_part = args[0].is_a?(Integer) || args[0].is_a?(Array)
         
     | 
| 
      
 103 
     | 
    
         
            +
                  if has_perm && !has_part
         
     | 
| 
      
 104 
     | 
    
         
            +
                    path,perm,input=args
         
     | 
| 
      
 105 
     | 
    
         
            +
                  elsif !has_perm && has_part
         
     | 
| 
      
 106 
     | 
    
         
            +
                    part,path,input=args
         
     | 
| 
      
 107 
     | 
    
         
            +
                  else
         
     | 
| 
      
 108 
     | 
    
         
            +
                    raise ArgumentError.new "Ambigious arguments"
         
     | 
| 
      
 109 
     | 
    
         
            +
                  end
         
     | 
| 
      
 110 
     | 
    
         
            +
                when 4
         
     | 
| 
      
 111 
     | 
    
         
            +
                  part,path,perm,input = args
         
     | 
| 
      
 112 
     | 
    
         
            +
                end
         
     | 
| 
      
 113 
     | 
    
         
            +
                run_part file,part,'write',fix_path(path),perm.to_s, in: input
         
     | 
| 
      
 114 
     | 
    
         
            +
                nil
         
     | 
| 
       78 
115 
     | 
    
         
             
              end
         
     | 
| 
       79 
116 
     | 
    
         | 
| 
       80 
117 
     | 
    
         
             
              def self.fix_path(path)
         
     | 
    
        data/linux/loopless
    CHANGED
    
    | 
         Binary file 
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: loopless
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Matt Edlefsen
         
     | 
| 
         @@ -23,7 +23,7 @@ files: 
     | 
|
| 
       23 
23 
     | 
    
         
             
            - darwin/loopless
         
     | 
| 
       24 
24 
     | 
    
         
             
            - lib/loopless.rb
         
     | 
| 
       25 
25 
     | 
    
         
             
            - linux/loopless
         
     | 
| 
       26 
     | 
    
         
            -
            homepage: https://gitlab.xforty.com 
     | 
| 
      
 26 
     | 
    
         
            +
            homepage: https://gitlab.xforty.com/projects/loopless
         
     | 
| 
       27 
27 
     | 
    
         
             
            licenses:
         
     | 
| 
       28 
28 
     | 
    
         
             
            - GPL-2.0
         
     | 
| 
       29 
29 
     | 
    
         
             
            metadata: {}
         
     |