pkgr 0.3.1 → 0.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/README.md +103 -37
  2. data/lib/pkgr/cli.rb +3 -3
  3. data/lib/pkgr/version.rb +1 -1
  4. metadata +1 -1
data/README.md CHANGED
@@ -50,19 +50,28 @@ Ruby1.9 (+rubygems).
50
50
 
51
51
  ## What?
52
52
 
53
- This gem will allow you to package your Rails3 application, create an `init.d`
54
- script for you, install a binary file to start your app/rake tasks/console,
55
- put your configuration files in `/etc/app-name/`, setup a proper logrotate
56
- file so that your log files don't eat all the disk space of your server, and a
57
- few other things.
53
+ This gem will allow you to package your Rails3 application as a `.deb` package, and sets up a few things for you:
58
54
 
59
- The default target installation directory for the other app files will be
55
+ * an `init.d` script to easily start/stop/restart your app, and make it load when the server boots;
56
+
57
+ * an executable to manually start the server, your rake tasks, or access the console;
58
+
59
+ * your configuration files will be available in `/etc/app-name/*.yml`;
60
+
61
+ * defaults for your app (host, port, etc.) can be setup in `/etc/default/app-name`;
62
+
63
+ * a proper `logrotate` file will be created for you, so that your log files
64
+ don't eat all the disk space of your server;
65
+
66
+ * and a few other things.
67
+
68
+ The default target installation directory for all the other app files will be
60
69
  `/opt/local/app-name`. This can be configured.
61
70
 
62
71
  ## Requirements
63
72
 
64
73
  * You must use Rails3+ and ruby1.9+ in your application. This may work with
65
- other rubies but then you'll need to add a rubygems dependency.
74
+ other rubies but then you'll need to add adapt the dependencies.
66
75
 
67
76
  * Your Rails application must be able to run with the
