tpkg 2.3.1 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Rakefile +1 -1
  2. data/bin/tpkg +112 -108
  3. data/lib/tpkg.rb +1 -1
  4. metadata +7 -7
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rake/gempackagetask'
2
2
  spec = Gem::Specification.new do |s|
3
3
  s.name = 'tpkg'
4
4
  s.summary = 'tpkg Application Packaging & Deployment'
5
- s.version = '2.3.1'
5
+ s.version = '2.3.2'
6
6
  s.authors = ['Darren Dao', 'Jason Heiss']
7
7
  s.email = 'tpkg-users@lists.sourceforge.net'
8
8
  s.homepage = 'http://tpkg.sourceforge.net'
data/bin/tpkg CHANGED
@@ -37,6 +37,9 @@ require 'tpkg'
37
37
  @other_options = {}
38
38
  @compress = "gzip"
39
39
 
40
+ #
41
+ # Subroutines
42
+ #
40
43
 
41
44
  def rerun_with_sudo_if_necessary
42
45
  if Process.euid != 0 && @sudo
@@ -107,6 +110,22 @@ def parse_config_files
107
110
  @config_file_settings = settings
108
111
  end
109
112
 
113
+ passphrase_callback = lambda do | package |
114
+ # ask("Passphrase for #{package}: ", true)
115
+ begin
116
+ system 'stty -echo;'
117
+ print "Passphrase for #{package}: "
118
+ input = STDIN.gets.chomp
119
+ ensure
120
+ system 'stty echo; echo ""'
121
+ end
122
+ input
123
+ end
124
+
125
+ #
126
+ # Begin main program logic
127
+ #
128
+
110
129
  opts = OptionParser.new(nil, 24, ' ')
111
130
  opts.banner = 'Usage: tpkg [options]'
112
131
  opts.on('--make', '-m', '=DIRECTORY', 'Make a package out of the contents of the directory') do |opt|
@@ -416,13 +435,6 @@ rescue OptionParser::ParseError => e
416
435
  exit 1
417
436
  end
418
437
 
419
- # Rerun with sudo if necessary, unless it's a deploy, then
420
- # we don't need to run with sudo on this machine. It will run with sudo
421
- # on the remote machine
422
- if @rerun_with_sudo && !@deploy
423
- rerun_with_sudo_if_necessary
424
- end
425
-
426
438
  # Display a usage message if the user did not specify a valid action to perform.
427
439
  if !@action
428
440
  puts opts
@@ -455,99 +467,91 @@ end
455
467
  # Figure out base directory, sources and other configuration
456
468
  #
457
469
 
458
- def instantiate_tpkg
459
- settings = parse_config_files
460
-
461
- # base can come from four possible places. They take precedence in this
462
- # order:
463
- # - command line option
464
- # - TPKG_HOME environment variable
465
- # - config file
466
- # - Tpkg::DEFAULT_BASE constant defined in tpkg.rb
467
- if ENV['TPKG_HOME']
468
- if !@tpkg_options[:base]
469
- @tpkg_options[:base] = ENV['TPKG_HOME']
470
- # Warn the user, as this could potentially be confusing
471
- # if they don't realize there's an environment variable set.
472
- warn "Using base '#{@tpkg_options[:base]}' base from $TPKG_HOME" if !@quiet
473
- else
474
- warn "Ignoring $TPKG_HOME" if @debug
475
- end
476
- end
477
- if settings[:base]
478
- if !@tpkg_options[:base]
479
- # Warn the user, as this could potentially be confusing
480
- # if they don't realize there's a config file lying
481
- # around
482
- @tpkg_options[:base] = settings[:base]
483
- warn "Using base #{@tpkg_options[:base]} from config file" if !@quiet
484
- else
485
- warn "Ignoring 'base' option in config file" if @debug
486
- end
487
- end
470
+ settings = parse_config_files
471
+
472
+ # base can come from four possible places. They take precedence in this
473
+ # order:
474
+ # - command line option
475
+ # - TPKG_HOME environment variable
476
+ # - config file
477
+ # - Tpkg::DEFAULT_BASE constant defined in tpkg.rb
478
+ if ENV['TPKG_HOME']
488
479
  if !@tpkg_options[:base]
489
- @tpkg_options[:base] = Tpkg::DEFAULT_BASE
480
+ @tpkg_options[:base] = ENV['TPKG_HOME']
481
+ # Warn the user, as this could potentially be confusing
482
+ # if they don't realize there's an environment variable set.
483
+ warn "Using base '#{@tpkg_options[:base]}' base from $TPKG_HOME" if !@quiet
484
+ else
485
+ warn "Ignoring $TPKG_HOME" if @debug
490
486
  end
