natives 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NGJiYWNiZGIzY2JkMjQzNzQyNmY0NDdmYjQ5M2Y0YWNhMjVlNTJjNg==
4
+ M2U5MzE1YzYzY2U5Y2M2N2VkOWQwZjlhZjJjYmU2ZGRlYTdlZDU0OA==
5
5
  data.tar.gz: !binary |-
6
- MmExZGFlMGEzNjcxNTlkNDAxNjc1Y2ZkMzk0ZTk0NzFiY2FmOTZjNw==
6
+ MmQzY2RiNWFkMGVlMGYxZWMxZDNiZWU1NGVmZjg3MDA5YTk5OTI3Mw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDJiMTNiZjg0MWRmNWJmMjc0YTkyMWE2ZDdmOTM1YmExYzU0ZGJhMTAzOWM3
10
- NjQyYTE1OWRkN2NjZGMxNTU0NWY4MzA1NDQ4MGQ1OTNlYzliNTFmMzAwNjk4
11
- MTBjNjcyZjVhZmVjNzI3ZTdkOTE1Yzk3MWM4NWJlNDczNzg5Mzg=
9
+ MzU4YWU5ZDU4NTVlNjFhYWI5YjdmMTE4MWFhYTk1Mzg0MGQ2MTkwOTk5ZDY1
10
+ MzRiYjk0MDdiMzY3YzU3Njc3ZTM5OTEzZDVhNGZmMWE4ZjMyMzE0OTdlZTc5
11
+ N2FhNDY2NTgxMGQ4ZGI0MWEzN2Y5OGRhNGVjYTI1YzNkZmQwZmU=
12
12
  data.tar.gz: !binary |-
13
- Nzg0ZjBmYjZmYjJiMzAwODUzNTZmODk1ZWIyN2M4MWI3NmVhODMyM2Y5YjZh
14
- NjJhNTBkYjBhNzExMDlkOGMwMzEyNTljZGIzNDIyMTQ0MTQ3ZWI4ZjU0MzVm
15
- MWQyZjc5MzY3OWVkMTExMTA2ZTY2Mjc5YjJiYjc1NjU1YzAwMmY=
13
+ OTU2ZDVmYjhlMDQwZDA2MTllZGU0OWMwNjg4NmRlNDQ4YmI5OTc1ZmIwZjky
14
+ ZmExYzM4ZWYyNDM2ZDBmYTc4ZTIxMmRiNDdlM2Q2ZmZkMGNjZTk0YzJjMmZk
15
+ MWYyMzFlMzliNGRmM2M3ZDliNGJjODY3ZmFlNTFkNmUxMjQyNDM=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.3
1
+ 0.5.4
@@ -0,0 +1,102 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ BOX_NAME = ENV['BOX_NAME'] || "ubuntu"
5
+ BOX_URI = ENV['BOX_URI'] || "http://files.vagrantup.com/precise64.box"
6
+ VF_BOX_URI = ENV['BOX_URI'] || "http://files.vagrantup.com/precise64_vmware_fusion.box"
7
+ AWS_REGION = ENV['AWS_REGION'] || "us-east-1"
8
+ AWS_AMI = ENV['AWS_AMI'] || "ami-d0f89fb9"
9
+ FORWARD_DOCKER_PORTS = ENV['FORWARD_DOCKER_PORTS']
10
+
11
+ Vagrant::Config.run do |config|
12
+ # Setup virtual machine box. This VM configuration code is always executed.
13
+ config.vm.box = BOX_NAME
14
+ config.vm.box_url = BOX_URI
15
+
16
+ config.ssh.forward_agent = true
17
+
18
+ # Provision docker and new kernel if deployment was not done.
19
+ # It is assumed Vagrant can successfully launch the provider instance.
20
+ if Dir.glob("#{File.dirname(__FILE__)}/.vagrant/machines/default/*/id").empty?
21
+ # Add lxc-docker package
22
+ pkg_cmd = "wget -q -O - https://get.docker.io/gpg | apt-key add -;" \
23
+ "echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list;" \
24
+ "apt-get update -qq; apt-get install -q -y --force-yes lxc-docker; "
25
+ # Add Ubuntu raring backported kernel
26
+ pkg_cmd << "apt-get update -qq; apt-get install -q -y linux-image-generic-lts-raring; "
27
+ # Add guest additions if local vbox VM. As virtualbox is the default provider,
28
+ # it is assumed it won't be explicitly stated.
29
+ if ENV["VAGRANT_DEFAULT_PROVIDER"].nil? && ARGV.none? { |arg| arg.downcase.start_with?("--provider") }
30
+ pkg_cmd << "apt-get install -q -y linux-headers-generic-lts-raring dkms; " \
31
+ "echo 'Downloading VBox Guest Additions...'; " \
32
+ "wget -q http://dlc.sun.com.edgesuite.net/virtualbox/4.2.12/VBoxGuestAdditions_4.2.12.iso; "
33
+ # Prepare the VM to add guest additions after reboot
34
+ pkg_cmd << "echo -e 'mount -o loop,ro /home/vagrant/VBoxGuestAdditions_4.2.12.iso /mnt\n" \
35
+ "echo yes | /mnt/VBoxLinuxAdditions.run\numount /mnt\n" \
36
+ "rm /root/guest_additions.sh; ' > /root/guest_additions.sh; " \
37
+ "chmod 700 /root/guest_additions.sh; " \
38
+ "sed -i -E 's#^exit 0#[ -x /root/guest_additions.sh ] \\&\\& /root/guest_additions.sh#' /etc/rc.local; " \
39
+ "echo 'Installation of VBox Guest Additions is proceeding in the background.'; " \
40
+ "echo '\"vagrant reload\" can be used in about 2 minutes to activate the new guest additions.'; "
41
+ end
42
+ # Add vagrant user to the docker group
43
+ pkg_cmd << "usermod -a -G docker vagrant; "
44
+ # Activate new kernel
45
+ pkg_cmd << "shutdown -r +1; "
46
+ config.vm.provision :shell, :inline => pkg_cmd
47
+ end
48
+ end
49
+
50
+
51
+ # Providers were added on Vagrant >= 1.1.0
52
+ Vagrant::VERSION >= "1.1.0" and Vagrant.configure("2") do |config|
53
+ config.vm.provider :aws do |aws, override|
54
+ aws.access_key_id = ENV["AWS_ACCESS_KEY_ID"]
55
+ aws.secret_access_key = ENV["AWS_SECRET_ACCESS_KEY"]
56
+ aws.keypair_name = ENV["AWS_KEYPAIR_NAME"]
57
+ override.ssh.private_key_path = ENV["AWS_SSH_PRIVKEY"]
58
+ override.ssh.username = "ubuntu"
59
+ aws.region = AWS_REGION
60
+ aws.ami = AWS_AMI
61
+ aws.instance_type = "t1.micro"
62
+ end
63
+
64
+ config.vm.provider :rackspace do |rs|
65
+ config.ssh.private_key_path = ENV["RS_PRIVATE_KEY"]
66
+ rs.username = ENV["RS_USERNAME"]
67
+ rs.api_key = ENV["RS_API_KEY"]
68
+ rs.public_key_path = ENV["RS_PUBLIC_KEY"]
69
+ rs.flavor = /512MB/
70
+ rs.image = /Ubuntu/
71
+ end
72
+
73
+ config.vm.provider :vmware_fusion do |f, override|
74
+ override.vm.box = BOX_NAME
75
+ override.vm.box_url = VF_BOX_URI
76
+ override.vm.synced_folder ".", "/vagrant", disabled: true
77
+ f.vmx["displayName"] = "docker"
78
+ end
79
+
80
+ config.vm.provider :virtualbox do |vb|
81
+ config.vm.box = BOX_NAME
82
+ config.vm.box_url = BOX_URI
83
+ config.vm.synced_folder ".", "/vagrant"
84
+ vb.name = "natives_catalog_test"
85
+ vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
86
+ vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
87
+ end
88
+ end
89
+
90
+ if !FORWARD_DOCKER_PORTS.nil?
91
+ Vagrant::VERSION < "1.1.0" and Vagrant::Config.run do |config|
92
+ (49000..49900).each do |port|
93
+ config.vm.forward_port port, port
94
+ end
95
+ end
96
+
97
+ Vagrant::VERSION >= "1.1.0" and Vagrant.configure("2") do |config|
98
+ (49000..49900).each do |port|
99
+ config.vm.network :forwarded_port, :host => port, :guest => port
100
+ end
101
+ end
102
+ end
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby -W0
1
+ #!/usr/bin/env ruby
2
2
  # encoding: UTF-8
