SlideShare a Scribd company logo
How to use
App::FatPacker effectively
Shoichi Kaji
About Me
• Shoichi Kaji
• CPAN SKAJI
• perl5 cpm, App::FatPacker::Simple,
Mojo::SlackRTM
• perl6 mi6, Frinfon
Contents
• What is App::FatPacker?
• Who uses App::FatPacker?
• How to use App::FatPacker
• Problems and solutions for App::FatPacker
• Conclusion
• See also
What is
App::FatPacker?
• Let’s say you want to download perl tarball.
• This script runs perfectly in your local OS X.
# download.pl
use strict;
use warnings;
use HTTP::Tiny;
my $http = HTTP::Tiny->new;
my $url = "http://www.cpan.org/src/5.0/perl-5.22.1.tar.gz";
my $res = $http->mirror($url => "perl-5.22.1.tar.gz");
if ($res->{success}) {
warn "Complete!n";
} else {
die "Failed $res->{status}";
}
• But, if you run it in a remote CentOS6 host,
you’ll get
• This is because the perl in CentOS6 is so old
that it does not have HTTP::Tiny in core :/
$ /usr/bin/perl download.pl
Can’t locate HTTP/Tiny.pm in @INC (@INC contains…)
What can we do?
• Yes, we can install HTTP::Tiny in remote host
• But it is sometimes tiresome, or even
impossible.
• Okay let’s introduce App::FatPacker by mst
now!
$ cpanm HTTP::Tiny
Successfully installed HTTP-Tiny-0.056
• App::FatPacker embeds HTTP::Tiny into a BEGIN
block so that we have self-contailed download.pl
# download.fatpack.pl
BEGIN {
my %fatpacked;
$fatpacked{"HTTP/Tiny.pm"} = <<'EOF';
package HTTP::Tiny;
# ... all HTTP::Tiny code ...
1;
EOF
my $class = "FatPacked::" . (0+%fatpacked);
*{$class . "::INC"} = sub {
my ($self, $pm) = @_;
if (my $content = $self->{$pm}) {
open my $fh, "<", $content;
return $fh;
}
return;
};
unshift @INC, bless %fatpacked, $class;
}
# content of download.pl...
$ /usr/bin/perl download.fatpack.pl
Complete!
😄
Who uses App::FatPacker?
• perlbrew by gugod
• cpanm by miyagawa
• perl-build (plenv plugin) by tokuhirom
• start_server (bundled in h2o) by kazuho
How to use App::FatPacker
• perldoc fatpack says:
# 1. trace dependencies
fatpack trace myscript.pl
# 2. find .packlist files
fatpack packlists-for `cat fatpacker.trace` >packlists
# 3. collect pm files in ./fatlib directory
fatpack tree `cat packlists`
# 4. bundles all pm files in ./fatlib into BEGIN block of myscript.pl
fatpack file myscript.pl >myscript.packed.pl
Problem
• I cannot remember usage of fatpack :/
• Tracing dependencies may result in
unexpected
• Modules that I want to trace does not trace
• Modules that I do not want to trace trace
Solution
• I created App::FatPacker::Simple
• It completely leaves you to trace
dependencies
• It just creates a fatpacked script with all
modules in lib, local, fatlib, extlib directories
• It is simple, isn’t it?
# You know HTTP::Tiny is a dependency.
# So install it to ./local first
$ cpanm -nq -L ./local HTTP::Tiny
Successfully installed HTTP-Tiny-0.056
# Then just run fatpack-simple
$ fatpack-simple download.pl
-> fatpack HTTP/Tiny.pm (with perl-strip)
-> Successfully created download.fatpack.pl
Still problem…
• Although I said App::FatPacker::Simple leaves
you to trace dependencies, it’s sometimes
annoying.
• Let’s say your script depends on URI module. Then
$ cpanm -nq -L ./local URI
Successfully installed URI-1.71
$ fatpack-simple script.pl
-> Successfully created script.fatpack.pl
$ /path/to/5.8.5/perl script.fatpack.pl
Can’t locate parent.pm in @INC ...
• Solutions might be
• Use perl5.8.5 even in fatpacking process💩
• Use cpm with --target-perl option👍
$ cpm install --target-perl 5.8.5 URI
DONE install parent-0.234
DONE install URI-1.71
$ fatpack-simple script.pl
-> Successfully created script.fatpack.pl
$ /path/to/5.8.5/perl script.fatpack.pl
# WORKS!
Conclusion
• App::FatPacker can create a self-contained,
depencency-free perl script
• App::FatPacker::Simple + cpm may help that
• Happy hacking with perl5!
See also
• https://metacpan.org/pod/App::FatPacker
• https://metacpan.org/pod/App::FatPacker::Simple
• https://github.com/skaji/plenv-download (a real
example of using fatpack-simple + cpm)
• http://ks0608.hatenablog.com/entry/
2015/06/07/004313 (an explanation of require()
function, in japanese)

