pkgr 0.3.4 → 1.0.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +68 -463
- data/bin/pkgr +4 -52
- data/lib/pkgr.rb +13 -29
- data/lib/pkgr/app.rb +19 -4
- data/lib/pkgr/builder.rb +207 -0
- data/lib/pkgr/buildpack.rb +80 -0
- data/lib/pkgr/cli.rb +34 -158
- data/lib/pkgr/config.rb +65 -0
- data/lib/pkgr/data/distributions/debian/build_dependencies.yml +14 -0
- data/lib/pkgr/data/{debian → distributions/debian}/cron.d +0 -0
- data/lib/pkgr/data/distributions/debian/default.erb +12 -0
- data/lib/pkgr/data/distributions/debian/dependencies.yml +17 -0
- data/lib/pkgr/data/distributions/debian/hooks/postinstall.sh +27 -0
- data/lib/pkgr/data/distributions/debian/hooks/preinstall.sh +9 -0
- data/lib/pkgr/data/{debian → distributions/debian}/logrotate.erb +0 -0
- data/lib/pkgr/data/distributions/debian/runner.erb +122 -0
- data/lib/pkgr/data/distributions/debian/upstart/master.conf.erb +7 -0
- data/lib/pkgr/data/distributions/debian/upstart/process.conf.erb +7 -0
- data/lib/pkgr/data/distributions/debian/upstart/process_master.conf.erb +2 -0
- data/lib/pkgr/dispatcher.rb +51 -0
- data/lib/pkgr/distributions.rb +18 -0
- data/lib/pkgr/distributions/debian.rb +157 -0
- data/lib/pkgr/git.rb +24 -0
- data/lib/pkgr/process.rb +18 -0
- data/lib/pkgr/templates/dir_template.rb +14 -0
- data/lib/pkgr/templates/file_template.rb +38 -0
- data/lib/pkgr/version.rb +1 -1
- metadata +93 -26
- data/lib/pkgr/data/debian/changelog +0 -0
- data/lib/pkgr/data/debian/compat.erb +0 -1
- data/lib/pkgr/data/debian/control.erb +0 -12
- data/lib/pkgr/data/debian/copyright.erb +0 -17
- data/lib/pkgr/data/debian/default.erb +0 -11
- data/lib/pkgr/data/debian/dirs.erb +0 -2
- data/lib/pkgr/data/debian/docs.erb +0 -0
- data/lib/pkgr/data/debian/init.d.erb +0 -155
- data/lib/pkgr/data/debian/install.erb +0 -16
- data/lib/pkgr/data/debian/links.erb +0 -5
- data/lib/pkgr/data/debian/postinst.erb +0 -59
- data/lib/pkgr/data/debian/prerm.erb +0 -57
- data/lib/pkgr/data/debian/rules.erb +0 -7
- data/lib/pkgr/pkgr.rake +0 -50
- data/lib/pkgr/railtie.rb +0 -7
data/lib/pkgr/git.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'mixlib/shellout'
|
2
|
+
|
3
|
+
module Pkgr
|
4
|
+
class Git
|
5
|
+
attr_reader :path
|
6
|
+
|
7
|
+
def initialize(path)
|
8
|
+
@path = path
|
9
|
+
end
|
10
|
+
|
11
|
+
def latest_tag
|
12
|
+
return nil unless valid?
|
13
|
+
Dir.chdir(path) do
|
14
|
+
git_describe = Mixlib::ShellOut.new("git describe --tags --abbrev=0")
|
15
|
+
git_describe.run_command
|
16
|
+
git_describe.stdout.chomp
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def valid?
|
21
|
+
File.file?(File.join(path, ".git", "index"))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/pkgr/process.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Pkgr
|
2
|
+
class Process
|
3
|
+
DAEMON_PROCESSES = ["web", "worker"]
|
4
|
+
|
5
|
+
attr_reader :name, :command
|
6
|
+
attr_accessor :scale
|
7
|
+
|
8
|
+
def initialize(name, command, scale = 1)
|
9
|
+
@name = name
|
10
|
+
@command = command
|
11
|
+
@scale = scale || 1
|
12
|
+
end
|
13
|
+
|
14
|
+
def daemon?
|
15
|
+
DAEMON_PROCESSES.include?(name)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module Pkgr
|
4
|
+
module Templates
|
5
|
+
class FileTemplate
|
6
|
+
attr_reader :source, :target
|
7
|
+
|
8
|
+
def initialize(target, source, opts = {})
|
9
|
+
@target = target
|
10
|
+
@source = source
|
11
|
+
@opts = opts
|
12
|
+
end
|
13
|
+
|
14
|
+
# Assumes that the current working directory is correct
|
15
|
+
def install(template_binding)
|
16
|
+
make_dir
|
17
|
+
File.open(target, "w+") do |f|
|
18
|
+
if source.respond_to?(:path) && File.extname(source) == ".erb"
|
19
|
+
f << ERB.new(source.read).result(template_binding)
|
20
|
+
else
|
21
|
+
f << source.read
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
FileUtils.chmod mode, target
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def make_dir
|
30
|
+
FileUtils.mkdir_p File.dirname(target)
|
31
|
+
end
|
32
|
+
|
33
|
+
def mode
|
34
|
+
@opts[:mode] || 0644
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/pkgr/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pkgr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.1.pre
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Cyril Rohr
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-10-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -27,6 +27,70 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: thor
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: fpm
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: mixlib-log
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: mixlib-shellout
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
30
94
|
- !ruby/object:Gem::Dependency
|
31
95
|
name: rspec
|
32
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -43,7 +107,7 @@ dependencies:
|
|
43
107
|
- - ~>
|
44
108
|
- !ruby/object:Gem::Version
|
45
109
|
version: '2'
|
46
|
-
description: Package your Rails apps as debian packages
|
110
|
+
description: Package your Ruby & Rails apps as debian packages
|
47
111
|
email:
|
48
112
|
- cyril.rohr@gmail.com
|
49
113
|
executables:
|
@@ -54,33 +118,36 @@ extra_rdoc_files:
|
|
54
118
|
- README.md
|
55
119
|
files:
|
56
120
|
- lib/pkgr/app.rb
|
121
|
+
- lib/pkgr/builder.rb
|
122
|
+
- lib/pkgr/buildpack.rb
|
57
123
|
- lib/pkgr/cli.rb
|
124
|
+
- lib/pkgr/config.rb
|
58
125
|
- lib/pkgr/data/bin/executable
|
59
126
|
- lib/pkgr/data/config/pre_boot.rb
|
60
|
-
- lib/pkgr/data/debian/
|
61
|
-
- lib/pkgr/data/debian/
|
62
|
-
- lib/pkgr/data/debian/
|
63
|
-
- lib/pkgr/data/debian/
|
64
|
-
- lib/pkgr/data/debian/
|
65
|
-
- lib/pkgr/data/debian/
|
66
|
-
- lib/pkgr/data/debian/
|
67
|
-
- lib/pkgr/data/debian/
|
68
|
-
- lib/pkgr/data/debian/
|
69
|
-
- lib/pkgr/data/debian/
|
70
|
-
- lib/pkgr/data/debian/
|
71
|
-
- lib/pkgr/data/debian/logrotate.erb
|
72
|
-
- lib/pkgr/data/debian/postinst.erb
|
73
|
-
- lib/pkgr/data/debian/prerm.erb
|
74
|
-
- lib/pkgr/data/debian/rules.erb
|
127
|
+
- lib/pkgr/data/distributions/debian/build_dependencies.yml
|
128
|
+
- lib/pkgr/data/distributions/debian/cron.d
|
129
|
+
- lib/pkgr/data/distributions/debian/default.erb
|
130
|
+
- lib/pkgr/data/distributions/debian/dependencies.yml
|
131
|
+
- lib/pkgr/data/distributions/debian/hooks/postinstall.sh
|
132
|
+
- lib/pkgr/data/distributions/debian/hooks/preinstall.sh
|
133
|
+
- lib/pkgr/data/distributions/debian/logrotate.erb
|
134
|
+
- lib/pkgr/data/distributions/debian/runner.erb
|
135
|
+
- lib/pkgr/data/distributions/debian/upstart/master.conf.erb
|
136
|
+
- lib/pkgr/data/distributions/debian/upstart/process.conf.erb
|
137
|
+
- lib/pkgr/data/distributions/debian/upstart/process_master.conf.erb
|
75
138
|
- lib/pkgr/data/pkgr.yml
|
76
|
-
- lib/pkgr/
|
77
|
-
- lib/pkgr/
|
139
|
+
- lib/pkgr/dispatcher.rb
|
140
|
+
- lib/pkgr/distributions/debian.rb
|
141
|
+
- lib/pkgr/distributions.rb
|
142
|
+
- lib/pkgr/git.rb
|
143
|
+
- lib/pkgr/process.rb
|
144
|
+
- lib/pkgr/templates/dir_template.rb
|
145
|
+
- lib/pkgr/templates/file_template.rb
|
78
146
|
- lib/pkgr/version.rb
|
79
147
|
- lib/pkgr.rb
|
80
148
|
- LICENSE
|
81
149
|
- README.md
|
82
|
-
-
|
83
|
-
YmluL3BrZ3I=
|
150
|
+
- bin/pkgr
|
84
151
|
homepage: http://github.com/crohr/pkgr
|
85
152
|
licenses: []
|
86
153
|
post_install_message:
|
@@ -93,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
160
|
requirements:
|
94
161
|
- - ! '>='
|
95
162
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
163
|
+
version: 1.8.7
|
97
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
165
|
none: false
|
99
166
|
requirements:
|
@@ -102,8 +169,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
169
|
version: '1.3'
|
103
170
|
requirements: []
|
104
171
|
rubyforge_project:
|
105
|
-
rubygems_version: 1.8.
|
172
|
+
rubygems_version: 1.8.23
|
106
173
|
signing_key:
|
107
174
|
specification_version: 3
|
108
|
-
summary: Package your Rails apps as debian packages
|
175
|
+
summary: Package your Ruby & Rails apps as debian packages
|
109
176
|
test_files: []
|
File without changes
|
@@ -1 +0,0 @@
|
|
1
|
-
7
|
@@ -1,12 +0,0 @@
|
|
1
|
-
Source: <%= name %>
|
2
|
-
Section: unknown
|
3
|
-
Priority: extra
|
4
|
-
Maintainer: <%= author_name %> <<%= author_email %>>
|
5
|
-
Build-Depends: <%= debian_build_dependencies.join(",") %>
|
6
|
-
Standards-Version: 3.7.3
|
7
|
-
Homepage: <%= homepage %>
|
8
|
-
|
9
|
-
Package: <%= name %>
|
10
|
-
Architecture: <%= architecture %>
|
11
|
-
Depends: <%= debian_runtime_dependencies.join(", ") %>
|
12
|
-
Description: <%= description %>
|
@@ -1,17 +0,0 @@
|
|
1
|
-
This package was debianized by Pkgr <http://crohr.me/pkgr> on <%= Time.now.to_s %>.
|
2
|
-
|
3
|
-
It was downloaded from <ssh://somewhere>
|
4
|
-
|
5
|
-
Upstream Author(s):
|
6
|
-
|
7
|
-
<%= author_name %> <<%=author_email %>>
|
8
|
-
|
9
|
-
Copyright:
|
10
|
-
|
11
|
-
Some copyright here
|
12
|
-
|
13
|
-
License:
|
14
|
-
|
15
|
-
<Put the license of the package here indented by 4 spaces>
|
16
|
-
|
17
|
-
The Debian packaging is public domain.
|
@@ -1,11 +0,0 @@
|
|
1
|
-
# Defaults for <%= name %> initscript
|
2
|
-
# sourced by /etc/init.d/<%= name %>
|
3
|
-
# installed at /etc/default/<%= name %> by the maintainer scripts
|
4
|
-
|
5
|
-
#
|
6
|
-
# This is a POSIX shell fragment
|
7
|
-
#
|
8
|
-
|
9
|
-
# Additional options that are passed to the Daemon.
|
10
|
-
DAEMON_OPTS="server -d --pid $PIDFILE --user $NAME --group $NAME --log /var/log/$NAME/thin.log"
|
11
|
-
|
File without changes
|
@@ -1,155 +0,0 @@
|
|
1
|
-
#! /bin/sh
|
2
|
-
#
|
3
|
-
### BEGIN INIT INFO
|
4
|
-
# Provides: <%= name %>
|
5
|
-
# Required-Start: $remote_fs $syslog
|
6
|
-
# Required-Stop: $remote_fs $syslog
|
7
|
-
# Default-Start: 2 3 4 5
|
8
|
-
# Default-Stop: 0 1 6
|
9
|
-
# Short-Description: Start <%= name %> app at boot time.
|
10
|
-
# Description: Enable service provided by <%= name %>.
|
11
|
-
### END INIT INFO
|
12
|
-
#
|
13
|
-
|
14
|
-
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
15
|
-
NAME="<%= name %>"
|
16
|
-
DAEMON=/usr/bin/$NAME
|
17
|
-
DESC=$NAME
|
18
|
-
|
19
|
-
test -x $DAEMON || exit 0
|
20
|
-
|
21
|
-
LOGDIR=/var/log/$NAME
|
22
|
-
PIDFILE=/var/run/$NAME.pid
|
23
|
-
DODTIME=5 # Time to wait for the server to die, in seconds
|
24
|
-
# If this value is set too low you might not
|
25
|
-
# let some servers to die gracefully and
|
26
|
-
# 'restart' will not work
|
27
|
-
|
28
|
-
# Include defaults if available
|
29
|
-
if [ -f /etc/default/$NAME ] ; then
|
30
|
-
. /etc/default/$NAME
|
31
|
-
fi
|
32
|
-
|
33
|
-
set -e
|
34
|
-
|
35
|
-
|
36
|
-
running_pid()
|
37
|
-
{
|
38
|
-
# Check if a given process status name matches a given name
|
39
|
-
pid=$1
|
40
|
-
name=$2
|
41
|
-
[ -z "$pid" ] && return 1
|
42
|
-
[ ! -d /proc/$pid ] && return 1
|
43
|
-
cmd=`cat /proc/$pid/status | grep Name: | cut -f 2`
|
44
|
-
# Is this the expected child?
|
45
|
-
[ "$cmd" != "$name" ] && return 1
|
46
|
-
return 0
|
47
|
-
}
|
48
|
-
|
49
|
-
running()
|
50
|
-
{
|
51
|
-
# Check if the process is running looking at /proc
|
52
|
-
# (works for all users)
|
53
|
-
# No pidfile, probably no daemon present
|
54
|
-
[ ! -f "$PIDFILE" ] && return 1
|
55
|
-
# Obtain the pid
|
56
|
-
pid=`cat $PIDFILE`
|
57
|
-
running_pid $pid $NAME || return 1
|
58
|
-
return 0
|
59
|
-
}
|
60
|
-
|
61
|
-
force_stop() {
|
62
|
-
# Forcefully kill the process
|
63
|
-
[ ! -f "$PIDFILE" ] && return
|
64
|
-
if running ; then
|
65
|
-
kill -15 $pid
|
66
|
-
# Is it really dead?
|
67
|
-
[ -n "$DODTIME" ] && sleep "$DODTIME"s
|
68
|
-
if running ; then
|
69
|
-
kill -9 $pid
|
70
|
-
[ -n "$DODTIME" ] && sleep "$DODTIME"s
|
71
|
-
if running ; then
|
72
|
-
echo "Cannot kill $NAME (pid=$pid)!"
|
73
|
-
exit 1
|
74
|
-
fi
|
75
|
-
fi
|
76
|
-
fi
|
77
|
-
rm -f $PIDFILE
|
78
|
-
return 0
|
79
|
-
}
|
80
|
-
|
81
|
-
case "$1" in
|
82
|
-
start)
|
83
|
-
echo -n "Starting $DESC: "
|
84
|
-
if running ; then
|
85
|
-
echo "already running."
|
86
|
-
else
|
87
|
-
$DAEMON $DAEMON_OPTS start
|
88
|
-
# Needed to let Thin handle stale pid file.
|
89
|
-
sleep 1
|
90
|
-
if running ; then
|
91
|
-
echo "OK."
|
92
|
-
else
|
93
|
-
echo "ERROR."
|
94
|
-
fi
|
95
|
-
fi
|
96
|
-
;;
|
97
|
-
stop)
|
98
|
-
echo -n "Stopping $DESC: "
|
99
|
-
$DAEMON $DAEMON_OPTS stop
|
100
|
-
echo "OK."
|
101
|
-
;;
|
102
|
-
force-stop)
|
103
|
-
echo -n "Forcefully stopping $DESC: "
|
104
|
-
force_stop
|
105
|
-
if ! running ; then
|
106
|
-
echo "OK."
|
107
|
-
else
|
108
|
-
echo "ERROR."
|
109
|
-
fi
|
110
|
-
;;
|
111
|
-
#reload)
|
112
|
-
#
|
113
|
-
# If the daemon can reload its config files on the fly
|
114
|
-
# for example by sending it SIGHUP, do it here.
|
115
|
-
#
|
116
|
-
# If the daemon responds to changes in its config file
|
117
|
-
# directly anyway, make this a do-nothing entry.
|
118
|
-
#
|
119
|
-
# echo "Reloading $DESC configuration files."
|
120
|
-
# start-stop-daemon --stop --signal 1 --quiet --pidfile \
|
121
|
-
# /var/run/$NAME.pid --exec $DAEMON
|
122
|
-
#;;
|
123
|
-
force-reload)
|
124
|
-
#
|
125
|
-
# If the "reload" option is implemented, move the "force-reload"
|
126
|
-
# option to the "reload" entry above. If not, "force-reload" is
|
127
|
-
# just the same as "restart" except that it does nothing if the
|
128
|
-
# daemon isn't already running.
|
129
|
-
# check wether $DAEMON is running. If so, restart
|
130
|
-
if running ; then
|
131
|
-
$0 restart
|
132
|
-
fi
|
133
|
-
;;
|
134
|
-
restart)
|
135
|
-
echo "Restarting $DESC..."
|
136
|
-
$0 stop && $0 start
|
137
|
-
;;
|
138
|
-
status)
|
139
|
-
echo -n "$NAME is "
|
140
|
-
if running ; then
|
141
|
-
echo "running."
|
142
|
-
else
|
143
|
-
echo "not running."
|
144
|
-
exit 1
|
145
|
-
fi
|
146
|
-
;;
|
147
|
-
*)
|
148
|
-
N=/etc/init.d/$NAME
|
149
|
-
# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
|
150
|
-
echo "Usage: $N {start|stop|restart|force-reload|status|force-stop}" >&2
|
151
|
-
exit 1
|
152
|
-
;;
|
153
|
-
esac
|
154
|
-
|
155
|
-
exit 0
|