3
3
 
4
4
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
@@ -1 +1 @@
1
- /data
1
+ /logs
@@ -0,0 +1,13 @@
1
+ #!/bin/bash
2
+
3
+ BIN_HOME="$( cd "$( dirname "$0" )" && pwd )"
4
+ TEST_HOME="$( cd "$BIN_HOME/.." && pwd )"
5
+
6
+ for dir in $TEST_HOME/images/*/
7
+ do
8
+ cd $dir &&
9
+ image_name=${PWD##*/} && # to assign to a variable
10
+ echo "Building $image_name from $dir" &&
11
+ docker build -t natives/$image_name .
12
+ docker push natives/$image_name
13
+ done
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env bash
2
+
3
+ BIN_HOME="$( cd "$( dirname "$0" )" && pwd )"
4
+ PROJECT_HOME="$( cd $BIN_HOME/../.. && pwd )"
5
+
6
+ gem_name=$1
7
+ echo " * Gem: $gem_name"
8
+
9
+ native_packages="$( $PROJECT_HOME/bin/natives list $gem_name )"
10
+ echo " * Native packages: $native_packages"
11
+
12
+ if [ -n "$native_packages" ]; then
13
+ echo " * Installing native packages.."
14
+ max_retry=3
15
+ retry_count=0
16
+ last_status='err'
17
+ while [ $retry_count -lt $max_retry ]; do
18
+ retry_count=$[$retry_count+1]
19
+ echo " * Attempt: $retry_count of $max_retry"
20
+
21
+ apt-get install -y $native_packages
22
+
23
+ if [ $? -eq 0 ]; then
24
+ last_status='ok'
25
+ break
26
+ fi
27
+ done
28
+ if [ $last_status == 'err' ]; then
29
+ echo " * Abort. Error when installing native packages."
30
+ return 1
31
+ fi
32
+ fi
33
+
34
+ echo " * Installing gems.."
35
+ gem install --verbose $gem_name
36
+
37
+ EXIT_CODE=$?
38
+ echo " * Exit code: $EXIT_CODE"
39
+
40
+ echo ""
41
+ if [ $EXIT_CODE -eq 0 ]; then
42
+ echo "SUCCESS"
43
+ else
44
+ echo "FAILED"
45
+ fi
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env bash
2
+
3
+ BIN_HOME="$( cd "$( dirname "$0" )" && pwd )"
4
+
5
+ image=$1
6
+ gem_name=$2
7
+
8
+ docker run \
9
+ -v /vagrant:/vagrant \
10
+ $image \
11
+ $BIN_HOME/install_entry $gem_name
@@ -1,11 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'psych'
4
3
  require 'yaml'
5
4
  require 'fileutils'
6
5
 
7
- test_home = File.expand_path(File.dirname(__FILE__))
8
- project_home = File.expand_path(File.join(test_home, '..'))
6
+ bin_home = File.dirname(__FILE__)
7
+ project_home = File.expand_path(File.join(bin_home, '..', '..'))
9
8
 
10
9
  rubygems_catalog_file = File.join(
11
10
  project_home, 'catalogs', 'rubygems.yaml')