More Related Content

What's hot

Local development with vvv jon trujillo
Local development with vvv   jon trujilloLocal development with vvv   jon trujillo
Local development with vvv jon trujillo
Jonathan Trujillo
 
Debugging and Profiling PHP Applications
Debugging and Profiling PHP ApplicationsDebugging and Profiling PHP Applications
Debugging and Profiling PHP Applications
Logan Lindquist
 
Road to cloud hero
Road to cloud heroRoad to cloud hero
Road to cloud hero
William Chong
 
Managing Complexity with Module::Release
Managing Complexity with Module::ReleaseManaging Complexity with Module::Release
Managing Complexity with Module::Release
brian d foy
 
T3DD11 - Scaleable TYPO3 Hosting
T3DD11 - Scaleable TYPO3 HostingT3DD11 - Scaleable TYPO3 Hosting
T3DD11 - Scaleable TYPO3 Hosting
perlsec
 
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
The 5 most common reasons for a slow WordPress site and how to fix them – ext...The 5 most common reasons for a slow WordPress site and how to fix them – ext...
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
Otto Kekäläinen
 
Managing Modules Without Going Crazy (NPW 2007)
Managing Modules Without Going Crazy (NPW 2007)Managing Modules Without Going Crazy (NPW 2007)
Managing Modules Without Going Crazy (NPW 2007)
brian d foy
 
2 Installation of Drupal
2  Installation of Drupal2  Installation of Drupal
2 Installation of DrupalWingston
 
3 Configuring Drupal
3 Configuring Drupal3 Configuring Drupal
3 Configuring DrupalWingston
 
Let's use Xslate - Osdc.tw 2011
Let's use Xslate - Osdc.tw 2011Let's use Xslate - Osdc.tw 2011
Let's use Xslate - Osdc.tw 2011Goro Fuji
 
8 Web Practices for Drupal
8  Web Practices for Drupal8  Web Practices for Drupal
8 Web Practices for DrupalWingston
 
How to investigate and recover from a security breach in WordPress
How to investigate and recover from a security breach in WordPressHow to investigate and recover from a security breach in WordPress
How to investigate and recover from a security breach in WordPress
Otto Kekäläinen
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / Webgrind
Sam Keen
 
How to make your website IPv6 ready (quickly)
How to make your website IPv6 ready (quickly)How to make your website IPv6 ready (quickly)
How to make your website IPv6 ready (quickly)
Ralf Schwoebel
 
Google App Engine: For PHP Developers
Google App Engine: For PHP DevelopersGoogle App Engine: For PHP Developers
Google App Engine: For PHP Developers
Abu Ashraf Masnun
 
7 things every web developer should know about linux administration
7 things every web developer should know about linux administration7 things every web developer should know about linux administration
7 things every web developer should know about linux administration
Zareef Ahmed
 
Varnish more than a cache
Varnish more than a cacheVarnish more than a cache
Varnish more than a cache
bloeffeld
 
Bigger Stronger Faster
Bigger Stronger FasterBigger Stronger Faster
Bigger Stronger Faster
Chris Love
 
Debugging PHP With Xdebug
Debugging PHP With XdebugDebugging PHP With Xdebug
Debugging PHP With Xdebug
Mark Niebergall
 
Caching strategy and apc
Caching strategy and apcCaching strategy and apc
Caching strategy and apc
Võ Duy Tuấn
 

What's hot (20)

Local development with vvv jon trujillo
Local development with vvv   jon trujilloLocal development with vvv   jon trujillo
Local development with vvv jon trujillo
 
Debugging and Profiling PHP Applications
Debugging and Profiling PHP ApplicationsDebugging and Profiling PHP Applications
Debugging and Profiling PHP Applications
 
Road to cloud hero
Road to cloud heroRoad to cloud hero
Road to cloud hero
 
Managing Complexity with Module::Release
Managing Complexity with Module::ReleaseManaging Complexity with Module::Release
Managing Complexity with Module::Release
 
