Share
Embed
fpm-cookery RUGHH Oct 2011
An introduction to fpm-cookery I gave at the Ruby User Group Hamburg/Germany in October 2011.
Bernd Ahlers
October 12, 2011
Transcript
39 slides
-
No web stuff today! this talk is about building and
packaging software -
Debian $ curl http://.../redis-2.2.14.tar.gz $ mkdir redis-2.2.14 $ cd redis-2.2.14
$ dh_make -f ../redis-2.2.14.tar.gz [answer questions] -
Debian $ find . | sort . ./debian ./debian/changelog ./debian/compat
./debian/control ./debian/copyright ./debian/cron.d.ex ./debian/docs ./debian/emacsen-install.ex -
$ [cont.] ./debian/emacsen-remove.ex ./debian/emacsen-startup.ex ./debian/init.d.ex ./debian/init.d.lsb.ex ./debian/manpage.1.ex ./debian/manpage.sgml.ex ./debian/manpage.xml.ex ./debian/menu.ex
./debian/postinst.ex ./debian/postrm.ex ./debian/preinst.ex ./debian/prerm.ex ./debian/README.Debian ./debian/README.source ./debian/rules ./debian/redis.default.ex ./debian/redis.doc-base.EX ./debian/watch.ex -
fpm by Jordan Sissel (@jordansissel) helps you build packages quickly
DEB and RPM formats -
fpm $ curl http://.../redis-2.2.14.tar.gz $ tar -xzf redis-2.2.14 $ cd
redis-2.2.14 $ make $ make PREFIX=$PWD/dest/usr install $ fpm -s dir -t deb -n redis -v 2.2.14 -C dest Created $PWD/redis_2.2.14_i386.deb -
RPM packages? $ curl http://.../redis-2.2.14.tar.gz $ tar -xzf redis-2.2.14 $
cd redis-2.2.14 $ make $ make PREFIX=$PWD/dest/usr install $ fpm -s dir -t rpm -n redis -v 2.2.14 -C dest Created $PWD/redis-2.2.14.i686.rpm -
brew2deb (good stuff) helps you to build packages quickly can
use Homebrew formulas (with minimal modifications) can handle Debian .dsc files (awesome!) -
brew2deb (stuff I don't like) vendored Homebrew (with lots of
Mac OS specific stuff) vendored fpm no speparation between framework and formulas -
brew2deb Usage $ cd brew2deb.git/packages/redis $ ../../bin/brew2deb ==> Downloading ...
==> Extracing source ... ==> Packaging into a .deb Created brew2deb/packages/redis/pkg/redis-2.2.14+github1_i386.deb -
Makefile $ cat ~/.fpmmake zeromq: destdir rm -rf $(DEST_DIR)/$@ ./configure
--prefix=/usr make make DESTDIR=$(DEST_ROOT)/$@ install fpm -s dir -t $(TARGET) -n zeromq -v 2.1.7 \ -C $(DEST_ROOT)/$@ \ -m $(MAINTAINER) --url http://www.zeromq.org/ $ make -f ~/.fpmmake zeromq -
Features recipes to describe the build can handle different source
types (http/https/ftp for now...) builds software based on the recipe (configure, make, make install) -
Features (cont.) sandboxed builds (no root, no install in /usr)
creates packages with fpm standalone recipe trees -
Features - planned (cont.) more source types (Git, SVN, ...)
support for rpm (dependencies, rpm specific options) programing api? -
Setup $ gem install fpm-cookery Fetching: fpm-cookery-0.0.1.gem (100%) Successfully installed
fpm-cookery-0.0.1 1 gem installed $ mkdir fpm-recipes/redis && cd fpm-recipes/redis $ $EDITOR recipe.rb -
Example Recipe class Redis < F P M : :
C o o k e r y : : R e c i p e description ' A n a d v a n c e d k e y - v a l u e s t o r e ' name ' r e d i s - s e r v e r ' version ' 2 : 2 . 2 . 1 4 ' revision 1 homepage ' h t t p : / / r e d i s . i o / ' source \ " h t t p : / / r e d i s . g o o g l e c o d e . c o m / f i l e s / r e d i s - 2 . 2 . 1 4 . t a r . g z " section ' d a t a b a s e ' conflicts ' r e d i s - s e r v e r ' config_files ' / e t c / r e d i s / r e d i s . c o n f ' # ... end -
Example Recipe (cont.) class Redis < F P M :
: C o o k e r y : : R e c i p e # ... def build make # Fix up default conf file to match our paths inline_replace " r e d i s . c o n f " do |s| s.gsub! ' d a e m o n i z e n o ' , ' d a e m o n i z e y e s ' s.gsub! ' l o g f i l e s t d o u t ' , ' l o g f i l e / v a r / l o g / r e d i s / r e d i s - s e r v e r . l o g ' s.gsub! ' l o g l e v e l v e r b o s e ' , ' l o g l e v e l n o t i c e ' s.gsub! ' d i r . / ' , ' d i r / v a r / l i b / r e d i s / ' s.gsub! ' / v a r / r u n / r e d i s . p i d ' , ' / v a r / r u n / r e d i s . p i d ' end end # ... end -
Example Recipe (cont.) class Redis < F P M :
: C o o k e r y : : R e c i p e # ... def install %w(run lib/ r e d i s l o g / redis).each { |p| var(p).mkpath } bin.install Dir[" s r c / r e d i s - * " ].select do |f| f =~ / r e d i s - [ ^ \ . ] + $ / end etc(' r e d i s ' ).install " r e d i s . c o n f " etc(' i n i t . d ' ).install_p(workdir(' r e d i s - s e r v e r . i n i t . d ' ), ' r e d i s - s e r v e r ' ) end end -
CLI Example (build) $ cd fpm-recipes/redis $ fpm-cook cd src
&& make all make[1]: Entering directory `tmp-build/redis-2.2.14/src' ... ["fpm", "-n", "redis-server", "-v", "2.2.14+fpm1", "-t", "deb", "-s", "dir", "--url", "http://redis.io/", "-C", "fpm-recipes/redis/tmp-dest", "--maintainer", "Bernd Ahlers <[email protected]>", "--category", "database", "--epoch", "2", "--description", "An advanced key-value store", "--conflicts", "redis-server", "--config-files", "/etc/redis/redis.conf", "."] Created $PWD/pkg/redis-server_2.2.14+fpm1_i386.deb -
CLI Example (clean) $ cd fpm-recipes/redis $ fpm-cook clean =>
removes temp stuff -
How To Contribute I'd love to hear from you (likes,
hate, usage reports) fork and send pull requests send patches have fun anything!