Pro Yearly is on sale from $80 to $50! »

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.

A428c190cba8985990a410b0450b680f?s=128

Bernd Ahlers

October 12, 2011
Tweet

Transcript

  1. fpm-cookery Ruby User Group HH 12. Oct 2011

  2. No web stuff today! this talk is about building and

    packaging software
  3. No web stuff today!

  4. I need a custom package real quick!

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

    ./debian/control ./debian/copyright ./debian/cron.d.ex ./debian/docs ./debian/emacsen-install.ex
  7. $ [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
  8. Debian we haven't built anything yet I cant' remember the

    commands
  9. Debian lots of Debian documentation to read lots of rules

    to follow
  10. Debian ?!

  11. fpm

  12. fpm by Jordan Sissel (@jordansissel) helps you build packages quickly

    DEB and RPM formats
  13. 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
  14. 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
  15. brew2deb

  16. brew2deb by Aman Gupta (@tmm1) a hack that combines Homebrew

    and fpm
  17. brew2deb (good stuff) helps you to build packages quickly can

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

    Mac OS specific stuff) vendored fpm no speparation between framework and formulas
  19. 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
  20. Custom Scripts

  21. Custom Scripts I built my own hacks Makefiles shell scripts

  22. 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
  23. Custom Scripts works but feels crappy isn't really shareable

  24. fpm-cookery

  25. fpm-cookery an infrastructure to automatically build and package software based

    on recipes
  26. fpm-cookery ideas and code from Homebrew ideas and code from

    brew2deb
  27. 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)
  28. Features (cont.) sandboxed builds (no root, no install in /usr)

    creates packages with fpm standalone recipe trees
  29. Features - planned patch handling build/run depends check recipe validation

  30. Features - planned (cont.) more source types (Git, SVN, ...)

    support for rpm (dependencies, rpm specific options) programing api?
  31. 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
  32. 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
  33. 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
  34. 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
  35. 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 <bernd@tuneafish.de>", "--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
  36. CLI Example (clean) $ cd fpm-recipes/redis $ fpm-cook clean =>

    removes temp stuff
  37. How To Contribute I'd love to hear from you (likes,

    hate, usage reports) fork and send pull requests send patches have fun anything!
  38. Thank you! I am Bernd Ahlers @berndahlers github.com/bernd xing.to/bernd bernd@tuneafish.de

  39. Questions? github.com/bernd/fpm­cookery github.com/bernd/fpm­recipes github.com/jordansissel/fpm github.com/tmm1/brew2deb