T3DD11 - Scaleable TYPO3 Hosting
T3DD11 - Scaleable TYPO3 HostingT3DD11 - Scaleable TYPO3 Hosting
T3DD11 - Scaleable TYPO3 Hosting
 
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
The 5 most common reasons for a slow WordPress site and how to fix them – ext...The 5 most common reasons for a slow WordPress site and how to fix them – ext...
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
 
Managing Modules Without Going Crazy (NPW 2007)
Managing Modules Without Going Crazy (NPW 2007)Managing Modules Without Going Crazy (NPW 2007)
Managing Modules Without Going Crazy (NPW 2007)
 
2 Installation of Drupal
2  Installation of Drupal2  Installation of Drupal
2 Installation of Drupal
 
3 Configuring Drupal
3 Configuring Drupal3 Configuring Drupal
3 Configuring Drupal
 
Let's use Xslate - Osdc.tw 2011
Let's use Xslate - Osdc.tw 2011Let's use Xslate - Osdc.tw 2011
Let's use Xslate - Osdc.tw 2011
 
8 Web Practices for Drupal
8  Web Practices for Drupal8  Web Practices for Drupal
8 Web Practices for Drupal
 
How to investigate and recover from a security breach in WordPress
How to investigate and recover from a security breach in WordPressHow to investigate and recover from a security breach in WordPress
How to investigate and recover from a security breach in WordPress
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / Webgrind
 
How to make your website IPv6 ready (quickly)
How to make your website IPv6 ready (quickly)How to make your website IPv6 ready (quickly)
How to make your website IPv6 ready (quickly)
 
Google App Engine: For PHP Developers
Google App Engine: For PHP DevelopersGoogle App Engine: For PHP Developers
Google App Engine: For PHP Developers
 
7 things every web developer should know about linux administration
7 things every web developer should know about linux administration7 things every web developer should know about linux administration
7 things every web developer should know about linux administration
 
Varnish more than a cache
Varnish more than a cacheVarnish more than a cache
Varnish more than a cache
 
Bigger Stronger Faster
Bigger Stronger FasterBigger Stronger Faster
Bigger Stronger Faster
 
Debugging PHP With Xdebug
Debugging PHP With XdebugDebugging PHP With Xdebug
Debugging PHP With Xdebug
 
Caching strategy and apc
Caching strategy and apcCaching strategy and apc
Caching strategy and apc
 

Viewers also liked

Gazelle & CPAN modules for performance. Shibuya.pm Tech Talk #17 LT
Gazelle & CPAN modules for performance. Shibuya.pm Tech Talk #17 LTGazelle & CPAN modules for performance. Shibuya.pm Tech Talk #17 LT
Gazelle & CPAN modules for performance. Shibuya.pm Tech Talk #17 LT
Masahiro Nagano
 
Mackerel & Norikra mackerel meetup #4 LT
Mackerel & Norikra mackerel meetup #4 LTMackerel & Norikra mackerel meetup #4 LT
Mackerel & Norikra mackerel meetup #4 LT
Masahiro Nagano
 
Norikraで作るPHPの例外検知システム YAPC::Asia Tokyo 2015 LT
Norikraで作るPHPの例外検知システム YAPC::Asia Tokyo 2015 LTNorikraで作るPHPの例外検知システム YAPC::Asia Tokyo 2015 LT
Norikraで作るPHPの例外検知システム YAPC::Asia Tokyo 2015 LT
Masahiro Nagano
 
Big Master Data PHP BLT #1
Big Master Data PHP BLT #1Big Master Data PHP BLT #1
Big Master Data PHP BLT #1
Masahiro Nagano
 
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Masahiro Nagano
 
メルカリのデータベース戦略 / PHPとMySQLの怖い話 MyNA会2015年8月
メルカリのデータベース戦略 / PHPとMySQLの怖い話 MyNA会2015年8月メルカリのデータベース戦略 / PHPとMySQLの怖い話 MyNA会2015年8月
メルカリのデータベース戦略 / PHPとMySQLの怖い話 MyNA会2015年8月
Masahiro Nagano
 
メルカリでのNorikraの活用、 Mackerelを添えて
メルカリでのNorikraの活用、 Mackerelを添えてメルカリでのNorikraの活用、 Mackerelを添えて
メルカリでのNorikraの活用、 Mackerelを添えて
Masahiro Nagano
 
ISUCONの勝ち方 YAPC::Asia Tokyo 2015
ISUCONの勝ち方 YAPC::Asia Tokyo 2015ISUCONの勝ち方 YAPC::Asia Tokyo 2015
ISUCONの勝ち方 YAPC::Asia Tokyo 2015
Masahiro Nagano
 

Viewers also liked (8)

Gazelle & CPAN modules for performance. Shibuya.pm Tech Talk #17 LT
Gazelle & CPAN modules for performance. Shibuya.pm Tech Talk #17 LTGazelle & CPAN modules for performance. Shibuya.pm Tech Talk #17 LT
Gazelle & CPAN modules for performance. Shibuya.pm Tech Talk #17 LT
 
Mackerel & Norikra mackerel meetup #4 LT
Mackerel & Norikra mackerel meetup #4 LTMackerel & Norikra mackerel meetup #4 LT
Mackerel & Norikra mackerel meetup #4 LT
 
Norikraで作るPHPの例外検知システム YAPC::Asia Tokyo 2015 LT
Norikraで作るPHPの例外検知システム YAPC::Asia Tokyo 2015 LTNorikraで作るPHPの例外検知システム YAPC::Asia Tokyo 2015 LT
Norikraで作るPHPの例外検知システム YAPC::Asia Tokyo 2015 LT
 
Big Master Data PHP BLT #1
Big Master Data PHP BLT #1Big Master Data PHP BLT #1
Big Master Data PHP BLT #1
 
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015
 
メルカリのデータベース戦略 / PHPとMySQLの怖い話 MyNA会2015年8月
メルカリのデータベース戦略 / PHPとMySQLの怖い話 MyNA会2015年8月メルカリのデータベース戦略 / PHPとMySQLの怖い話 MyNA会2015年8月
メルカリのデータベース戦略 / PHPとMySQLの怖い話 MyNA会2015年8月
 
メルカリでのNorikraの活用、 Mackerelを添えて
メルカリでのNorikraの活用、 Mackerelを添えてメルカリでのNorikraの活用、 Mackerelを添えて
メルカリでのNorikraの活用、 Mackerelを添えて
 
ISUCONの勝ち方 YAPC::Asia Tokyo 2015
ISUCONの勝ち方 YAPC::Asia Tokyo 2015ISUCONの勝ち方 YAPC::Asia Tokyo 2015
ISUCONの勝ち方 YAPC::Asia Tokyo 2015
 

Similar to How to use App::FatPacker effectively

Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet
 
Puppet Camp LA 2/19/2015
Puppet Camp LA 2/19/2015Puppet Camp LA 2/19/2015
Puppet Camp LA 2/19/2015
ice799
 
Package manages and Puppet - PuppetConf 2015
Package manages and Puppet - PuppetConf 2015Package manages and Puppet - PuppetConf 2015
Package manages and Puppet - PuppetConf 2015
ice799
 
Ruby v cpp_preso
Ruby v cpp_presoRuby v cpp_preso
Ruby v cpp_presojessicard
 
Linux System Administration
Linux System AdministrationLinux System Administration
Linux System Administration
Jayant Dalvi
 
TYPO3 8 is here - how we keep EXT:solr uptodate with the TYPO3 core
TYPO3 8 is here - how we keep EXT:solr uptodate with the TYPO3 coreTYPO3 8 is here - how we keep EXT:solr uptodate with the TYPO3 core
TYPO3 8 is here - how we keep EXT:solr uptodate with the TYPO3 core
timohund
 
Package Management and Chef - ChefConf 2015
Package Management and Chef - ChefConf 2015Package Management and Chef - ChefConf 2015
Package Management and Chef - ChefConf 2015
Chef
 
Chef Conf 2015: Package Management & Chef
Chef Conf 2015: Package Management & ChefChef Conf 2015: Package Management & Chef
Chef Conf 2015: Package Management & Chef
ice799
 
Getting root with benign app store apps
Getting root with benign app store appsGetting root with benign app store apps
Getting root with benign app store apps
Csaba Fitzl
 
perlbrew yapcasia 2010
perlbrew yapcasia 2010perlbrew yapcasia 2010
perlbrew yapcasia 2010
Kang-min Liu
 
In the desert, without a camel
In the desert, without a camelIn the desert, without a camel
In the desert, without a camel
Stephen Scaffidi
 
21st Century CPAN Testing: CPANci
21st Century CPAN Testing: CPANci21st Century CPAN Testing: CPANci
21st Century CPAN Testing: CPANci
Mike Friedman
 