@@ -0,0 +1,6 @@
1
+ #!/bin/bash
2
+
3
+ BIN_HOME="$( cd "$( dirname "$0" )" && pwd )"
4
+
5
+ $BIN_HOME/test_catalog_in_vagrant
6
+ #$BIN_HOME/run_osx
@@ -0,0 +1,22 @@
1
+ #!/bin/bash
2
+
3
+ BIN_HOME="$( cd "$( dirname "$0" )" && pwd )"
4
+ TEST_HOME="$( cd "$BIN_HOME/.." && pwd )"
5
+ LOG_HOME="$TEST_HOME/logs"
6
+
7
+ for dir in $TEST_HOME/images/*/
8
+ do
9
+ image_name=$(basename $dir)
10
+
11
+ log_dir="$LOG_HOME/$image_name"
12
+ echo " * Cleaning up logs: $log_dir .."
13
+ mkdir -p $log_dir
14
+ rm -rf $log_dir/*
15
+
16
+ gems="$( $BIN_HOME/list_all )"
17
+ echo " * To test entries in $image_name image: $gems"
18
+ for gem_name in $gems
19
+ do
20
+ $BIN_HOME/test_entry $image_name $gem_name
21
+ done
22
+ done
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ vagrant ssh -c '/vagrant/catalogs_test/bin/test_catalog'
@@ -0,0 +1,29 @@
1
+ #!/bin/bash
2
+
3
+ BIN_HOME="$( cd "$( dirname "$0" )" && pwd )"
4
+ TEST_HOME="$( cd "$BIN_HOME/.." && pwd )"
5
+ LOG_HOME="$TEST_HOME/logs"
6
+
7
+ image_name=$1
8
+ gem_name=$2
9
+ log_dir="$LOG_HOME/$image_name"
10
+
11
+ echo " * Removing previous log file.."
12
+ rm $log_dir/$gem_name*.log
13
+
14
+ echo " * Installing $gem_name gem in $image_name .."
15
+ $BIN_HOME/install_entry_in_docker "natives/$image_name" $gem_name | \
16
+ tee $log_dir/$gem_name.log
17
+
18
+ echo " * Appending test status to log filename.."
19
+ test_status=$( tail -n1 $log_dir/$gem_name.log )
20
+ new_log_file="$gem_name-FAILED.log"
21
+ if [ "$test_status" == "SUCCESS" ]; then
22
+ new_log_file="$gem_name-SUCCESS.log"
23
+ elif [ "$test_status" == "FAILED" ]; then
24
+ new_log_file="$gem_name-FAILED.log"
25
+ else
26
+ new_log_file="$gem_name-ERROR.log"
27
+ fi
28
+ mv $log_dir/$gem_name.log $log_dir/$new_log_file
29
+
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ vagrant ssh -c "/vagrant/catalogs_test/bin/test_entry $1 $2"
@@ -0,0 +1,10 @@
1
+ FROM ubuntu:12.10
2
+
3
+ MAINTAINER Huiming Teo (@teohm)
4
+
5
+ RUN apt-get -y update
6
+ RUN apt-get -y install ruby1.9.1-full
7
+ RUN apt-get -y install build-essential
8
+
9
+ RUN gem install bundler
10
+ RUN gem install natives
@@ -2,15 +2,15 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: natives 0.5.3 ruby lib
5
+ # stub: natives 0.5.4 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "natives"
9
- s.version = "0.5.3"
9
+ s.version = "0.5.4"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.authors = ["Huiming Teo"]
13
- s.date = "2013-11-11"
13
+ s.date = "2013-11-12"
14
14
  s.description = "Lookup native package dependencies required by gems on your machine."
15
15
  s.email = "teohuiming@gmail.com"
16
16
  s.executables = ["natives"]
@@ -28,14 +28,20 @@ Gem::Specification.new do |s|
28
28
  "README.md",
29
29
  "Rakefile",
30
30
  "VERSION",
31
+ "Vagrantfile",
31
32
  "bin/natives",
32
33
  "catalogs/rubygems.yaml",
33
34
  "catalogs_test/.gitignore",
34
- "catalogs_test/clean",
35
- "catalogs_test/list_all",
36
- "catalogs_test/run",
37
- "catalogs_test/setup",
38
- "catalogs_test/vendored/pacapt",
35
+ "catalogs_test/bin/build_images",
36
+ "catalogs_test/bin/install_entry",
37
+ "catalogs_test/bin/install_entry_in_docker",
38
+ "catalogs_test/bin/list_all",
39
+ "catalogs_test/bin/run",
40
+ "catalogs_test/bin/test_catalog",
41
+ "catalogs_test/bin/test_catalog_in_vagrant",
42
+ "catalogs_test/bin/test_entry",
43
+ "catalogs_test/bin/test_entry_in_vagrant",
44
+ "catalogs_test/images/ubuntu-12.10/Dockerfile",
39
45
  "lib/natives.rb",
40
46
  "lib/natives/apps.rb",
41
47
  "lib/natives/apps/detect.rb",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: natives
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Huiming Teo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-11 00:00:00.000000000 Z
11
+ date: 2013-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ohai
@@ -168,14 +168,20 @@ files:
168
168
  - README.md
169
169
  - Rakefile
170
170
  - VERSION
171
+ - Vagrantfile
171
172
  - bin/natives
172
173
  - catalogs/rubygems.yaml
173
174
  - catalogs_test/.gitignore
174
- - catalogs_test/clean
175
- - catalogs_test/list_all
176
- - catalogs_test/run
177
- - catalogs_test/setup
178
- - catalogs_test/vendored/pacapt
175
+ - catalogs_test/bin/build_images
176
+ - catalogs_test/bin/install_entry
177
+ - catalogs_test/bin/install_entry_in_docker
178
+ - catalogs_test/bin/list_all
179
+ - catalogs_test/bin/run
180
+ - catalogs_test/bin/test_catalog
181
+ - catalogs_test/bin/test_catalog_in_vagrant
182
+ - catalogs_test/bin/test_entry
183
+ - catalogs_test/bin/test_entry_in_vagrant
184
+ - catalogs_test/images/ubuntu-12.10/Dockerfile
179
185
  - lib/natives.rb
180
186
  - lib/natives/apps.rb
181
187
  - lib/natives/apps/detect.rb
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- TEST_HOME="$( cd "$( dirname "$0" )" && pwd )"
4
-
5
- rm -rf $TEST_HOME/data
6
- echo " * Removed data/ directory."
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- TEST_HOME="$( cd "$( dirname "$0" )" && pwd )"
4
- PROJECT_HOME="$( cd $TEST_HOME/.. && pwd )"
5
-
6
- $TEST_HOME/setup
7
-
8
- NATIVES_CMD="$PROJECT_HOME/bin/natives list $($TEST_HOME/list_all)"
9
- NATIVE_PACKAGES="$( $NATIVES_CMD )"
10
- echo " * Native packages: $NATIVE_PACKAGES"
11
-
12
- if [ -n "$NATIVE_PACKAGES" ]; then
13
- echo " * Installing native packages.."
14
- INSTALL_CMD="$TEST_HOME/vendored/pacapt -v -S"
15
- $INSTALL_CMD $NATIVE_PACKAGES
16
- fi
17
-
18
- echo " * Installing gems.."
19
- bundle install --gemfile $TEST_HOME/data/Gemfile --path bundle --verbose
20
-
21
- EXIT_CODE=$?
22
- echo " * Exit code: $EXIT_CODE"
23
- echo ""
24
-
25
- if [ $EXIT_CODE -eq 0 ]; then
26
- echo "SUCCESS"
27
- else
28
- echo "FAILED"
29
- fi
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'yaml'
4
- require 'fileutils'
5
-
6
- test_home = File.expand_path(File.dirname(__FILE__))
7
- project_home = File.expand_path(File.join(test_home, '..'))
8
- gemfile_path = File.join(test_home, 'data', 'Gemfile')
9
-
10
- gem_names = `#{ File.join(test_home, 'list_all') }`.split("\n")
11
-
12
- FileUtils.mkdir_p File.dirname(gemfile_path)
13
- File.open(gemfile_path, 'w') do |f|
14
- f.puts %{source "https://rubygems.org"}
15
- gem_names.each do |gem_name|
16
- f.puts %{gem "#{gem_name}"}
17
- end
18
- end
19
-
20
- puts " * Generated gemfile at #{gemfile_path}"
@@ -1,660 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Purpose: A wrapper for all Unix package managers
4
- # Author : Anh K. Huynh
5
- # License: Fair license (http://www.opensource.org/licenses/fair)
6
- # Source : http://github.com/icy/pacapt/
7
-
8
- # Copyright (C) 2010 - 2013 Anh K. Huynh
9
- #
10
- # Usage of the works is permitted provided that this instrument is
11
- # retained with the works, so that any entity that uses the works is
12
- # notified of this instrument.
13
- #
14
- # DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
15
-
16
- _POPT="" # primary operation
17
- _SOPT="" # secondary operation
18
- _TOPT="" # options for operations
19
- _PKG="" # packages and extra parameters for apt-get
20
- _VERBOSE="" # verbose mode
21
- _FORCE="" # force yes
22
- _OSTYPE="" # type of package manager (Arch pacman, Debian apt, ...)
23
-
24
- _error() {
25
- echo >&2 ":: $*"
26
- }
27
-
28
- _help() {
29
- cat <<\EOF
30
- NAME
31
-
32
- pacapt - An Arch's pacman-like package manager for some Unices.
33
-
34
- DESCRIPTION
35
-
36
- An Arch's pacman-like package manager for some Unices. Actually this Bash
37
- script provides a wrapper for system's package manager.
38
-
39
- Instead of remembering various options/tools on different OSs, you only
40
- need a common way to manipulate packages. Not all options of the native
41
- package manager are ported; the tool only provides a very basic interface
42
- to search, install, remove packages, and/or update the system.
43
-
44
- Arch's pacman is chosen, as pacman is quite smart when it divides all
45
- packages-related operations into three major groups: Synchronize, Query
46
- and Remove/Clean up. It has a clean man page, and it is the only tool
47
- needed to manipulate official packages on system. (Debian, for example,
48
- requires you to use apt-get, dpkg, and/or aptitude.)
49
-
50
- The tool supports the following package managers:
51
-
52
- pacman by Arch Linux, ArchBang, Manjaro, etc.
53
- dpkg/apt-get by Debian, Ubuntu, etc.
54
- homebrew by Mac OS X
55
- macports by Mac OS X
56
- yum/rpm by Redhat, CentOS, Fedora, etc.
57
- portage by Gentoo
58
- zypper by OpenSUSE
59
-
60
- SYNTAX
61
-
62
- $ pacapt <operation> <option(s)> <packages>
63
-
64
- OPERATIONS
65
-
66
- Query
67
-
68
- -Q list all installed packages
69
- -Qc <package> show package's changelog
70
- -Qi <package> print package status
71
- -Ql <package> list package's files
72
- -Qm list installed packages that aren't available
73
- in any installation source
74
- -Qo <file> query package that provides <file>
75
- -Qp <file> query a package file (don't use package database)
76
-
77
- Synchronize
78
-
79
- -S <package> install package(s)
80
- -Ss <package> search for packages
81
- -Su upgrade the system
82
- -Sy update package database
83
- -Suy update package database, then upgrade the system
84
-
85
- Remove / Clean up
86
-
87
- -R <packages> remove some packages
88
- -Sc delete old downloaded packages
89
- -Scc delete all downloaded packages
90
- -Sccc clean variant files.
91
- (debian) See more at http://dragula.org/blogs/646
92
-
93
- OPTIONS
94
-
95
- -f force yes
96
- -v be verbose
97
- -w download packages but don't install them
98
-
99
- NOTES
100
-
101
- To install a package from backports repository on Debian system:
102
- $ pacapt -S foobar -t lenny-backports
103
-
104
- Similarly, any further option which isn't recognized by getopts (1)
105
- can be passed to system tool.
106
-
107
- When being executed on Arch-based system, the tool simply invokes
108
- the system tool '/usr/bin/pacman'.
109
-
110
- THANKS
111
-
112
- Special thanks to
113
-
114
- Châu An, Nguyễn (told me about 'Pacman Rosetta' [1])
115
- Karol Blazewicz (for comments about '-Sy')
116
- James Pearson (for userful comments and patches.
117
- See also http://github.com/xiongchiamiov/pacapt)
118
- Alexander Dupuy (for userful comments and patches.
119
- See also https://github.com/dupuy/pacapt)
120
- Hà Dương, Nguyễn (for adding Gentoo support.
121
- See also https://github.com/CMPITG/pacapt)
122
-
123
- REFERENCES
124
-
125
- 1. Pacman Rosetta, https://wiki.archlinux.org/index.php?title=Pacman_Rosetta
126
- EOF
127
- }
128
-
129
- ###
130
- ### Helpers
131
- ###
132
-
133
- _os_is() {
134
- [[ "$_OSTYPE" = "$*" ]]
135
- }
136
-
137
- _exec_() {
138
- local _type="$1"
139
- shift
140
- if _os_is $_type; then
141
- [[ -z "$_VERBOSE" ]] || _error "Going to execute: $* $_VERBOSE $_FORCE"
142
- eval "$* $_VERBOSE $_FORCE"
143
- fi
144
- }
145
-
146
-
147
- # Detect package type from /etc/issue
148
- _found_arch() {
149
- local _ostype="$1"
150
- shift
151
- grep -qis "$*" /etc/issue && _OSTYPE="$_ostype"
152
- }
153
-
154
- # Detect package type
155
- _OSTYPE_detect() {
156
- _found_arch PACMAN "Arch Linux" && return
157
- _found_arch DPKG "Debian GNU/Linux" && return
158
- _found_arch DPKG "Ubuntu" && return
159
- _found_arch YUM "CentOS" && return
160
- _found_arch YUM "Red Hat" && return
161
- _found_arch YUM "Fedora" && return
162
- _found_arch ZYPPER "SUSE" && return
163
-
164
- [[ -z "$_OSTYPE" ]] || return
165
-
166
- # See also https://github.com/icy/pacapt/pull/22
167
- # Please not that $OSTYPE (which is `linux-gnu` on Linux system)
168
- # is not our $_OSTYPE. The choice is not very good because
169
- # a typo can just break the logic of the program.
170
- if [[ "$OSTYPE" != "darwin"* ]]; then
171
- _error "Can't detect OS type from /etc/issue. Running fallback method."
172
- fi
173
- [[ -x "/usr/bin/pacman" ]] && _OSTYPE="PACMAN" && return
174
- [[ -x "/usr/bin/apt-get" ]] && _OSTYPE="DPKG" && return
175
- [[ -x "/usr/bin/yum" ]] && _OSTYPE="YUM" && return
176
- [[ -x "/opt/local/bin/port" ]] && _OSTYPE="MACPORTS" && return
177
- command -v brew >/dev/null && _OSTYPE="HOMEBREW" && return
178
- [[ -x "/usr/bin/emerge" ]] && _OSTYPE="PORTAGE" && return
179
- [[ -x "/usr/bin/zypper" ]] && _OSTYPE="ZYPPER" && return
180
- if [[ -z "$_OSTYPE" ]]; then
181
- _error "No supported package manager installed on system"
182
- _error "(supported: apt, homebrew, pacman, portage, yum)"
183
- exit 1
184
- fi
185
- }
186
-
187
- ###
188
- ### Main
189
- ###
190
-
191
- # Detect type of package manager.
192
- _OSTYPE_detect
193
-
194
- # If the system is Arch-like, pass all of the arguments to /usr/bin/pacman
195
- # and return. This is done here to achieve a consistent help menu.
196
- [[ "$_OSTYPE" == "PACMAN" ]] && exec /usr/bin/pacman "$@"
197
-
198
- #
199
- # Get options from command lines. FIXME: Support long options
200
- #
201
-
202
- # By default, with Gentoo, 'force' is always 'yes', so we change it to 'no'
203
- [[ "$_OSTYPE" == "PORTAGE" ]] && _FORCE="-a"
204
-
205
- while getopts "URQShfvlumyispqwco" opt 2>/dev/null; do
206
- case "$opt" in
207
- Q|S|R|U)
208
- if [[ "$_POPT" != "" && "$_POPT" != "$opt" ]]; then
209
- _error "Only one operation may be used at a time"
210
- exit 1
211
- fi
212
- _POPT="$opt"
213
- ;;
214
-
215
- # FIXME: Please check pacman(8) to see if they are really 2nd operation
216
- s|l|i|p|o|m)
217
- if [[ "$_SOPT" == '' ]]; then
218
- _SOPT="$opt"
219
- else
220
- _TOPT="$opt"
221
- fi
222
- ;;
223
-
224
- # NOTE: -q is an output option, not an operator!
225
- # Thanks to James Pearson for his catch :)
226
- q)
227
- _TOPT="$opt"
228
- ;;
229
-
230
- u)
231
- if [[ "${_SOPT:0:1}" = "y" ]]; then
232
- _SOPT="uy"
233
- else
234
- _SOPT="u"
235
- fi
236
- ;;
237
-
238
- y)
239
- if [[ "${_SOPT:0:1}" = "u" ]]; then
240
- _SOPT="uy"
241
- else
242
- _SOPT="y"
243
- fi
244
- ;;
245
-
246
- c)
247
- if [[ "${_SOPT:0:2}" = "cc" ]]; then
248
- _SOPT="ccc"
249
- elif [[ "${_SOPT:0:1}" = "c" ]]; then
250
- _SOPT="cc"
251
- else
252
- _SOPT="$opt"
253
- fi
254
- ;;
255
-
256
- w)
257
- case "$_OSTYPE" in
258
- "DPKG") _TOPT="-d" ;;
259
- "YUM")
260
- _TOPT="--downloadonly"
261
- if ! rpm -q yum-downloadonly > /dev/null; then
262
- _error "The '-w' option requires the package 'yum-downloadonly'"
263
- _error "Install this with 'yum install -y yum-downloadonly' or"
264
- _error "$0 -S -f yum-downloadonly"
265
- exit 1
266
- fi
267
- ;;
268
- "MACPORTS") _TOPT="fetch" ;;
269
- "PORTAGE") _TOPT="--fetchonly" ;;
270
- "ZYPPER") _TOPT="--download-only" ;;
271
- esac
272
- ;;
273
-
274
- f)
275
- case "$_OSTYPE" in
276
- "DPKG") _FORCE="-f --force-yes" ;;
277
- "YUM") _FORCE="-y" ;;
278
- "MACPORTS") _FORCE="-f" ;;
279
- "PORTAGE") _FORCE="" ;;
280
- *) _FORCE="-y" ;;
281
- esac
282
- ;;
283
-
284
- v) _VERBOSE="-v" ;;
285
-
286
- h) _help; exit 0 ;;
287
-
288
- *) _error "Error: Invalid option"; exit 1 ;;
289
- esac
290
- done
291
-
292
- # Remained options/packages/queries
293
- shift $((OPTIND - 1))
294
- _PKG="$*"
295
-
296
- # pacman man page (examples) says: "pacman -Syu gpm = Update package list,
297
- # upgrade all packages, and then install gpm if it wasn't already installed."
298
- # Instead, just disallow specific packages, as (ex-)yum users likely expect to
299
- # just update/upgrade one package (and its dependencies) and apt-get and pacman
300
- # have no way to do this.
301
- if [[ -n "$_PKG" ]]; then
302
- case "$_POPT$_SOPT" in
303
- "Su"|"Sy"|"Suy")
304
- _error "The -Sy/u options refresh and/or upgrade all packages"
305
- _error "To install packages as well, use separate commands to do so:"
306
- _error "$0 -S$_SOPT"
307
- _error "$0 -S $_PKG"
308
- exit 1
309
- esac
310
- fi
311
-
312
- # DEBUG
313
- # echo "Primary options: $_POPT"
314
- # echo "Secondary options: $_SOPT"
315
- # echo "Options for operations: $_TOPT"
316
- # echo "Extra params: $_PKG"
317
- # echo "Verbose: $_VERBOSE"
318
- # echo "Force: $_FORCE"
319
-
320
- # Return if no option was specified
321
- if [[ -z "$_POPT" ]]; then
322
- _error "No operation specified (use -h for help)"
323
- exit 1
324
- fi
325
-
326
- # Invoke the native package manager
327
- case "$_POPT$_SOPT" in
328
- ####################################################################
329
- # QUERYING #
330
- ####################################################################
331
-
332
- "Qi")
333
- _exec_ ZYPPER "zypper info $_PKG"
334
- _exec_ DPKG "dpkg-query -s $_PKG"
335
- _exec_ HOMEBREW "brew info $_PKG"
336
- #_exec_ MACPORTS "port info $_PKG"
337
- _os_is MACPORTS && _error "Function not implemented in macports"
338
- _exec_ YUM "yum info $_PKG"
339
- _FORCE="" \
340
- _exec_ PORTAGE "emerge --info $_PKG"
341
- ;;
342
- "Ql")
343
- _exec_ ZYPPER "echo 'Function is not available'; exit 1"
344
- _exec_ DPKG "
345
- if [[ -n \"$_PKG\" ]]; then
346
- dpkg-query -L $_PKG
347
- else
348
- dpkg -l \
349
- | grep -E ^[hi]i \
350
- | awk '{print \$2}' \
351
- | while read _pkg; do
352
- if [[ \"$_TOPT\" = 'q' ]]; then
353
- dpkg-query -L \$_pkg
354
- else
355
- dpkg-query -L \$_pkg \
356
- | while read _line; do
357
- echo \$_pkg \$_line
358
- done
359
- fi
360
- done
361
- fi
362
- "
363
- _exec_ HOMEBREW "brew list $_PKG"
364
- _exec_ MACPORTS "port contents $_PKG"
365
- _exec_ YUM "rpm -ql $_PKG"
366
- _FORCE="" \
367
- _exec_ PORTAGE "
368
- if [[ -x /usr/bin/qlist ]]; then
369
- qlist $_PKG
370
- elif [[ -x /usr/bin/equery ]]; then
371
- equery files $_PKG
372
- else
373
- _error 'You need to install portage-utils or gentoolkit to perform this operation.'
374
- fi
375
- "
376
- ;;
377
- "Qo")
378
- _exec_ ZYPPER "echo 'Function is not available'; exit 1"
379
-
380
- _exec_ DPKG "dpkg-query -S $_PKG"
381
- _exec_ HOMEBREW "
382
- cd \"\$(dirname -- \$(which $_PKG))\"
383
- pkg=\"\$(pwd -P)/\$(basename -- $_PKG)\"
384
- prefix=\"\$(brew --prefix)\"
385
- cellar=\"\$(brew --cellar)\"
386
- for package in \$cellar/*; do
387
- files=(\${package}/*/\${pkg/#\$prefix\//})
388
- if [[ -e \${files[\${#files[@]} - 1]} ]]; then
389
- echo \"\${package/#\$cellar\//}\"
390
- break
391
- fi
392
- done
393
- "
394
- _exec_ MACPORTS "port provides $_PKG"
395
- _exec_ YUM "rpm -qf $_PKG"
396
- _FORCE="" \
397
- _exec_ PORTAGE "
398
- if [[ -x /usr/bin/equery ]]; then
399
- equery belongs $_PKG
400
- else
401
- _error 'You need to install gentoolkit to perform this operation'
402
- fi
403
- "
404
- ;;
405
- "Qp")
406
- _exec_ ZYPPER "echo 'Function is not available'; exit 1"
407
- _os_is HOMEBREW && _error "Function not implemented in homebrew"
408
- _os_is MACPORTS && _error "Function not implemented in macports"
409
- _os_is PORTAGE && _error "Function not supported as Gentoo has no definition of 'package file"
410
-
411
- _exec_ DPKG "dpkg-deb -I $_PKG"
412
- _exec_ YUM "rpm -qp $_PKG"
413
- ;;
414
- "Qc")
415
- _exec_ ZYPPER "echo 'Function is not available'; exit 1"
416
- _os_is DPKG && _error "Function not implemented in Debian system"
417
-
418
- _exec_ HOMEBREW "brew log $_PKG"
419
- _exec_ MACPORTS "port log $_PKG"
420
- _exec_ YUM "rpm -q --changelog $_PKG"
421
- _FORCE="" \
422
- _exec_ PORTAGE "emerge -p --changelog $_PKG"
423
- ;;
424
- "Qu")
425
- _exec_ ZYPPER "zypper list-updates"
426
- _exec_ DPKG "apt-get upgrade --trivial-only $_PKG"
427
- _exec_ HOMEBREW "brew outdated | grep $_PKG"
428
- _exec_ MACPORTS "port outdated $_PKG"
429
- _exec_ YUM "yum list updates $_PKG"
430
- _exec_ PORTAGE "emerge -uvN $_PKG" # FIXME: not exactly
431
- ;;
432
- "Qm")
433
- _exec_ ZYPPER "zypper search -si | grep 'System Packages'"
434
- _os_is DPKG && _error "Function not implemented in Debian system"
435
- _os_is HOMEBREW && _error "Function not implemented in homebrew"
436
- _os_is MACPORTS && _error "Function not implemented in macports"
437
- _os_is PORTAGE && _error "Function not supported in Gentoo"
438
-
439
- _exec_ YUM "yum list extras $_PKG"
440
- ;;
441
-
442
- "Q")
443
- _exec_ ZYPPER "zypper search -i"
444
- if [[ "$_TOPT" = 'q' ]]; then
445
- # FIXME: Should we redirect user to a similar operation?
446
- _os_is HOMEBREW && _error "Function not implemented in homebrew"
447
- _os_is MACPORTS && _error "Function not implemented in macports"
448
- _os_is PORTAGE && _error "Function not supported as Gentoo has no definition of 'package file"
449
- _os_is YUM && _error "Function not implemented in Yum"
450
-
451
- _exec_ DPKG "dpkg -l | grep -E ^[hi]i | awk '{print \$2}'"
452
- elif [[ "$_TOPT" = "" ]]; then
453
- _exec_ DPKG "dpkg -l $_PKG | grep -E ^[hi]i"
454
- _exec_ HOMEBREW "brew list | grep $_PKG"
455
- _exec_ MACPORTS "port installed $_PKG"
456
- _exec_ YUM "yum list installed $_PKG"
457
-
458
- # FIXME: There are actually many ways to do this in Gentoo
459
- _FORCE="" \
460
- _exec_ PORTAGE "
461
- if [[ -x /usr/bin/eix ]]; then
462
- eix -I $_PKG
463
- elif [[ -x /usr/bin/equery ]]; then
464
- equery list '*' $_PKG
465
- else
466
- LS_COLORS=never ls -1 -d /var/db/pkg/*/*
467
- fi
468
- "
469
- else
470
- _error "Error: Invalid option"
471
- exit 1
472
- fi
473
- ;;
474
-
475
- ####################################################################
476
- # REMOVING #
477
- ####################################################################
478
-
479
- "Rs")
480
- if [[ "$_TOPT" = 's' ]]; then
481
- _os_is DPKG && _error "Function not implemented in Debian system"
482
- _os_is YUM && _error "Function not implemented in Yum"
483
- _os_is PORTAGE && _error "Function not supported in Gentoo"
484
-
485
- _exec_ ZYPPER "zypper remove $_PKG --clean-deps"
486
- _exec_ HOMEBREW "
487
- brew rm $_PKG
488
- brew rm \$(join <(brew leaves) <(brew deps $_PKG))
489
- "
490
- _os_is MACPORTS && _error "Function not implemented in macports"
491
- elif [[ "$_TOPT" = '' ]]; then
492
- _exec_ ZYPPER "echo 'Function is not available'; exit 1"
493
- _os_is HOMEBREW && _error "Function not implemented in homebrew"
494
- _exec_ MACPORTS "port uninstall --follow-dependencies $_PKG"
495
- _exec_ DPKG "apt-get autoremove $_PKG"
496
- _exec_ YUM "yum erase $_PKG"
497
- _exec_ PORTAGE "emerge --depclean world $_PKG"
498
- else
499
- _error "Error: Invalid option"
500
- fi
501
- ;;
502
- "R")
503
- _exec_ ZYPPER "zypper remove $_PKG"
504
- _exec_ DPKG "apt-get remove $_PKG"
505
- _exec_ HOMEBREW "brew remove $_PKG"
506
- _exec_ MACPORTS "port uninstall $_PKG"
507
- _exec_ YUM "yum erase $_PKG"
508
- _exec_ PORTAGE "emerge --depclean $_PKG"
509
- ;;
510
-
511
- ####################################################################
512
- # SYNCHRONIZING #
513
- ####################################################################
514
-
515
- "Si")
516
- _exec_ ZYPPER "echo 'Function is not available'; exit 1"
517
- _exec_ DPKG "dpkg-query -s $_PKG"
518
- _exec_ HOMEBREW "brew info $_PKG"
519
- _exec_ MACPORTS "port info $_PKG"
520
- _exec_ YUM "yum info $_PKG"
521
- _FORCE="" \
522
- _exec_ PORTAGE "emerge --info $_PKG"
523
- ;;
524
- "Suy")
525
- _exec_ ZYPPER "zypper dup"
526
- _VERBOSE="" \
527
- _exec_ DPKG "apt-get update; apt-get upgrade"
528
- _exec_ HOMEBREW "brew update; brew upgrade"
529
- _exec_ MACPORTS "port selfupdate; port upgrade outdated"
530
- _exec_ YUM "yum update"
531
- _exec_ PORTAGE "
532
- if [[ -x /usr/bin/layman ]]; then
533
- layman --sync-all \
534
- && emerge --sync \
535
- && emerge -auND world $_PKG
536
- else
537
- emerge --sync \
538
- && emerge -uND world $_PKG
539
- fi
540
- "
541
- ;;
542
- "Su")
543
- _exec_ ZYPPER "echo 'Function is not available'; exit 1"
544
- _VERBOSE="" \
545
- _exec_ DPKG "apt-get upgrade"
546
- _exec_ HOMEBREW "brew upgrade"
547
- _exec_ MACPORTS "port upgrade outdated"
548
- _exec_ YUM "yum update"
549
- _exec_ PORTAGE "emerge -uND world $_PKG"
550
- ;;
551
- "Sy")
552
- _exec_ ZYPPER "zypper refresh"
553
- _VERBOSE="" \
554
- _exec_ DPKG "apt-get update"
555
- _exec_ HOMEBREW "brew update"
556
- _exec_ MACPORTS "port selfupdate" # or sync?
557
- _exec_ YUM "yum check-update"
558
- _FORCE="" \
559
- _exec_ PORTAGE "
560
- if [[ -x /usr/bin/layman ]]; then
561
- layman --sync-all && emerge --sync
562
- else
563
- emerge --sync
564
- fi
565
- "
566
- ;;
567
- "Ss")
568
- _exec_ ZYPPER "zypper search $_PKG"
569
- _exec_ DPKG "apt-cache search $_PKG"
570
- _exec_ HOMEBREW "brew search $_PKG"
571
- _exec_ MACPORTS "port search $_PKG"
572
- _exec_ YUM "yum -C search $_PKG"
573
- _FORCE="" \
574
- _exec_ PORTAGE "
575
- if [[ -x /usr/bin/eix ]]; then
576
- eix $_PKG
577
- else
578
- emerge --search $_PKG
579
- fi
580
- "
581
- ;;
582
- "Sc")
583
- _exec_ ZYPPER "zypper clean"
584
- _exec_ DPKG "apt-get clean"
585
- _exec_ HOMEBREW "brew cleanup"
586
- _exec_ MACPORTS "port clean --all inactive"
587
- _exec_ YUM "yum clean expire-cache"
588
- __FORCE="" \
589
- _exec_ PORTAGE "
590
- if [[ -x usr/bin/eclean-dist ]]; then
591
- eclean-dist -d -t1m -s50 -f
592
- else
593
- _error 'You need install gentoolkit to perform this operation.'
594
- fi
595
- "
596
- ;;
597
- "Scc")
598
- _exec_ ZYPPER "zypper clean"
599
- _exec_ DPKG "apt-get autoclean"
600
- _exec_ HOMEBREW "brew cleanup -s"
601
- _exec_ MACPORTS "port clean --all installed"
602
- _exec_ YUM "yum clean packages"
603
- _FORCE="" \
604
- _exec_ PORTAGE "
605
- if [[ -x /usr/bin/eclean ]]; then
606
- eclean -i distfiles
607
- else
608
- _error 'You need install gentoolkit to perform this operation.'
609
- fi
610
- "
611
- ;;
612
- "Sccc")
613
- _exec_ ZYPPER "echo 'Function is not available'; exit 1"
614
- _exec_ DPKG "rm -fv /var/cache/apt/*.bin
615
- rm -fv /var/cache/apt/archives/*.*
616
- rm -fv /var/lib/apt/lists/*.*
617
- apt-get autoclean"
618
- _exec_ HOMEBREW 'rm -rf $(brew --cache)'
619
- _os_is MACPORTS && _error "Function not implemented in macports"
620
- _exec_ YUM "yum clean all"
621
- _FORCE="" \
622
- _exec_ PORTAGE "rm -fv /usr/portage/distfiles/*.*"
623
- ;;
624
- "S")
625
- [[ -z "$_PKG" ]] \
626
- && { _error "You must specify a package"; exit 1; }
627
-
628
- _exec_ ZYPPER "zypper install $_TOPT $_PKG"
629
- _exec_ DPKG "apt-get install $_TOPT $_PKG"
630
- _exec_ HOMEBREW "brew install $_TOPT $_PKG"
631
- if [[ "$_TOPT" = fetch ]]
632
- then
633
- _exec_ MACPORTS "port patch $_PKG"
634
- else
635
- _exec_ MACPORTS "port install $_TOPT $_PKG"
636
- fi
637
- _exec_ YUM "yum install $_TOPT $_PKG"
638
- _exec_ PORTAGE "emerge $_TOPT $_PKG"
639
- ;;
640
-
641
- ####################################################################
642
- # UPGRADING #
643
- ####################################################################
644
-
645
- "U")
646
- _exec_ ZYPPER "zypper install $_PKG"
647
- _os_is HOMEBREW && _error "Function not implemented in homebrew"
648
- _os_is MACPORTS && _error "Function not implemented in macports"
649
- _os_is PORTAGE && _error "You need to implement a local overlay and do the installation as usual."
650
-
651
- _exec_ DPKG "dpkg -i $_TOPT $_PKG"
652
- _exec_ YUM "yum localinstall $_TOPT $_PKG"
653
- ;;
654
-
655
- # Default option
656
- *)
657
- _error "Error: Invalid option"
658
- exit 1
659
- ;;
660
- esac