491
-
492
- # Sources can come from the command line and config files. We use the
493
- # combined set of sources.
494
- @sources.concat(settings[:sources]).uniq!
495
- @tpkg_options[:sources] = @sources
496
-
497
- @tpkg_options[:report_server] = settings[:report_server]
498
- # sudo can come from three possible places. They take precedence in this
499
- # order:
500
- # - command line option
501
- # - config file
502
- # - Tpkg.sudo_default? method defined in tpkg.rb
503
- case
504
- when !@sudo.nil?
505
- @tpkg_options[:sudo] = @sudo
506
- when @tpkg_options.has_key?(:sudo)
507
- @sudo = @tpkg_options[:sudo]
487
+ end
488
+ if settings[:base]
489
+ if !@tpkg_options[:base]
490
+ # Warn the user, as this could potentially be confusing
491
+ # if they don't realize there's a config file lying
492
+ # around
493
+ @tpkg_options[:base] = settings[:base]
494
+ warn "Using base #{@tpkg_options[:base]} from config file" if !@quiet
508
495
  else
509
- @sudo = @tpkg_options[:sudo] = Tpkg.sudo_default?
496
+ warn "Ignoring 'base' option in config file" if @debug
510
497
  end
511
- @tpkg_options[:force] = @force
512
-
513
- if !@sudo
514
- curruid = Process.euid
515
- if curruid == 0
516
- # Besides there being no point to running with --no-sudo when root, we
517
- # don't want users to accidentally create files/directories that can't be
518
- # modified by other users who properly run --no-sudo as a regular user.
519
- raise "--no-sudo cannot be used as 'root' user or via sudo"
520
- end
521
- fsroot = @tpkg_options[:file_system_root] ? @tpkg_options[:file_system_root] : ''
522
- base = File.join(fsroot, @tpkg_options[:base])
523
- if File.exist?(base)
524
- baseuid = File.stat(base).uid
525
- # We want to ensure that all --no-sudo usage within a given base directory
526
- # is done under the same account.
527
- if baseuid != curruid
528
- raise "Base dir #{@tpkg_options[:base]} owned by UID #{baseuid}, not your UID #{curruid}"
529
- end
498
+ end
499
+ if !@tpkg_options[:base]
500
+ @tpkg_options[:base] = Tpkg::DEFAULT_BASE
501
+ end
502
+
503
+ # Sources can come from the command line and config files. We use the
504
+ # combined set of sources.
505
+ @sources.concat(settings[:sources]).uniq!
506
+ @tpkg_options[:sources] = @sources
507
+
508
+ @tpkg_options[:report_server] = settings[:report_server]
509
+ # sudo can come from three possible places. They take precedence in this
510
+ # order:
511
+ # - command line option
512
+ # - config file
513
+ # - Tpkg.sudo_default? method defined in tpkg.rb
514
+ case
515
+ when !@sudo.nil?
516
+ @tpkg_options[:sudo] = @sudo
517
+ when @tpkg_options.has_key?(:sudo)
518
+ @sudo = @tpkg_options[:sudo]
519
+ else
520
+ @sudo = @tpkg_options[:sudo] = Tpkg.sudo_default?
521
+ end
522
+ @tpkg_options[:force] = @force
523
+
524
+ if !@sudo
525
+ curruid = Process.euid
526
+ if curruid == 0
527
+ # Besides there being no point to running with --no-sudo when root, we
528
+ # don't want users to accidentally create files/directories that can't be
529
+ # modified by other users who properly run --no-sudo as a regular user.
530
+ raise "--no-sudo cannot be used as 'root' user or via sudo"
531
+ end
532
+ fsroot = @tpkg_options[:file_system_root] ? @tpkg_options[:file_system_root] : ''
533
+ base = File.join(fsroot, @tpkg_options[:base])
534
+ if File.exist?(base)
535
+ baseuid = File.stat(base).uid
536
+ # We want to ensure that all --no-sudo usage within a given base directory
537
+ # is done under the same account.
538
+ if baseuid != curruid
539
+ raise "Base dir #{@tpkg_options[:base]} owned by UID #{baseuid}, not your UID #{curruid}"
530
540
  end
531
541
  end
532
-
533
- tpkg = Tpkg.new(@tpkg_options)
534
542
  end
535
543
 
