Skip to content

Instantly share code, notes, and snippets.

@dch
Created April 1, 2017 18:15
Show Gist options
  • Save dch/dfb77183d27c3cd1967b63159abbd57a to your computer and use it in GitHub Desktop.
Save dch/dfb77183d27c3cd1967b63159abbd57a to your computer and use it in GitHub Desktop.

host

iocell clone template tag=iwmnbase \
  host_domainname=example.com \
  host_hostname=iwmnbase \
  ip4_addr='lo1|10.241.0.4' \
  resolver='search example.com;nameserver 10.241.0.0' \
  allow_raw_sockets=1 \
  enforce_statfs=1

iocell start iwmnbase

iocell console iwmnbase

jail

pkg info

ca_root_nss-3.26               Root certificate bundle from the Mozilla Project
curl-7.53.1                    Non-interactive tool to get files from FTP, GOPHER, HTTP(S) servers
gettext-runtime-0.19.8.1_1     GNU gettext runtime libraries and programs
indexinfo-0.2.6                Utility to regenerate the GNU info page index
krb5-1.14.4_1                  MIT implementation of RFC 4120 network authentication service
libffi-3.2.1                   Foreign Function Interface
libnghttp2-1.19.0              HTTP/2.0 C Library
libressl-2.4.5                 Free version of the SSL/TLS protocol forked from OpenSSL
pkg-1.10.0_1                   Package manager
pkgconf-1.2.2_1                Utility to help to configure compiler and linker flags
python2-2_3                    The "meta-port" for version 2 of the Python interpreter
python27-2.7.13_1              Interpreted object-oriented programming language
readline-6.3.8                 Library for editing command lines as they are typed

pkg install -y \
          lang/python2 \
          security/sudo \
          devel/gmake \
          devel/git \
          devel/p5-App-cpanminus \
          www/p5-LWP-Protocol-https \
          dns/p5-Net-LibIDN \
          textproc/p5-XML-SAX-Expat

host

iocell snap iwmnbase@base-packages

jail

mkdir -p /usr/local/d8o /var/cache/cpan
cd /usr/local/d8o
git clone https://user:[email protected]/example/repo
# iocell snap iwmnbase@git-repos
cpanm --notest --save-dists /var/cache/cpan \
    https://user:[email protected]/example/repo/archive/latest.tar.gz
# iocell snap iwmnbase@cpanm-example-repo
cpanm --notest --save-dists /var/cache/cpan --installdeps \
    /usr/local/d8o/example/repo
# iocell snap iwmnbase@cpanm-iwmnbase

bundle cpan

panpipe

./panpipes
#!/usr/bin/env perl
use strict;
use warnings;
use Modern::Perl;
use ExtUtils::Installed;
use File::Temp qw(tempfile tempdir);
our ($modules) = ExtUtils::Installed->new();
sub get_unique_modules() {
my (@list, %seen);
return ( sort(grep { ! $seen{$_} ++ }
grep(!/^Perl$/, $modules->modules())));
}
sub build_manifest() {
my ($name, $version, @packlist, $manifest, $url, $size, @files, @links, @dirs);
# extract variables for interpolation into our manifest
$name = shift;
$version = $modules->version($name) || "0.0.0";
@packlist = $modules->files($name, "all", "/usr/local/lib/perl5/site_perl");
$url = "https://example.com/darkpan/$name-$version.txz";
# sum of all files that will be packed into the archive
$size = 0;
foreach my $file (@files) { $size += (-s $file) if (-f $file)};
# prepare files and dirs for injecting into the manifest
# sha256 will be provided via pkg-create(8) for us
# no warnings 'qw';
@files =map { qq("$_": { uname: root, gname: www, perm: 0440 }\n) }
(grep { (-f $_ ) } @packlist);
@links = map { qq("$_": -\n) }
(grep { (-l $_ ) } @packlist);
@dirs = map { qq("$_": { uname: root, gname: www, perm: 0750 }\n) }
(grep { (-d $_ ) } @packlist);
# prepare our manifest template
($manifest = << " TEMPLATE") =~ s/^\t//gm;
name: "$name"
version: "$version"
origin: "example/p5-$name"
arch: "freebsd:11:x86:64"
www: "$url"
maintainer: "sysadmins\@example.com"
prefix: "/usr/local"
licenselogic: "single"
licenses: ["ART10"]
deps: {perl5: {origin: "lang/perl5.24", version: "5.24.1"}}
categories: ["devel", "perl5", "cpan"]
comment: "A picture is worth a thousand words."
desc: "“Always be a poet, even in prose.”
― Charles Baudelaire
WWW: $url"
files: {
@files
@links
}
directories: {
@dirs
}
TEMPLATE
return($manifest);
}
sub package_module() {
my ($name) = shift;
say $name;
}
foreach my $name (get_unique_modules()) {
&package_module($name);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment