tpkg 2.3.3 → 2.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/Portfile +39 -0
- data/Portfile.template +39 -0
- data/README.md +43 -0
- data/Rakefile +468 -18
- data/bin/gem2tpkg +2 -2
- data/bin/tpkg +18 -13
- data/bin/tpkg_uploader +132 -0
- data/ca.pem +1 -0
- data/control +7 -0
- data/depend +3 -0
- data/externals-etch/authorized_keys +40 -0
- data/externals-etch/group +9 -0
- data/externals-etch/iptables +38 -0
- data/externals-etch/limits +30 -0
- data/externals-etch/nfs +30 -0
- data/externals-etch/sudo +30 -0
- data/externals-etch/supplemental_groups +8 -0
- data/externals-etch/sysctl +30 -0
- data/externals-etch/user +41 -0
- data/externals/group +39 -0
- data/externals/supplemental_groups +48 -0
- data/externals/user +39 -0
- data/lib/tpkg.rb +260 -991
- data/lib/tpkg/os.rb +164 -0
- data/lib/tpkg/os/debian.rb +159 -0
- data/lib/tpkg/os/freebsd.rb +113 -0
- data/lib/tpkg/os/macosx.rb +113 -0
- data/lib/tpkg/os/redhat.rb +173 -0
- data/lib/tpkg/os/solaris.rb +101 -0
- data/lib/tpkg/os/windows.rb +26 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify.rb +67 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/errors.rb +127 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/kwalify.schema.yaml +58 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/main.rb +442 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/messages.rb +173 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/meta-validator.rb +275 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/parser/base.rb +127 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/parser/yaml.rb +841 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/rule.rb +559 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/templates/genclass-java.eruby +222 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/templates/genclass-php.eruby +104 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/templates/genclass-ruby.eruby +113 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/types.rb +156 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util.rb +158 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/assert-text-equal.rb +46 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/hash-interface.rb +18 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/hashlike.rb +51 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/option-parser.rb +220 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/ordered-hash.rb +57 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/testcase-helper.rb +112 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/validator.rb +282 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/yaml-parser.rb +870 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh.rb +219 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/agent.rb +179 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/constants.rb +18 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/key_manager.rb +219 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/methods/abstract.rb +60 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/methods/hostbased.rb +71 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/methods/keyboard_interactive.rb +66 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/methods/password.rb +39 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/methods/publickey.rb +92 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/pageant.rb +183 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/session.rb +134 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/buffer.rb +340 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/buffered_io.rb +198 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/config.rb +205 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/connection/channel.rb +630 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/connection/constants.rb +33 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/connection/session.rb +597 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/connection/term.rb +178 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/errors.rb +85 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/key_factory.rb +102 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/known_hosts.rb +129 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/loggable.rb +61 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/packet.rb +102 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/prompt.rb +93 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/proxy/command.rb +75 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/proxy/errors.rb +14 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/proxy/http.rb +94 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/proxy/socks4.rb +70 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/proxy/socks5.rb +142 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/ruby_compat.rb +43 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/service/forward.rb +288 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test.rb +89 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test/channel.rb +129 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test/extensions.rb +152 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test/kex.rb +44 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test/local_packet.rb +51 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test/packet.rb +81 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test/remote_packet.rb +38 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test/script.rb +157 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test/socket.rb +64 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/algorithms.rb +384 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/cipher_factory.rb +97 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/constants.rb +30 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/hmac.rb +31 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/hmac/abstract.rb +79 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/hmac/md5.rb +12 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/hmac/md5_96.rb +11 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/hmac/none.rb +15 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/hmac/sha1.rb +13 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/hmac/sha1_96.rb +11 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/identity_cipher.rb +55 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/kex.rb +13 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +208 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +77 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/openssl.rb +127 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/packet_stream.rb +235 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/server_version.rb +71 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/session.rb +276 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/state.rb +206 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/verifiers/lenient.rb +30 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/verifiers/null.rb +12 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/verifiers/strict.rb +53 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/version.rb +62 -0
- data/lib/tpkg/version.rb +3 -0
- data/man/man1/cpan2tpkg.1 +82 -0
- data/man/man1/gem2tpkg.1 +120 -0
- data/man/man1/tpkg.1 +411 -0
- data/pkginfo +8 -0
- data/postinstall.solaris +11 -0
- data/postremove.solaris +16 -0
- data/schema/schema-1.0.5.yml +0 -0
- data/schema/schema-1.0.6.yml +0 -0
- data/schema/schema-1.0.7.yml +0 -0
- data/schema/schema-1.0.8.yml +0 -0
- data/schema/schema-1.0.9.yml +0 -0
- data/schema/schema.yml +0 -0
- data/schema/tpkg-1.0.0.dtd +0 -0
- data/schema/tpkg-1.0.1.dtd +0 -0
- data/schema/tpkg-1.0.2.dtd +0 -0
- data/schema/tpkg-1.0.3.dtd +0 -0
- data/schema/tpkg-1.0.4.dtd +0 -0
- data/schema/tpkg-1.0.5.dtd +0 -0
- data/schema/tpkg-1.0.6.dtd +0 -0
- data/schema/tpkg-1.0.7.dtd +0 -0
- data/schema/tpkg-1.0.8.dtd +0 -0
- data/schema/tpkg-1.0.9.dtd +0 -0
- data/schema/tpkg.dtd +0 -0
- data/test/TODO +30 -0
- data/test/premadetestpkg/pkg_without_file_metadata-1.0-1.tpkg +0 -0
- data/test/test_checksum.rb +53 -0
- data/test/test_compress.rb +55 -0
- data/test/test_conflict.rb +41 -0
- data/test/test_crontabs.rb +398 -0
- data/test/test_dependency.rb +1113 -0
- data/test/test_downgrade.rb +80 -0
- data/test/test_download.rb +95 -0
- data/test/test_encrypt.rb +136 -0
- data/test/test_filemetadata.rb +131 -0
- data/test/test_initscript.rb +93 -0
- data/test/test_install.rb +186 -0
- data/test/test_lock.rb +82 -0
- data/test/test_make.rb +410 -0
- data/test/test_metadata.rb +805 -0
- data/test/test_misc.rb +379 -0
- data/test/test_options.rb +1711 -0
- data/test/test_os.rb +193 -0
- data/test/test_os_debian.rb +99 -0
- data/test/test_os_freebsd.rb +89 -0
- data/test/test_os_macosx.rb +79 -0
- data/test/test_os_redhat.rb +124 -0
- data/test/test_os_solaris.rb +85 -0
- data/test/test_os_windows.rb +26 -0
- data/test/test_query.rb +134 -0
- data/test/test_remove.rb +539 -0
- data/test/test_tar.rb +99 -0
- data/test/test_unpack.rb +977 -0
- data/test/test_upgrade.rb +398 -0
- data/test/test_version.rb +54 -0
- data/test/testcmds/crontab +14 -0
- data/test/testcmds/debian/apt-cache +145 -0
- data/test/testcmds/debian/dpkg-query +16 -0
- data/test/testcmds/freebsd/pkg_info +13 -0
- data/test/testcmds/macosx/port +35 -0
- data/test/testcmds/redhat/rpmbuild +6 -0
- data/test/testcmds/redhat/yum +90 -0
- data/test/testcmds/solaris/pkginfo +25 -0
- data/test/testcmds/solaris/pkgutil +36 -0
- data/test/testpkg/reloc/encfile +2 -0
- data/test/testpkg/reloc/file +2 -0
- data/test/testpkg/reloc/precryptfile +1 -0
- data/test/testpkg/reloc/precryptfile.plaintext +3 -0
- data/test/testpkg/tpkg-bad-ownergroup.xml +25 -0
- data/test/testpkg/tpkg-bad-ownergroup.yml +18 -0
- data/test/testpkg/tpkg-default-perms.xml +28 -0
- data/test/testpkg/tpkg-default-perms.yml +20 -0
- data/test/testpkg/tpkg-good-ownergroup.xml +25 -0
- data/test/testpkg/tpkg-good-ownergroup.yml +18 -0
- data/test/testpkg/tpkg-nativedeps.yml +13 -0
- data/test/testpkg/tpkg-nofiles.xml +14 -0
- data/test/testpkg/tpkg-nofiles.yml +9 -0
- data/test/testpkg/tpkg.xml +35 -0
- data/test/testpkg/tpkg.yml +25 -0
- data/test/tpkgtest.rb +300 -0
- data/tpkg.conf +16 -0
- data/tpkg.gemspec +24 -0
- data/tpkg.spec +28 -0
- data/tpkg.xml +17 -0
- data/tpkg_profile.sh +32 -0
- metadata +306 -31
data/bin/gem2tpkg
CHANGED
@@ -19,7 +19,7 @@ require 'facter'
|
|
19
19
|
|
20
20
|
# We don't want to just use the first gem command in the user's PATH by
|
21
21
|
# default, as that may not be a tpkg gem. I.e. /usr/bin/gem on Mac OS X.
|
22
|
-
DEFAULT_GEM_COMMAND = "#{Tpkg::DEFAULT_BASE}/
|
22
|
+
DEFAULT_GEM_COMMAND = "#{Tpkg::DEFAULT_BASE}/bin/gem"
|
23
23
|
|
24
24
|
# Ruby 1.8.7 and later have Dir.mktmpdir, but we support ruby 1.8.5 for
|
25
25
|
# RHEL/CentOS 5. So this is a basic substitute.
|
@@ -423,7 +423,7 @@ def package(gem)
|
|
423
423
|
# If the gemspec lists any extensions then the package has native
|
424
424
|
# code and needs to be flagged as specific to the OS and architecture
|
425
425
|
if gemspec.extensions && !gemspec.extensions.empty?
|
426
|
-
os =
|
426
|
+
os = tpkg.os.os
|
427
427
|
if os =~ /RedHat-(.*)/
|
428
428
|
os = os + ", CentOS-#{$1}"
|
429
429
|
elsif os =~ /CentOS-(.*)/
|
data/bin/tpkg
CHANGED
@@ -23,6 +23,7 @@ require 'tpkg'
|
|
23
23
|
@prompt = true
|
24
24
|
@quiet = false
|
25
25
|
@sudo = nil
|
26
|
+
@sudo_option = nil
|
26
27
|
@force = false
|
27
28
|
@deploy = false
|
28
29
|
@deploy_params = ARGV # hold parameters for how to invoke tpkg on the machines we're deploying to
|
@@ -65,7 +66,7 @@ def parse_config_files
|
|
65
66
|
|
66
67
|
# FIXME: Move config file parsing to tpkg.rb
|
67
68
|
# https://github.com/tpkg/client/issues/22
|
68
|
-
fsroot = @tpkg_options[:file_system_root]
|
69
|
+
fsroot = @tpkg_options[:file_system_root] || ''
|
69
70
|
settings = {:sources => []}
|
70
71
|
[File.join(fsroot, Tpkg::DEFAULT_CONFIGDIR, 'tpkg.conf'),
|
71
72
|
File.join(fsroot, ENV['HOME'], ".tpkg.conf")].each do |configfile|
|
@@ -168,7 +169,7 @@ opts.on('--groups', '-g', '=GROUP', Array, 'Group of server on which to apply ac
|
|
168
169
|
# abbreviation. I.e. if the option is --servers and the user specified
|
169
170
|
# --serv (which OptionParser will accept as long as it is unambiguous) this
|
170
171
|
# won't detect and remove it.
|
171
|
-
@deploy_params = @deploy_params - ['--groups', '-g', @groups.join(","), "--
|
172
|
+
@deploy_params = @deploy_params - ['--groups', '-g', @groups.join(","), "--groups=#{@groups.join(',')}"]
|
172
173
|
end
|
173
174
|
opts.on('--ua', 'Upgrade all packages') do |opt|
|
174
175
|
@rerun_with_sudo = true
|
@@ -363,7 +364,7 @@ opts.on('--quiet', 'Reduce informative but non-essential output') do |opt|
|
|
363
364
|
@quiet = opt
|
364
365
|
end
|
365
366
|
opts.on('--no-sudo', 'No calls to sudo for operations that might need root') do |opt|
|
366
|
-
@
|
367
|
+
@sudo_option = opt
|
367
368
|
end
|
368
369
|
opts.on('--lock-force', 'Force the removal of an existing lockfile') do |opt|
|
369
370
|
@tpkg_options[:lockforce] = opt
|
@@ -449,7 +450,7 @@ if @groups
|
|
449
450
|
end
|
450
451
|
servers = []
|
451
452
|
@groups.each do |group|
|
452
|
-
IO.popen(settings[:host_group_script]) do |pipe|
|
453
|
+
IO.popen(settings[:host_group_script]<<" "<<group.chomp) do |pipe|
|
453
454
|
pipe.each_line do |line|
|
454
455
|
servers << line.chomp
|
455
456
|
end
|
@@ -510,14 +511,17 @@ end
|
|
510
511
|
# order:
|
511
512
|
# - command line option
|
512
513
|
# - config file
|
513
|
-
# -
|
514
|
+
# - Default based on OS (Tpkg::OS#sudo_default?)
|
514
515
|
case
|
515
|
-
when !@
|
516
|
-
@
|
516
|
+
when !@sudo_option.nil?
|
517
|
+
@sudo = @sudo_option
|
517
518
|
when settings.has_key?(:sudo)
|
518
|
-
@sudo =
|
519
|
+
@sudo = settings[:sudo]
|
519
520
|
else
|
520
|
-
|
521
|
+
# This bit of horribleness will be better when option parsing gets moved
|
522
|
+
# into tpkg.rb
|
523
|
+
os = Tpkg::OS.create
|
524
|
+
@sudo = os.sudo_default?
|
521
525
|
end
|
522
526
|
@tpkg_options[:force] = @force
|
523
527
|
|
@@ -529,7 +533,7 @@ if !@sudo
|
|
529
533
|
# modified by other users who properly run --no-sudo as a regular user.
|
530
534
|
raise "--no-sudo cannot be used as 'root' user or via sudo"
|
531
535
|
end
|
532
|
-
fsroot = @tpkg_options[:file_system_root]
|
536
|
+
fsroot = @tpkg_options[:file_system_root] || ''
|
533
537
|
base = File.join(fsroot, @tpkg_options[:base])
|
534
538
|
if File.exist?(base)
|
535
539
|
baseuid = File.stat(base).uid
|
@@ -961,7 +965,7 @@ when :query_requires
|
|
961
965
|
dependencies.each do | requiree, deps |
|
962
966
|
next if deps.nil?
|
963
967
|
deps.each do | dep |
|
964
|
-
if
|
968
|
+
if tpkg.package_meets_requirement?(pkg, dep)
|
965
969
|
pkgfilename = pkg[:metadata][:filename]
|
966
970
|
if !requirees[pkgfilename]
|
967
971
|
requirees[pkgfilename] = []
|
@@ -1152,8 +1156,9 @@ when :query_tpkg_metadata_available
|
|
1152
1156
|
FileUtils.rm_rf(downloaddir)
|
1153
1157
|
end
|
1154
1158
|
when :query_env
|
1155
|
-
|
1156
|
-
puts "
|
1159
|
+
tpkg = Tpkg.new(@tpkg_options)
|
1160
|
+
puts "Operating System: #{tpkg.os.os}"
|
1161
|
+
puts "Architecture: #{tpkg.os.arch}"
|
1157
1162
|
puts "Tar: #{Tpkg::find_tar}"
|
1158
1163
|
when :query_conf
|
1159
1164
|
# This is somewhat arbitrarily limited to the options read from the
|
data/bin/tpkg_uploader
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
##############################################################################
|
3
|
+
# tpkg package management system
|
4
|
+
# License: MIT (http://www.opensource.org/licenses/mit-license.php)
|
5
|
+
##############################################################################
|
6
|
+
|
7
|
+
# Simple script for uploading packages to a tpkg server.
|
8
|
+
# Requires curl in order to work
|
9
|
+
|
10
|
+
require 'ping'
|
11
|
+
require 'tempfile'
|
12
|
+
require 'optparse'
|
13
|
+
require 'etc'
|
14
|
+
require 'uri'
|
15
|
+
require 'cgi'
|
16
|
+
|
17
|
+
##########################################################################
|
18
|
+
# Set these variables to the appropriate values that suit your environment
|
19
|
+
authentication_url = "http://localhost:3000/login"
|
20
|
+
tpkg_upload_url = "http://localhost:3000/uploads/create"
|
21
|
+
proxy_server = "proxy.local:8080"
|
22
|
+
##########################################################################
|
23
|
+
|
24
|
+
username = Etc.getlogin
|
25
|
+
password = nil
|
26
|
+
files_to_upload = nil
|
27
|
+
proxy = ""
|
28
|
+
cookie_file = nil
|
29
|
+
opts = OptionParser.new
|
30
|
+
opts.banner = 'Usage: tpkg [options]'
|
31
|
+
opts.on('-u', '--username USERNAME', 'Your username') do |opt|
|
32
|
+
username = opt
|
33
|
+
end
|
34
|
+
opts.on('-p', '--password PASSWORD', 'Your password') do |opt|
|
35
|
+
password = opt
|
36
|
+
end
|
37
|
+
opts.on('-f', '--file FILES', Array, 'Comma-separated list of files you want to upload') do |opt|
|
38
|
+
files_to_upload = opt
|
39
|
+
end
|
40
|
+
opts.on('--source_dir DIR', 'Directory containing *.tpkg files that you want to upload') do |opt|
|
41
|
+
if !File.directory?(opt)
|
42
|
+
raise "#{opt} is not a directory"
|
43
|
+
else
|
44
|
+
files_to_upload = Dir.glob(File.join(opt, '*.tpkg'))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
opts.on('-x', '--proxy PROXY', 'Proxy to connect to tpkg server (if needed)') do |opt|
|
48
|
+
proxy = "--proxy #{opt}"
|
49
|
+
end
|
50
|
+
opts.on('--server SERVER', 'Where to upload the package to') do |opt|
|
51
|
+
tpkg_upload_url = "http://#{opt}/uploads/create"
|
52
|
+
end
|
53
|
+
opts.on('--cookie FILE', 'Path where cookie is stored') do |opt|
|
54
|
+
cookie_file = opt
|
55
|
+
end
|
56
|
+
|
57
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
58
|
+
puts opts
|
59
|
+
exit
|
60
|
+
end
|
61
|
+
|
62
|
+
opts.parse(ARGV)
|
63
|
+
|
64
|
+
# Authenticate against tpkg server either using existing cookie file (saved from curl)
|
65
|
+
# or username/password
|
66
|
+
# To save cookie file, use the following curl command
|
67
|
+
# curl https://myserver/login --data 'login=username&password=password' -k -c path_to_save_the_cookie
|
68
|
+
|
69
|
+
if cookie_file
|
70
|
+
if !File.exists?(cookie_file)
|
71
|
+
puts "Cookie file doesn't exist"
|
72
|
+
exit
|
73
|
+
end
|
74
|
+
else
|
75
|
+
# ask for username and password if user doesn't specify it
|
76
|
+
if username.nil?
|
77
|
+
print "Enter your username: "
|
78
|
+
username = STDIN.gets.chomp
|
79
|
+
end
|
80
|
+
|
81
|
+
if password.nil?
|
82
|
+
begin
|
83
|
+
system 'stty -echo'
|
84
|
+
print "Enter your password: "
|
85
|
+
password = STDIN.gets.chomp
|
86
|
+
ensure
|
87
|
+
system 'stty echo; echo ""'
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
curl_config=Tempfile.new("curl_config")
|
92
|
+
cookie_file=Tempfile.new("cookie").path
|
93
|
+
|
94
|
+
# See if we can talk to the authentication server. If not, we might need to use a proxy
|
95
|
+
if (proxy.nil? || proxy.empty?) && !Ping.pingecho(URI.parse(authentication_url).host, 2, URI.parse(authentication_url).port)
|
96
|
+
proxy = "--proxy #{proxy_server}"
|
97
|
+
puts "Can't connect to authentication server directly. Trying to connect via #{proxy}."
|
98
|
+
end
|
99
|
+
|
100
|
+
# We need to authenticate against the server first in order to get a cookie
|
101
|
+
# To prevent username and password showing up when we call
|
102
|
+
# curl, we will tell curl to look it up from a config file
|
103
|
+
config="data = \"login=#{CGI.escape(username)}&password=#{CGI.escape(password)}\""
|
104
|
+
File.open(curl_config.path, 'w') {|f| f.write(config) }
|
105
|
+
result = `curl #{authentication_url} -s -L -K #{curl_config.path} -k -c #{cookie_file} #{proxy}`
|
106
|
+
if result =~ /failed/
|
107
|
+
puts "Failed to authenticate."
|
108
|
+
exit
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# Get file to upload
|
113
|
+
if files_to_upload.nil?
|
114
|
+
print "Specify the file you want to upload: "
|
115
|
+
files_to_upload = [STDIN.gets.chomp]
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
# Do the actual upload
|
120
|
+
files_to_upload.each do | file |
|
121
|
+
# check if file exists
|
122
|
+
if File.file?(file)
|
123
|
+
file = File.expand_path(file)
|
124
|
+
else
|
125
|
+
puts "File doesn't exist"
|
126
|
+
exit
|
127
|
+
end
|
128
|
+
|
129
|
+
puts "Uploading #{file} to #{URI.parse(tpkg_upload_url).host}"
|
130
|
+
out=`curl -b #{cookie_file} -F upload[upload]=@'#{file}' #{tpkg_upload_url} #{proxy}`
|
131
|
+
puts out
|
132
|
+
end
|
data/ca.pem
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Add your SSL certificate authority's cert(s) to this file
|
data/control
ADDED
data/depend
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
pkgfile=$1
|
6
|
+
operation=$2
|
7
|
+
|
8
|
+
# Grab the data passed to us on stdin
|
9
|
+
datafile=`mktemp`
|
10
|
+
cat > $datafile
|
11
|
+
# We expect just one line of data containing the home directory path
|
12
|
+
homedir=`head -1 $datafile`
|
13
|
+
# Make sure we got some sort of string for the home directory
|
14
|
+
test -n "$homedir"
|
15
|
+
|
16
|
+
requestfile=/var/etch/requests/$homedir/.ssh/authorized_keys/$pkgfile
|
17
|
+
|
18
|
+
case "$operation" in
|
19
|
+
'install')
|
20
|
+
mkdir -p `dirname "$requestfile"`
|
21
|
+
tmpfile=`mktemp "$requestfile.XXXXXX"` || exit 1
|
22
|
+
echo "<request>" > $tmpfile
|
23
|
+
# Dump in the data we captured above
|
24
|
+
cat $datafile >> $tmpfile
|
25
|
+
echo "</request>" >> $tmpfile
|
26
|
+
chmod 644 "$tmpfile"
|
27
|
+
;;
|
28
|
+
'remove')
|
29
|
+
rm -f "$requestfile".*
|
30
|
+
;;
|
31
|
+
*)
|
32
|
+
echo "$0: Invalid arguments"
|
33
|
+
exit 1
|
34
|
+
;;
|
35
|
+
esac
|
36
|
+
|
37
|
+
# There's no guarantee that the user has keys in etch, and etch will throw an
|
38
|
+
# error if you ask it to generate a file that it doesn't know about.
|
39
|
+
#/usr/sbin/etch $homedir/.ssh/authorized_keys
|
40
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
pkgfile=$1
|
6
|
+
operation=$2
|
7
|
+
|
8
|
+
# /etc/sysconfig/iptables for Red Hat
|
9
|
+
# /var/lib/iptables/active for Debian
|
10
|
+
requestfiles="/var/etch/requests/etc/sysconfig/iptables/$pkgfile /var/etch/requests/var/lib/iptables/active/$pkgfile"
|
11
|
+
|
12
|
+
case "$operation" in
|
13
|
+
'install')
|
14
|
+
for requestfile in $requestfiles
|
15
|
+
do
|
16
|
+
mkdir -p `dirname "$requestfile"`
|
17
|
+
tmpfile=`mktemp "$requestfile.XXXXXX"` || exit 1
|
18
|
+
echo "<request>" > $tmpfile
|
19
|
+
# Dump in the data passed to us on stdin
|
20
|
+
cat >> $tmpfile
|
21
|
+
echo "</request>" >> $tmpfile
|
22
|
+
chmod 644 "$tmpfile"
|
23
|
+
done
|
24
|
+
;;
|
25
|
+
'remove')
|
26
|
+
for requestfile in $requestfiles
|
27
|
+
do
|
28
|
+
rm -f "$requestfile".*
|
29
|
+
done
|
30
|
+
;;
|
31
|
+
*)
|
32
|
+
echo "$0: Invalid arguments"
|
33
|
+
exit 1
|
34
|
+
;;
|
35
|
+
esac
|
36
|
+
|
37
|
+
/usr/sbin/etch /etc/sysconfig/iptables /var/lib/iptables/active
|
38
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
pkgfile=$1
|
6
|
+
operation=$2
|
7
|
+
|
8
|
+
requestfile=/var/etch/requests/etc/security/limits.conf/$pkgfile
|
9
|
+
|
10
|
+
case "$operation" in
|
11
|
+
'install')
|
12
|
+
mkdir -p `dirname "$requestfile"`
|
13
|
+
tmpfile=`mktemp "$requestfile.XXXXXX"` || exit 1
|
14
|
+
echo "<request>" > $tmpfile
|
15
|
+
# Dump in the data passed to us on stdin
|
16
|
+
cat >> $tmpfile
|
17
|
+
echo "</request>" >> $tmpfile
|
18
|
+
chmod 644 "$tmpfile"
|
19
|
+
;;
|
20
|
+
'remove')
|
21
|
+
rm -f "$requestfile".*
|
22
|
+
;;
|
23
|
+
*)
|
24
|
+
echo "$0: Invalid arguments"
|
25
|
+
exit 1
|
26
|
+
;;
|
27
|
+
esac
|
28
|
+
|
29
|
+
/usr/sbin/etch /etc/security/limits.conf
|
30
|
+
|
data/externals-etch/nfs
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
pkgfile=$1
|
6
|
+
operation=$2
|
7
|
+
|
8
|
+
requestfile=/var/etch/requests/etc/auto.auto/$pkgfile
|
9
|
+
|
10
|
+
case "$operation" in
|
11
|
+
'install')
|
12
|
+
mkdir -p `dirname "$requestfile"`
|
13
|
+
tmpfile=`mktemp "$requestfile.XXXXXX"`
|
14
|
+
echo "<request>" > $tmpfile
|
15
|
+
# Dump in the data passed to us on stdin
|
16
|
+
cat >> $tmpfile
|
17
|
+
echo "</request>" >> $tmpfile
|
18
|
+
chmod 644 "$tmpfile"
|
19
|
+
;;
|
20
|
+
'remove')
|
21
|
+
rm -f "$requestfile".*
|
22
|
+
;;
|
23
|
+
*)
|
24
|
+
echo "$0: Invalid arguments"
|
25
|
+
exit 1
|
26
|
+
;;
|
27
|
+
esac
|
28
|
+
|
29
|
+
/usr/sbin/etch /etc/auto.auto
|
30
|
+
|
data/externals-etch/sudo
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
pkgfile=$1
|
6
|
+
operation=$2
|
7
|
+
|
8
|
+
requestfile=/var/etch/requests/etc/sudoers/$pkgfile
|
9
|
+
|
10
|
+
case "$operation" in
|
11
|
+
'install')
|
12
|
+
mkdir -p `dirname "$requestfile"`
|
13
|
+
tmpfile=`mktemp "$requestfile.XXXXXX"` || exit 1
|
14
|
+
echo "<request>" > $tmpfile
|
15
|
+
# Dump in the data passed to us on stdin
|
16
|
+
cat >> $tmpfile
|
17
|
+
echo "</request>" >> $tmpfile
|
18
|
+
chmod 644 "$tmpfile"
|
19
|
+
;;
|
20
|
+
'remove')
|
21
|
+
rm -f "$requestfile".*
|
22
|
+
;;
|
23
|
+
*)
|
24
|
+
echo "$0: Invalid arguments"
|
25
|
+
exit 1
|
26
|
+
;;
|
27
|
+
esac
|
28
|
+
|
29
|
+
/usr/sbin/etch /etc/sudoers
|
30
|
+
|