Packaging perl (LPW2010)
Packaging perl (LPW2010)Packaging perl (LPW2010)
Packaging perl (LPW2010)
p3castro
 
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Codemotion
 
Php through the eyes of a hoster confoo
Php through the eyes of a hoster confooPhp through the eyes of a hoster confoo
Php through the eyes of a hoster confoo
Combell NV
 
[Hackersuli][HUN]MacOS - Going Down the Rabbit Hole
[Hackersuli][HUN]MacOS - Going Down the Rabbit Hole[Hackersuli][HUN]MacOS - Going Down the Rabbit Hole
[Hackersuli][HUN]MacOS - Going Down the Rabbit Hole
hackersuli
 
Getting root with benign app store apps vsecurityfest
Getting root with benign app store apps vsecurityfestGetting root with benign app store apps vsecurityfest
Getting root with benign app store apps vsecurityfest
Csaba Fitzl
 
Learning to code
Learning to codeLearning to code
Learning to code
Sara-Jayne Terp
 
Tp install anything
Tp install anythingTp install anything
Tp install anything
Alessandro Franceschi
 
Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Combell NV
 

Similar to How to use App::FatPacker effectively (20)

Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
 
Puppet Camp LA 2/19/2015
Puppet Camp LA 2/19/2015Puppet Camp LA 2/19/2015
Puppet Camp LA 2/19/2015
 
Package manages and Puppet - PuppetConf 2015
Package manages and Puppet - PuppetConf 2015Package manages and Puppet - PuppetConf 2015
Package manages and Puppet - PuppetConf 2015
 
Ruby v cpp_preso
Ruby v cpp_presoRuby v cpp_preso
Ruby v cpp_preso
 
Linux System Administration
Linux System AdministrationLinux System Administration
Linux System Administration
 
TYPO3 8 is here - how we keep EXT:solr uptodate with the TYPO3 core
TYPO3 8 is here - how we keep EXT:solr uptodate with the TYPO3 coreTYPO3 8 is here - how we keep EXT:solr uptodate with the TYPO3 core
TYPO3 8 is here - how we keep EXT:solr uptodate with the TYPO3 core
 
Package Management and Chef - ChefConf 2015
Package Management and Chef - ChefConf 2015Package Management and Chef - ChefConf 2015
Package Management and Chef - ChefConf 2015
 
Chef Conf 2015: Package Management & Chef
Chef Conf 2015: Package Management & ChefChef Conf 2015: Package Management & Chef
Chef Conf 2015: Package Management & Chef
 
Getting root with benign app store apps
Getting root with benign app store appsGetting root with benign app store apps
Getting root with benign app store apps
 
perlbrew yapcasia 2010
perlbrew yapcasia 2010perlbrew yapcasia 2010
perlbrew yapcasia 2010
 
In the desert, without a camel
In the desert, without a camelIn the desert, without a camel
In the desert, without a camel
 
21st Century CPAN Testing: CPANci
21st Century CPAN Testing: CPANci21st Century CPAN Testing: CPANci
21st Century CPAN Testing: CPANci
 
Packaging perl (LPW2010)
Packaging perl (LPW2010)Packaging perl (LPW2010)
Packaging perl (LPW2010)
 
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
 
Php through the eyes of a hoster confoo
Php through the eyes of a hoster confooPhp through the eyes of a hoster confoo
Php through the eyes of a hoster confoo
 
[Hackersuli][HUN]MacOS - Going Down the Rabbit Hole
[Hackersuli][HUN]MacOS - Going Down the Rabbit Hole[Hackersuli][HUN]MacOS - Going Down the Rabbit Hole
[Hackersuli][HUN]MacOS - Going Down the Rabbit Hole
 
Getting root with benign app store apps vsecurityfest
Getting root with benign app store apps vsecurityfestGetting root with benign app store apps vsecurityfest
Getting root with benign app store apps vsecurityfest
 
Learning to code
Learning to codeLearning to code
Learning to code
 
Tp install anything
Tp install anythingTp install anything
Tp install anything
 
Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11
 

Recently uploaded

weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
Kamal Acharya
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
PrashantGoswami42
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
Kamal Acharya
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
ShahidSultan24
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 

Recently uploaded (20)

weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 

