Upgrade to Pro — share decks privately, control downloads, hide ads and more …

fpm-cookery RUGHH Oct 2011

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
Tweet

More Decks by Bernd Ahlers

Other Decks in Programming

Transcript

  1. 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]
  2. Debian $ find . | sort . ./debian ./debian/changelog ./debian/compat

    ./debian/control ./debian/copyright ./debian/cron.d.ex ./debian/docs ./debian/emacsen-install.ex
  3. $ [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
  4. fpm

  5. 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
  6. 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
  7. brew2deb (good stuff) helps you to build packages quickly can

    use Homebrew formulas (with minimal modifications) can handle Debian .dsc files (awesome!)
  8. brew2deb (stuff I don't like) vendored Homebrew (with lots of

    Mac OS specific stuff) vendored fpm no speparation between framework and formulas
  9. 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
  10. 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
  11. 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)
  12. Features (cont.) sandboxed builds (no root, no install in /usr)

    creates packages with fpm standalone recipe trees
  13. Features - planned (cont.) more source types (Git, SVN, ...)

    support for rpm (dependencies, rpm specific options) programing api?
  14. 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
  15. 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
  16. 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
  17. 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
  18. 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
  19. How To Contribute I'd love to hear from you (likes,

    hate, usage reports) fork and send pull requests send patches have fun anything!