536
- passphrase_callback = lambda do | package |
537
- # ask("Passphrase for #{package}: ", true)
538
- begin
539
- system 'stty -echo;'
540
- print "Passphrase for #{package}: "
541
- input = STDIN.gets.chomp
542
- ensure
543
- system 'stty echo; echo ""'
544
- end
545
- input
544
+ # Rerun with sudo if necessary, unless it's a deploy, then
545
+ # we don't need to run with sudo on this machine. It will run with sudo
546
+ # on the remote machine
547
+ if @rerun_with_sudo && !@deploy
548
+ rerun_with_sudo_if_necessary
546
549
  end
547
550
 
548
551
  #
549
- # Do stuff
552
+ # Perform the user's requested operation
550
553
  #
554
+
551
555
  if @deploy
552
556
  # puts "Creating deployer with #{@worker_count} number of worker"
553
557
  @deploy_options["max-worker"] = @worker_count
@@ -597,16 +601,16 @@ when :make
597
601
  when :extract
598
602
  Tpkg::extract_metadata(@action_value)
599
603
  when :install
600
- tpkg = instantiate_tpkg
604
+ tpkg = Tpkg.new(@tpkg_options)
601
605
  ret_val = tpkg.install(@action_value, passphrase_callback, @other_options)
602
606
  when :upgrade
603
- tpkg = instantiate_tpkg
607
+ tpkg = Tpkg.new(@tpkg_options)
604
608
  ret_val = tpkg.upgrade(@action_value, passphrase_callback, @other_options)
605
609
  when :remove
606
- tpkg = instantiate_tpkg
610
+ tpkg = Tpkg.new(@tpkg_options)
607
611
  ret_val = tpkg.remove(@action_value, @other_options)
608
612
  when :download
609
- tpkg = instantiate_tpkg
613
+ tpkg = Tpkg.new(@tpkg_options)
610
614
  ret_val = tpkg.download_pkgs(@action_value, @other_options)
611
615
  when :verify
612
616
  result = nil
@@ -615,7 +619,7 @@ when :verify
615
619
  Tpkg::verify_package_checksum(@action_value)
616
620
  # Verify an installed pkg
617
621
  else
618
- tpkg = instantiate_tpkg
622
+ tpkg = Tpkg.new(@tpkg_options)
619
623
  results = tpkg.verify_file_metadata([@action_value])
620
624
  if results.length == 0
621
625
  puts "No package found"
@@ -632,13 +636,13 @@ when :verify
632
636
  puts "Package verification failed" unless success
633
637
  end
634
638
  when :execute_init
635
- tpkg = instantiate_tpkg
639
+ tpkg = Tpkg.new(@tpkg_options)
636
640
  if @init_options[:cmd].nil?
637
641
  raise "You didn't specify what init command to run"
638
642
  end
639
643
  ret_val = tpkg.execute_init(@init_options)
640
644
  when :query_installed
641
- tpkg = instantiate_tpkg
645
+ tpkg = Tpkg.new(@tpkg_options)
642
646
  matches = []
643
647
  if @action_value
644
648
  # The --query switch is set to accept multiple values (the "Array"
@@ -676,7 +680,7 @@ when :query_installed
676
680
  end
677
681
  end
678
682
  when :query_info
679
- tpkg = instantiate_tpkg
683
+ tpkg = Tpkg.new(@tpkg_options)
680
684
  requirements = []
681
685
  packages = {}