68
77
  [`thin`](http://code.macournoyer.com/thin/) web server. Don't forget to add
@@ -74,9 +83,60 @@ The default target installation directory for the other app files will be
74
83
  email is taken from the git configuration, and the changelog is populated
75
84
  based on the git log between two versions.
76
85
 
77
- ## Getting started
86
+ ## Getting started (quickly)
87
+
88
+ Aka, how to build a debian package out of your Rails app in 5 minutes. This
89
+ assumes that you have a VM or server running Debian Squeeze readily available
90
+ for building the package.
91
+
92
+ Install `pkgr`:
93
+
94
+ $ gem install pkgr
95
+
96
+ Create a new Rails app:
97
+
98
+ $ rails new my-app
99
+ create
100
+ create README.rdoc
101
+ create Rakefile
102
+ ...
103
+ create vendor/plugins
104
+ create vendor/plugins/.gitkeep
105
+
106
+ Initialize the git repository (if not already done):
107
+
108
+ $ cd my-app
109
+ $ git init
110
+ $ git add .
111
+ $ git commit -m "First commit"
112
+
113
+ Package (this will create a new branch prefixed with `pkgr-`. You can delete
114
+ it afterwards):
115
+
116
+ $ pkgr --uri . --bump 0.1.0 --host debian-build-machine
117
+ ...
118
+ my-app_0.1.0-1_amd64.deb 100% 6080KB 5.9MB/s 00:01
119
+
120
+ Your .deb package is in `pkg/my-app_0.1.0-1_amd64.deb`. Install it on your production server:
121
+
122
+ $ scp pkg/my-app_0.1.0-1_amd64.deb production-machine:/tmp/
123
+ $ ssh production-machine 'sudo dpkg -i /tmp/my-app_0.1.0-1_amd64.deb || sudo apt-get -f -y install'
124
+
125
+ The app should now be up and running on `0.0.0.0:8000`. You might want to change this in the `/etc/default/my-app` file on the server.
126
+
127
+ $ ssh production-machine 'curl -is localhost:8000'
128
+
129
+ You should get a 404. This is expected since this app does nothing. You can
130
+ now build your app and update the `config/pkgr.yml` file when you have system
131
+ dependencies to add.
132
+
133
+ Enjoy, and you may want to read the step-by-step guide to learn more about
134
+ what's going on.
135
+
136
+ ## Getting started (step by step)
78
137
 
79
- Or, how to build a debian package of your Rails app in 5 minutes.
138
+ `pkgr` can be used as a command-line tool (fully automatic), or through the
139
+ rake tasks it installs when you require it in your Gemfile. Below is how you would use the rake tasks to accomplish the same thing as before.
80
140
 
81
141
  ### Setup
82
142
 
@@ -93,7 +153,7 @@ Create a new Rails app:
93
153
  Go into your app directory, and add `pkgr` to your Gemfile:
94
154
 
95
155
  $ cd my-app
96
- $ echo "gem 'pkgr', :group => :development" >> Gemfile
156
+ $ echo "gem 'pkgr'" >> Gemfile
97
157
 
98
158
  For now, this packaging tool only supports `thin` (would be easy to add others, though), so add it to your Gemfile:
99
159
 
@@ -299,29 +359,11 @@ unauthenticated packages:
299
359
 
300
360
  production-server # echo 'APT::Get::AllowUnauthenticated "true";' >> /etc/apt/apt.conf.d/allow-unauthenticated
301
361
 
302
- Easy.
303
-
304
- ## Notes of interest
305
-
306
- * your configuration files will be stored in `/etc/my-app/*.yml`, making it easy to manage with Puppet or manually (don't forget to `/etc/init.d/my-app restart` after making changes).
307
-
308
- * you can change how the Thin server is launched by adding options to the `/etc/default/my-app` file.
309
-
310
- * your log files will be stored in `/var/log/my-app/`.
311
-
312
- * your db files will be stored in `var/db/my-app/`.
313
-
314
- * if you've got migrations to run, just do a `my-app rake db:migrate` (we might want to run them automatically as part of the postinstall process).
315
-
316
- * you can launch a console using `my-app console`.
317
-
318
- * use the initd script to start and stop the app: `/etc/init.d/my-app [start|stop|status]`.
319
-
320
362
  ## General usage
321
363
 
322
- Declare `pkgr` as one of your **development** dependencies in your `Gemfile`:
364
+ Declare `pkgr` as one of your dependencies in your `Gemfile`:
323
365
 
324
- gem 'pkgr', :group => :development
366
+ gem 'pkgr'
325
367
 
326
368
  Also add `thin`:
327
369
 
@@ -384,18 +426,24 @@ Once you're ready to package your app, just run the following commands:
384
426
  Starting from version 0.3.0, pkgr now comes with an executable, which allows
385
427
  to package any app stored in a git repository with one command.
386
428
 
387
- For instance, here is how you would package the Redmine app:
429
+ For instance, here is how you would package the [Redmine] [redmine] app:
388
430
 
389
- pkgr --uri https://github.com/edavis10/redmine --ref master --bump 1.4.1 \
431
+ $ cd /tmp
432
+ $ pkgr --uri https://github.com/edavis10/redmine --ref master --bump 1.4.1 \
390
433
  -c https://raw.github.com/crohr/pkgr/master/examples/redmine/configuration.yml \
391
434
  -c https://raw.github.com/crohr/pkgr/master/examples/redmine/database.yml \
392
435
  -c https://raw.github.com/crohr/pkgr/master/examples/redmine/pkgr.yml \
393
436
  --host debian-build
394
437
 
395
- You .deb package will be available in `redmine/pkg/`. In this example, the given `pkgr.yml` configuration file automatically adds a dependency on `mysql-server`, which means that when you install the generated redmine package, it will be ready to be accessed on `0.0.0.0:8000`.
438
+ You .deb package will be available in `/tmp/redmine/pkg/`. In this example,
439
+ the given `pkgr.yml` configuration file automatically adds a dependency on
440
+ `mysql-server`, which means that when you install the generated redmine
441
+ package, it will be ready to be accessed on `0.0.0.0:8000`.
442
+
443
+ Note that for simple projects, you may not need to specify all those
444
+ configuration files on the command line. Redmine is a complex app.
396
445
 
397
- Note that for simple projects, you may not need to specify any configuration
398
- file on the command line. See `pkgr -h` for the list of options available:
446
+ See `pkgr -h` for the list of options available:
399
447
 
400
448
  $ pkgr -h
401
449
  * Description
@@ -415,6 +463,24 @@ file on the command line. See `pkgr -h` for the list of options available:
415
463
  -h, --help Show this message
416
464
  --version Show version
417
465
 
466
+ [redmine]: http://www.redmine.org/
467
+
468
+ ## Notes of interest
469
+
470
+ * your configuration files will be stored in `/etc/my-app/*.yml`, making it easy to manage with Puppet or manually (don't forget to `/etc/init.d/my-app restart` after making changes).
471
+
472
+ * you can change how the Thin server is launched by adding options to the `/etc/default/my-app` file.
473
+
474
+ * your log files will be stored in `/var/log/my-app/`.
475
+
476
+ * your db files will be stored in `var/db/my-app/`.
477
+
478
+ * if you've got migrations to run, just do a `my-app rake db:migrate` (we might want to run them automatically as part of the postinstall process).
479
+
480
+ * you can launch a console using `my-app console`.
481
+
482
+ * use the initd script to start and stop the app: `/etc/init.d/my-app [start|stop|restart|status]`.
483
+
418
484
  ## Todo
419
485
 
420
486
  * Speed up the packaging process (currently, bundler re-downloads all the gems
@@ -422,9 +488,9 @@ file on the command line. See `pkgr -h` for the list of options available:
422
488
 
423
489
  * Include tasks for building RPMs.
424
490
 
425
- * Better debian initd script.
491
+ * The included initd script sucks. Improve it.
426
492
 
427
- * Populate dependencies based on gems declared in the Gemfile.
493
+ * Populate system dependencies based on gems declared in the Gemfile.
428
494
 
429
495
  * Some tests.
430
496
 
data/lib/pkgr/cli.rb CHANGED
@@ -140,17 +140,17 @@ module Pkgr
140
140
  Pkgr.setup(dir)
141
141
 
142
142
  gemfile = File.read("Gemfile")
143
- unless gemfile =~ /$gem 'pkgr'/
143
+ unless gemfile =~ /^gem 'pkgr'/
144
144
  File.open("Gemfile", "a") do |f|
145
145
  f.puts
146
146
  f.puts "gem 'pkgr'"
147
147
  end
148
148
  end
149
149
 
150
- unless gemfile =~ /$gem 'thin'/
150
+ unless gemfile =~ /^gem 'thin'/
151
151
  File.open("Gemfile", "a") do |f|
152
152
  f.puts
153
- f.puts "gem 'pkgr'"
153
+ f.puts "gem 'thin'"
154
154
  end
155
155
  end
156
156
 
data/lib/pkgr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pkgr
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pkgr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: