{"id":345,"date":"2012-04-20T13:53:05","date_gmt":"2012-04-20T19:53:05","guid":{"rendered":"http:\/\/www.goodjobsucking.com\/?p=345"},"modified":"2012-04-20T13:53:05","modified_gmt":"2012-04-20T19:53:05","slug":"freebsd-bsdpan-to-p5-migration-for-perl-modules","status":"publish","type":"post","link":"http:\/\/www.goodjobsucking.com\/?p=345","title":{"rendered":"FreeBSD bsdpan- to p5- migration for perl modules"},"content":{"rendered":"<p>FreeBSD has a package system to manage installations and dependencies, and so does perl.\u00a0 Perl on FreeBSD, therefore, causes these to intersect in interesting, and sometimes suboptimal ways.<\/p>\n<p>CPAN can be used to install perl packages that aren&#8217;t in the ports tree, and FreeBSD handles this with relative grace by including them in its package database with the prefix &#8220;bsdpan,&#8221; and be excluded from updates.\u00a0 An identical package installed from the ports tree will be prefixed with &#8220;p5&#8221; instead, and be treated as any other port, with dependencies and upgrades handled as part of the ports system.<\/p>\n<p>After trying out a few CPAN modules (which in turn installed their own dependencies) I found myself with a great many &#8220;bsdpan&#8221; packages, which I&#8217;d prefer to tuck neatly into the bsd ports tree rather than continue to manage with CPAN, therefore, I whanged together a shell script to do it:<\/p>\n<pre>#!\/bin\/sh\r\npkg_info | grep ^bsdpan | awk '{print $1}' &gt; \/tmp\/bsdpan-to-p5.tmp\r\n&gt; \/tmp\/bsdpan-to-p5-2.tmp\r\ncd \/usr\/ports\r\nwhile read bsdname; do\r\n\u00a0 name=$(echo $bsdname | cut -c 8- )\r\n\u00a0 portpath=$(make search name=p5-$name | grep ^Path | awk '{print $2}' | sed -r 's\/\\\/usr\\\/ports\\\/\/\/')\r\n\u00a0 shortname=$(echo $name | sed -r 's\/(.*)-.*\/\\1\/');\r\n\u00a0 if [ \"$portpath\" ]; then\r\n\u00a0\u00a0\u00a0\u00a0 echo -n p5-$name is in ports,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 echo \" adding to list\"\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 echo portupgrade -o $portpath -f bsdpan-$shortname &gt;&gt; \/tmp\/bsdpan-to-p5-2.tmp\r\n\u00a0 else\r\n\u00a0\u00a0\u00a0\u00a0 echo p5-$name not in ports\r\n\u00a0\u00a0\u00a0\u00a0 portpath=$(make search name=p5-$shortname- | grep ^Path | awk '{print $2}' | sed -r 's\/\\\/usr\\\/ports\\\/\/\/')\r\n\u00a0\u00a0\u00a0\u00a0 if [ \"$portpath\" ]; then\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 paths=$(echo $portpath | wc -w)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if [ \"$paths\" -eq \"1\" ]; then\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 p5name=$(make search name=p5-$shortname- | grep Port | awk '{print $2}')\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 echo \" ... $p5name found, using that\"\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 echo portupgrade -o $portpath -f bsdpan-$shortname &gt;&gt; \/tmp\/bsdpan-to-p5-2.tmp\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fi\r\n\u00a0\u00a0\u00a0\u00a0 fi\r\n\u00a0 fi\r\ndone &lt; \/tmp\/bsdpan-to-p5.tmp\r\nrm \/tmp\/bsdpan-to-p5.tmp\r\necho\r\necho \"Starting conversion ...\"\r\necho\r\nsh \/tmp\/bsdpan-to-p5-2.tmp\r\nrm \/tmp\/bsdpan-to-p5-2.tmp<\/pre>\n<p>The script tries to automate a manual process of finding the corresponding &#8220;p5&#8221; port for each &#8220;bsdpan&#8221; port, and builds a script that replaces each one using the portupgrade tool.<\/p>\n<p>It doesn&#8217;t make any attempt to resolve dependencies, so it may take a few passes.\u00a0 It also can&#8217;t help where a search for the port name returns more than one possibility (usually part of a longer name) or when the &#8220;p5&#8221; name happens to be nothing like the &#8220;bsdpan&#8221; name, but in practice, there are only a handful of exceptions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>FreeBSD has a package system to manage installations and dependencies, and so does perl.\u00a0 Perl on FreeBSD, therefore, causes these to intersect in interesting, and sometimes suboptimal ways. CPAN can be used to install perl packages that aren&#8217;t in the ports tree, and FreeBSD handles this with relative grace by \u2026 <a class=\"continue-reading-link\" href=\"http:\/\/www.goodjobsucking.com\/?p=345\"> Continue reading <span class=\"meta-nav\">&rarr; <\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"_links":{"self":[{"href":"http:\/\/www.goodjobsucking.com\/index.php?rest_route=\/wp\/v2\/posts\/345"}],"collection":[{"href":"http:\/\/www.goodjobsucking.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.goodjobsucking.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.goodjobsucking.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.goodjobsucking.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=345"}],"version-history":[{"count":5,"href":"http:\/\/www.goodjobsucking.com\/index.php?rest_route=\/wp\/v2\/posts\/345\/revisions"}],"predecessor-version":[{"id":350,"href":"http:\/\/www.goodjobsucking.com\/index.php?rest_route=\/wp\/v2\/posts\/345\/revisions\/350"}],"wp:attachment":[{"href":"http:\/\/www.goodjobsucking.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.goodjobsucking.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=345"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.goodjobsucking.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}