How to use App::FatPacker effectively

  • 1. How to use App::FatPacker effectively Shoichi Kaji
  • 2. About Me • Shoichi Kaji • CPAN SKAJI • perl5 cpm, App::FatPacker::Simple, Mojo::SlackRTM • perl6 mi6, Frinfon
  • 3. Contents • What is App::FatPacker? • Who uses App::FatPacker? • How to use App::FatPacker • Problems and solutions for App::FatPacker • Conclusion • See also
  • 5. • Let’s say you want to download perl tarball. • This script runs perfectly in your local OS X. # download.pl use strict; use warnings; use HTTP::Tiny; my $http = HTTP::Tiny->new; my $url = "http://www.cpan.org/src/5.0/perl-5.22.1.tar.gz"; my $res = $http->mirror($url => "perl-5.22.1.tar.gz"); if ($res->{success}) { warn "Complete!n"; } else { die "Failed $res->{status}"; }
  • 6. • But, if you run it in a remote CentOS6 host, you’ll get • This is because the perl in CentOS6 is so old that it does not have HTTP::Tiny in core :/ $ /usr/bin/perl download.pl Can’t locate HTTP/Tiny.pm in @INC (@INC contains…)
  • 7. What can we do? • Yes, we can install HTTP::Tiny in remote host • But it is sometimes tiresome, or even impossible. • Okay let’s introduce App::FatPacker by mst now! $ cpanm HTTP::Tiny Successfully installed HTTP-Tiny-0.056
  • 8. • App::FatPacker embeds HTTP::Tiny into a BEGIN block so that we have self-contailed download.pl # download.fatpack.pl BEGIN { my %fatpacked; $fatpacked{"HTTP/Tiny.pm"} = <<'EOF'; package HTTP::Tiny; # ... all HTTP::Tiny code ... 1; EOF my $class = "FatPacked::" . (0+%fatpacked); *{$class . "::INC"} = sub { my ($self, $pm) = @_; if (my $content = $self->{$pm}) { open my $fh, "<", $content; return $fh; } return; }; unshift @INC, bless %fatpacked, $class; } # content of download.pl...
  • 10. 😄
  • 11. Who uses App::FatPacker? • perlbrew by gugod • cpanm by miyagawa • perl-build (plenv plugin) by tokuhirom • start_server (bundled in h2o) by kazuho
  • 12. How to use App::FatPacker • perldoc fatpack says: # 1. trace dependencies fatpack trace myscript.pl # 2. find .packlist files fatpack packlists-for `cat fatpacker.trace` >packlists # 3. collect pm files in ./fatlib directory fatpack tree `cat packlists` # 4. bundles all pm files in ./fatlib into BEGIN block of myscript.pl fatpack file myscript.pl >myscript.packed.pl
  • 13. Problem • I cannot remember usage of fatpack :/ • Tracing dependencies may result in unexpected • Modules that I want to trace does not trace • Modules that I do not want to trace trace
  • 14. Solution • I created App::FatPacker::Simple • It completely leaves you to trace dependencies • It just creates a fatpacked script with all modules in lib, local, fatlib, extlib directories
  • 15. • It is simple, isn’t it? # You know HTTP::Tiny is a dependency. # So install it to ./local first $ cpanm -nq -L ./local HTTP::Tiny Successfully installed HTTP-Tiny-0.056 # Then just run fatpack-simple $ fatpack-simple download.pl -> fatpack HTTP/Tiny.pm (with perl-strip) -> Successfully created download.fatpack.pl
  • 16. Still problem… • Although I said App::FatPacker::Simple leaves you to trace dependencies, it’s sometimes annoying. • Let’s say your script depends on URI module. Then $ cpanm -nq -L ./local URI Successfully installed URI-1.71 $ fatpack-simple script.pl -> Successfully created script.fatpack.pl $ /path/to/5.8.5/perl script.fatpack.pl Can’t locate parent.pm in @INC ...
  • 17. • Solutions might be • Use perl5.8.5 even in fatpacking process💩 • Use cpm with --target-perl option👍 $ cpm install --target-perl 5.8.5 URI DONE install parent-0.234 DONE install URI-1.71 $ fatpack-simple script.pl -> Successfully created script.fatpack.pl $ /path/to/5.8.5/perl script.fatpack.pl # WORKS!
  • 18. Conclusion • App::FatPacker can create a self-contained, depencency-free perl script • App::FatPacker::Simple + cpm may help that • Happy hacking with perl5!
  • 19. See also • https://metacpan.org/pod/App::FatPacker • https://metacpan.org/pod/App::FatPacker::Simple • https://github.com/skaji/plenv-download (a real example of using fatpack-simple + cpm) • http://ks0608.hatenablog.com/entry/ 2015/06/07/004313 (an explanation of require() function, in japanese)