diskman 1.0.9 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 356141ac045d586f1d8dec632762474496de583c2cd1f9199b392ad273baf123
4
- data.tar.gz: '09057fecdaa82c8fddac9a7ed21c2d172f0cc1e342331d226967f908e0330906'
3
+ metadata.gz: 7fc1b38621654bc6c54e2c341508f7a34bad56edea11e3d6a1430fb386aa7998
4
+ data.tar.gz: ef7d21e5d8fd39f346e755fd8cc961c38d0b0f90fbd1a8a8326faacd5021ce39
5
5
  SHA512:
6
- metadata.gz: 1c5c298f9849ef5e25d952b8bc782749c2b98075ef9289f2379f708932c4041bb301cb22dcbe0fa90337fae41103af8b8f9c0079ba7a414935222094b621ffc7
7
- data.tar.gz: e840f6c4bb49c3a6f8559494986c082515d3ff8f8c9b705d9d4f9a32bd9794308e21d6044296a03c5dd8305f34a626ce10d2aeb7cfb488491c1931bc9da9d4cb
6
+ metadata.gz: 1633d95b48a889716644ec065f124add986f10eaa11ed8386b4c64cf354bcf0a909231e00d727637ff6f2821fe1282cf7f2e37a7ce648c3bfe58224c86ac298d
7
+ data.tar.gz: 6e3d1a87a326e762cef359c67ba782f87a63f8f8f658b6dadbb21f3bf6ad2c13e1db6aaf550759384f6ba699f7deb5f0422ff1982ac68aff04709fc05c26301f
data/bin/diskman CHANGED
@@ -8,6 +8,7 @@ Params = Struct.new(
8
8
  :version,
9
9
  :list,
10
10
  :write,
11
+ :clone,
11
12
  :fdisk,
12
13
  :mkfs,
13
14
  :file,
@@ -28,6 +29,7 @@ class Main
28
29
  version: @opts['--version'],
29
30
  list: @opts['--list'],
30
31
  write: @opts['write'],
32
+ clone: @opts['clone'],
31
33
  fdisk: @opts['fdisk'],
32
34
  mkfs: @opts['mkfs'],
33
35
  file: @opts['<file>'],
@@ -44,6 +46,8 @@ class Main
44
46
  Command::Mkfs.new.run(list: params.list)
45
47
  elsif params.write
46
48
  Command::Write.new.run(file: params.file)
49
+ elsif params.clone
50
+ Command::Clone.new.run(file: params.file)
47
51
  elsif params.fdisk
48
52
  Command::Fdisk.new.run
49
53
  end
@@ -51,16 +55,19 @@ class Main
51
55
  end
52
56
  end
53
57
 
58
+ PROGRAM_NAME = File.basename($PROGRAM_NAME)
59
+
54
60
  usage = <<~EOF
55
61
  Usage:
56
- #{File.basename($0)} write <file>
57
- #{File.basename($0)} fdisk
58
- #{File.basename($0)} mkfs [--list]
59
- #{File.basename($0)} ( --version | --help )
62
+ #{PROGRAM_NAME} write <file>
63
+ #{PROGRAM_NAME} clone <file>
64
+ #{PROGRAM_NAME} fdisk
65
+ #{PROGRAM_NAME} mkfs [--list]
66
+ #{PROGRAM_NAME} ( --version | --help )
60
67
 
61
68
  Options:
62
69
  -v, --version Show version
63
- -h, --help Show this help
70
+ -h, --help Show help
64
71
  EOF
65
72
 
66
73
  begin
@@ -0,0 +1,19 @@
1
+ module Command
2
+ class Clone
3
+ def run(file:)
4
+ if File.exist?(file)
5
+ puts ('File exists: ' + file).red
6
+ raise Interrupt
7
+ end
8
+
9
+ device = RootDevice.choose
10
+ cmd = device.get_clone_command(file)
11
+
12
+ puts "File: #{file.yellow}"
13
+ puts "Device: #{device.to_s.yellow}"
14
+ puts "Command: #{cmd.yellow}"
15
+
16
+ System.exec!(cmd)
17
+ end
18
+ end
19
+ end
@@ -17,8 +17,13 @@ module Diskman
17
17
  end
18
18
 
19
19
  def get_write_command(path)
20
- dd = 'sudo dd if="%s" of="%s" bs=%dK status=progress'
21
- dd % [path, @path, 4096]
20
+ dd = 'sudo dd if="%s" of="%s" bs=%dM status=progress conv=fsync'
21
+ dd % [path, @path, 4]
22
+ end
23
+
24
+ def get_clone_command(path)
25
+ dd = 'sudo dd if="%s" of="%s" bs=%dM status=progress conv=fsync'
26
+ dd % [@path, path, 4]
22
27
  end
23
28
 
24
29
  def to_s
@@ -1,19 +1,10 @@
1
1
  module Diskman
2
2
  module System
3
- # If sudo prompts for the password when a pipeline with pv has already
4
- # started then we're unable to enter the password. Run sudo --validate
5
- # first to ensure that we are preauthenticated.
6
- def self.prepare_sudo_session!
7
- system('sudo --validate')
8
- end
9
-
10
3
  # Execute a command.
11
- # If sudo is true, ensures sudo is ready before running the command.
12
- # If safe is true, ensures the user definitely wants to run the command
13
- # before running it.
14
- def self.exec!(cmd, safe: true, sudo: true)
4
+ #
5
+ # If safe is true, ensures the user definitely wants to run the command before running it.
6
+ def self.exec!(cmd, safe: true)
15
7
  Confirmer.check! if safe
16
- prepare_sudo_session! if sudo
17
8
  puts
18
9
  exec(cmd)
19
10
  end
@@ -22,8 +13,7 @@ module Diskman
22
13
  def self.bytes2human(b)
23
14
  return '0B' if b <= 0
24
15
 
25
- # Use 1000 to match the misleading way disk capacities are
26
- # advertised.
16
+ # Use 1000 to match the misleading way disk capacities are advertised.
27
17
  k = 1000
28
18
 
29
19
  suffixes = %w[T G M K B]
@@ -1,3 +1,3 @@
1
1
  module Diskman
2
- VERSION = '1.0.9'
2
+ VERSION = '1.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diskman
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - crdx
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-17 00:00:00.000000000 Z
11
+ date: 2023-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -104,6 +104,7 @@ files:
104
104
  - bin/diskman
105
105
  - lib/diskman.rb
106
106
  - lib/diskman/chooser.rb
107
+ - lib/diskman/commands/clone.rb
107
108
  - lib/diskman/commands/fdisk.rb
108
109
  - lib/diskman/commands/mkfs.rb
109
110
  - lib/diskman/commands/write.rb
@@ -115,7 +116,7 @@ files:
115
116
  - lib/diskman/version.rb
116
117
  homepage: https://github.com/crdx/diskman
117
118
  licenses:
118
- - MIT
119
+ - GPLv3
119
120
  metadata:
120
121
  rubygems_mfa_required: 'true'
121
122
  post_install_message:
@@ -133,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
134
  - !ruby/object:Gem::Version
134
135
  version: '0'
135
136
  requirements: []
136
- rubygems_version: 3.2.29
137
+ rubygems_version: 3.3.25
137
138
  signing_key:
138
139
  specification_version: 4
139
140
  summary: Interactive command line interface for safely managing disks