Method: Pkg::Util::Net.rsync_cmd
- Defined in:
- lib/packaging/util/net.rb
.rsync_cmd(origin_path, opts = {}) ⇒ String
Construct a valid rsync command
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/packaging/util/net.rb', line 140 def rsync_cmd(origin_path, opts = {}) = { bin: 'rsync', origin_host: nil, target_path: nil, target_host: nil, extra_flags: nil, dryrun: false }.merge(opts) origin = Pathname.new(origin_path) target = [:target_path] || origin.parent raise(ArgumentError, "Cannot sync between two remote hosts") if [:origin_host] && [:target_host] raise(ArgumentError, "Cannot sync path '#{origin}' because both origin_host and target_host are nil. Perhaps you need to set TEAM=release ?") unless [:origin_host] || [:target_host] cmd = %W[ #{[:bin]} --recursive --hard-links --links --verbose --omit-dir-times --no-perms --no-owner --no-group ] + [*[:extra_flags]] cmd << '--dry-run' if [:dryrun] cmd << Pkg::Util.pseudo_uri(path: origin, host: [:origin_host]) cmd << Pkg::Util.pseudo_uri(path: target, host: [:target_host]) cmd.uniq.compact.join("\s") end |