682
686
  tpkg.parse_requests([@action_value], requirements, packages,
@@ -721,7 +725,7 @@ when :query_info
721
725
  $stderr.puts "No packages matching '#{@action_value}' installed"
722
726
  end
723
727
  when :query_info_available
724
- tpkg = instantiate_tpkg
728
+ tpkg = Tpkg.new(@tpkg_options)
725
729
  requirements = []
726
730
  packages = {}
727
731
  tpkg.parse_requests([@action_value], requirements, packages)
@@ -770,7 +774,7 @@ when :query_info_available
770
774
  print output_strings.join("================================================================================\n")
771
775
  end
772
776
  when :query_list_files
773
- tpkg = instantiate_tpkg
777
+ tpkg = Tpkg.new(@tpkg_options)
774
778
  requirements = []
775
779
  packages = {}
776
780
  tpkg.parse_requests([@action_value], requirements, packages,
@@ -807,7 +811,7 @@ when :query_list_files
807
811
  end
808
812
  end
809
813
  when :query_list_files_available
810
- tpkg = instantiate_tpkg
814
+ tpkg = Tpkg.new(@tpkg_options)
811
815
  requirements = []
812
816
  packages = {}
813
817
  tpkg.parse_requests([@action_value], requirements, packages)
@@ -846,7 +850,7 @@ when :query_list_files_available
846
850
  FileUtils.rm_rf(downloaddir)
847
851
  end
848
852
  when :query_who_owns_file
849
- tpkg = instantiate_tpkg
853
+ tpkg = Tpkg.new(@tpkg_options)
850
854
  owned = false
851
855
  expanded_file = File.expand_path(@action_value)
852
856
  tpkg.files_for_installed_packages.each do |pkgfile, fip|
@@ -864,7 +868,7 @@ when :query_who_owns_file
864
868
  $stderr.puts "No package owns file '#{@action_value}'"
865
869
  end
866
870
  when :query_available
867
- tpkg = instantiate_tpkg
871
+ tpkg = Tpkg.new(@tpkg_options)
868
872
  availpkgs = []
869
873
  if @action_value
870
874
  # The --qs switch is set to accept multiple values (the "Array"
@@ -916,7 +920,7 @@ when :query_available
916
920
  end
917
921
  end
918
922
  when :query_requires
919
- tpkg = instantiate_tpkg
923
+ tpkg = Tpkg.new(@tpkg_options)
920
924
 
921
925
  # Parse the request
922
926
  requirements = []
@@ -981,7 +985,7 @@ when :query_requires
981
985
  puts "No other package depends on '#{@action_value}'"
982
986
  end
983
987
  when :query_depends
984
- tpkg = instantiate_tpkg
988
+ tpkg = Tpkg.new(@tpkg_options)
985
989
 
986
990
  requirements = []
987
991
  packages = {}
@@ -1031,7 +1035,7 @@ when :query_depends
1031
1035
  end
1032
1036
  end
1033
1037
  when :query_depends_available
1034
- tpkg = instantiate_tpkg
1038
+ tpkg = Tpkg.new(@tpkg_options)
1035
1039
  requirements = []
1036
1040
  packages = {}
1037
1041
  tpkg.parse_requests([@action_value], requirements, packages)
@@ -1086,7 +1090,7 @@ when :query_depends_available
1086
1090
  end
1087
1091
  end
1088
1092
  when :query_tpkg_metadata
1089
- tpkg = instantiate_tpkg
1093
+ tpkg = Tpkg.new(@tpkg_options)
1090
1094
  requirements = []
1091
1095
  packages = {}
1092
1096
  tpkg.parse_requests([@action_value], requirements, packages,
@@ -1111,7 +1115,7 @@ when :query_tpkg_metadata
1111
1115
  end
1112
1116
  end
1113
1117
  when :query_tpkg_metadata_available
1114
- tpkg = instantiate_tpkg
1118
+ tpkg = Tpkg.new(@tpkg_options)
1115
1119
  requirements = []
1116
1120
  packages = {}
1117
1121
  tpkg.parse_requests([@action_value], requirements, packages)
@@ -1158,12 +1162,12 @@ when :query_conf
1158
1162
  # without recreating all of our logic about deciding which config files to
1159
1163
  # read, which order to read them in, what environment variables override the
1160
1164
  # config files, etc.
1161
- tpkg = instantiate_tpkg
1165
+ tpkg = Tpkg.new(@tpkg_options)
1162
1166
  puts "Base: #{tpkg.base}"
1163
1167
  puts "Sources: #{tpkg.sources.inspect}"
1164
1168
  puts "Report server: #{tpkg.report_server}"
1165
1169
  when :query_history
1166
- tpkg = instantiate_tpkg
1170
+ tpkg = Tpkg.new(@tpkg_options)
1167
1171
  tpkg.installation_history
1168
1172
  when :query_version
1169
1173
  puts Tpkg::VERSION
@@ -42,7 +42,7 @@ OpenSSLCipherError = OpenSSL::Cipher.const_defined?(:CipherError) ? OpenSSL::Cip
42
42
 
43
43
  class Tpkg
44
44
 
45
- VERSION = '2.3.1'
45
+ VERSION = '2.3.2'
46
46
 
47
47
  GENERIC_ERR = 1
48
48
  POSTINSTALL_ERR = 2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tpkg
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ date: 2012-04-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: facter
17
- requirement: &70195691861980 !ruby/object:Gem::Requirement
17
+ requirement: &70208837451800 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70195691861980
25
+ version_requirements: *70208837451800
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: net-ssh
28
- requirement: &70195691861560 !ruby/object:Gem::Requirement
28
+ requirement: &70208837451260 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70195691861560
36
+ version_requirements: *70208837451260
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: kwalify
39
- requirement: &70195691861000 !ruby/object:Gem::Requirement
39
+ requirement: &70208837450840 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: '0'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *70195691861000
47
+ version_requirements: *70208837450840
48
48
  description:
49
49
  email: tpkg-users@lists.sourceforge.net
50
50
  executables: