{"id":5151,"date":"2018-06-01T14:09:19","date_gmt":"2018-06-01T06:09:19","guid":{"rendered":"https:\/\/lttt.vanabel.cn\/?p=5151"},"modified":"2018-06-04T15:20:38","modified_gmt":"2018-06-04T07:20:38","slug":"shiyongbundledocdabaolatexhongbaoyilai","status":"publish","type":"post","link":"https:\/\/lttt.vanabel.cn\/?p=5151","title":{"rendered":"\u4f7f\u7528bundledoc\u6253\u5305LaTeX\u5b8f\u5305\u4f9d\u8d56"},"content":{"rendered":"<p>\u6211\u9047\u5230\u8fc7\u7531\u4e8e\u5b8f\u5305\u4e0d\u591f\u65b0\u5bfc\u81f4\u7684latex\u7f16\u8bd1\u5931\u8d25\u3002\u90a3\u4e48\u6709\u6ca1\u6709\u529e\u6cd5\u5c06\u6211\u4eec\u7f16\u8bd1\u5f53\u524d\u6587\u6863\u9700\u8981\u7684\u5b8f\u5305\u6253\u5305\u5462\uff1f<\/p>\n<p>\u529e\u6cd5\u5c31\u662f\u4f7f\u7528<code>bundledoc<\/code>. \u6211\u7528\u7684texlive2017(\u811a\u672c\u4f4d\u7f6e\uff1a<code>E:\\texlive\\2016\\texmf-dist\\scripts\\bundledoc\\bundledoc<\/code>), \u770b\u8d77\u6765\u8fd9\u4e2a\u5b8f\u5305\u6709\u70b9\u65e7\u4e86, \u9700\u8981\u4fee\u590d\u4e0b\u3002<\/p>\n<h4>\u811a\u672c\u7684\u4fee\u590d<\/h4>\n<p><strong>P.S. \u6700\u65b0\u7248\u7684bundledoc(2018\/05\/23, Version 3.3)\u4e00\u4e0b\u4e24\u4e2a\u95ee\u9898\u90fd\u5df2\u7ecf\u4fee\u590d\u3002\u8bf7\u76f4\u63a5\u66f4\u65b0\u3002<\/strong><\/p>\n<p>\u9996\u5148\u5b83\u662f\u4e00\u4e2aperl\u811a\u672c, \u5176\u4e2d\u6709\u4e2a\u65b0\u5efa\u4e34\u65f6\u76ee\u5f55\u7684\u51fd\u6570<code>tmpnam<\/code>\u5df2\u7ecf\u5f03\u7528\u4e86, \u8fd9\u4e2a\u597d\u50cf\u4e0d\u662f\u975e\u5e38\u5f71\u54cd\u3002<br \/>\n <!--more--><\/p>\n<pre class=\"lang:perl marking:true mark:13 start-line:296 \" ># Create a bundled file.\nmy @dependencies = find_dependencies();\nif ($keepdirs) {\n    # Put absolute pathnames in the tar file.\n    # QUESTIONS: Does this work with multiple drive letters in Windows?\n    #            What about UNC names?\n    chdir rootdir() || die \"${progname}: $! (\".rootdir().\")\\n\";\n    $ENV{\"BDINPUTS\"} = join (\" \", map {s|^\/+||; s\/\\\"\/\/g; \"\\\"$_\\\"\"} @dependencies);\n    executecmd $uservariable{\"bundle\"};\n}\nelse {\n    # Copy each of the dependencies to a temporary directory and tar it up.\n    my $tempdir = tmpnam();\n    my $tempdir2 = catfile $tempdir, $docdirname;\n    print \"CREATING $tempdir\\n\" if $verbose;\n    mkdir ($tempdir, 0777)  || die \"${progname}: $! ($tempdir)\\n\";\n    print \"CREATING $tempdir2\\n\" if $verbose;\n    mkdir ($tempdir2, 0777) || die \"${progname}: $! ($tempdir2)\\n\";\n    foreach my $dep (@dependencies) {\n        # If the current dependency is in a subdirectory of the\n        # original location, create the same subdirectory in the\n        # temporary directory and copy the file there.  Otherwise just\n        # copy it to the root of the temporary directory.\n        my $targetdir = $tempdir2;\n        if (my $sd = $subdirs{$dep}) {\n            $targetdir = catfile($targetdir, $sd);\n            unless (-d $targetdir) {\n                print \"CREATING $targetdir\\n\" if $verbose;\n                mkpath($targetdir, 0, 0777) || die \"${progname}: $! ($targetdir)\\n\";\n            }\n        }\n        copy ($dep, $targetdir) || die \"${progname}: $! ($targetdir)\\n\";\n    }\n    if ($manifest ne \"\") {\n        my $manifest = catfile $tempdir2, $manifest;\n        my $manifestdir = dirname $manifest;\n        unless (-d $manifestdir) {\n            print \"CREATING $manifestdir\\n\" if $verbose;\n            mkpath($manifestdir, 0, 0777) || die \"${progname}: $! ($manifestdir)\\n\";\n        }\n        print \"WRITING $manifest\\n\" if $verbose;\n        open (MANIFEST, \"&gt;$manifest\") || die \"${progname}: $! ($manifest)\\n\";\n        print MANIFEST join (\"\\n\", @dependencies), \"\\n\";\n        close MANIFEST;\n    }\n    chdir $tempdir || die \"${progname}: $! ($tempdir)\\n\";\n    $ENV{\"BDINPUTS\"} = \"\\\"$docdirname\\\"\";\n    executecmd $uservariable{\"bundle\"};\n\n    # Clean up our mess.\n    # NOTE: We rmtree $tempdir2 and rmdir $tempdir because rmtree\n    #       complained on WinNT when trying to remove a top-level\n    #       directory (e.g., \"\\s4r.\").\n    print \"REMOVING $tempdir2\\n\" if $verbose;\n    rmtree $tempdir2, 0, 1;\n    chdir (updir());\n    print \"REMOVING $tempdir\\n\" if $verbose;\n    rmdir $tempdir || die \"${progname}: $! ($tempdir)\\n\";\n}\nprint \"FINISHED.\\n\" if $verbose;\nexit 0;<\/pre>\n<p>\u5176\u6b21, \u5b83\u7684\u6b63\u5219\u8868\u8fbe\u5f0f<code>{([^\\}]*)}<\/code>\u4e0d\u6b63\u786e, \u56e0\u4e3a\u6839\u636e<code>*.dep<\/code>\u7684\u7ed3\u6784, \u6211\u4eec\u9700\u8981\u5c06\u5176\u6539\u6210<code>\\\\{([^}]*)\\\\}<\/code>.<\/p>\n<pre class=\"lang:perl mark:5 start-line:132 decode:true \" ># Find all dependencies listed in the input file.\nsub find_dependencies ()\n{\n    open (DEPFILE, \"&lt;$depfile\") || die \"${progname}: $! ($depfile)\\n\";\n    my $braced = \"{([^\\}]*)}\";   # Regular expression for a braced name\n    my @dependencies;            # List of fully-qualified filenames\n    @dependencies = qualifyname $texfile;\n    while (my $oneline=&lt;DEPFILE&gt;) {\n        # Parse an input line into its component fields.\n        next if !($oneline =~ \/^\\s*\\*$braced\\s*$braced\\s*$braced\\s*$\/);\n        my $filetype = $1;\n        my $filename = $2;\n        my $versioninfo = $3;\n\n        # Extract the subdirectory if one exists.\n        my $subdir = dirname $filename;\n        my $qname = \"\";<\/pre>\n<p>\u5982\u679c\u6211\u4eec\u53ea\u9700\u8981\u5c062017\u5e74\u4ee5\u540e\u7684\u5b8f\u5305\u6253\u5305, \u5219\u53ef\u4ee5\u5c06\u4e0a\u8ff0\u4ee3\u7801\u7247\u6bb5\u6539\u4e3a<\/p>\n<pre class=\"lang:perl start-line:132  mark:5,10 decode:true \" ># Find all dependencies listed in the input file.\nsub find_dependencies ()\n{\n    open (DEPFILE, \"&lt;$depfile\") || die \"${progname}: $! ($depfile)\\n\";\n    my $braced = \"\\\\{([^}]*)\\\\}\";   # Regular expression for a braced name\n    my @dependencies;            # List of fully-qualified filenames\n    @dependencies = qualifyname $texfile;\n    while (my $oneline=&lt;DEPFILE&gt;) {\n        # Parse an input line into its component fields.\n        next if !($oneline =~ \/^\\s*\\*$braced\\s*$braced\\s*\\{((2017|2018)[^}]*)\\}\\s*$\/);\n        my $filetype = $1;\n        my $filename = $2;\n        my $versioninfo = $3;\n\n        # Extract the subdirectory if one exists.\n        my $subdir = dirname $filename;\n        my $qname = \"\";<\/pre>\n<h4>\u811a\u672c\u7684\u4f7f\u7528<\/h4>\n<p>\u65b0\u5efa<code>test.tex<\/code>\u6587\u6863\u5982\u4e0b\uff1a<\/p>\n<pre class=\"lang:tex mark:1 decode:true \" >\\RequirePackage{snapshot}\n\\documentclass{amsart}\n\\begin{document}\nHello world!\n\\end{document}<\/pre>\n<p>\u8fd9\u91cc\u7684\u5173\u952e\u662f\u9700\u8981\u7b2c\u4e00\u884c\u7684<code>\\RequirePackage{snapshot}<\/code>\u4ea7\u751f\u5b8f\u5305\u4f9d\u8d56\u5217\u8868<code>test.dep<\/code>. \u4f8b\u5982\u4e0a\u9762\u7684\u4ee3\u7801\u4ea7\u751f\u7684\u5b8f\u5305\u4f9d\u8d56\u5217\u8868\u4e3a\uff1a<\/p>\n<pre class=\"lang:default decode:true \" >\\RequireVersions{\n  *{application}{TeX}     {1990\/03\/25 v3.x}\n  *{format} {LaTeX2e}     {2017-04-15 v2.e}\n  *{package}{snapshot}    {2002\/03\/05 v1.14}\n  *{class}  {amsart}      {2017\/10\/31 v2.20.4}\n  *{package}{amsmath}     {2017\/09\/02 v2.17a}\n  *{package}{amstext}     {2000\/06\/29 v2.01}\n  *{package}{amsgen}      {1999\/11\/30 v2.0}\n  *{package}{amsbsy}      {1999\/11\/29 v1.2d}\n  *{package}{amsopn}      {2016\/03\/08 v2.02}\n  *{file}   {umsa.fd}     {2013\/01\/14 v3.01}\n  *{package}{amsfonts}    {2013\/01\/14 v3.01}\n  *{file}   {umsa.fd}     {2013\/01\/14 v3.01}\n  *{file}   {umsb.fd}     {2013\/01\/14 v3.01}\n}<\/pre>\n<p>\u63a5\u7740, \u6211\u4eec\u9700\u8981\u5728<code>test.tex<\/code>\u540c\u76ee\u5f55\u4e0b\u521b\u5efa<code>bundledoc<\/code>\u914d\u7f6e\u6587\u4ef6<code>bundledoc.cfg<\/code><\/p>\n<pre class=\"lang:default decode:true \" ># basic config file for use of arlatex + bundledoc\nbundle: (arlatex --document=$BDBASE.tex $BDINPUTS | tar -cvf - $BDINPUTS | gzip --best &gt; $BDBASE-all.tar.gz )\nsink:   &gt; \/dev\/null 2&gt;&amp;1\nfind:   kpsewhich -progname=latex $BDINPUTS<\/pre>\n<p>\u6700\u540e, \u5982\u679c\u4f60\u4f7f\u7528\u4fee\u6539\u540e\u7684\u811a\u672c\u7684\u8bdd, \u8fd0\u884c<br \/>\n<code>bundledoc --config=bundledoc.cfg --verbose test.dep<\/code><br \/>\n\u5219\u5f97\u5230\u6253\u5305\u540e\u7684\u538b\u7f29\u6587\u4ef6<code>test-all.tar.gz<\/code><br \/>\n\u9700\u8981\u6ce8\u610f\u7684\u662f, \u6211\u4eec\u9700\u8981\u538b\u7f29\u6587\u4ef6\u7684\u8f6f\u4ef6tar\u4e0egzip.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u9047\u5230\u8fc7\u7531\u4e8e\u5b8f\u5305\u4e0d\u591f\u65b0\u5bfc\u81f4\u7684latex\u7f16\u8bd1\u5931\u8d25\u3002\u90a3\u4e48\u6709\u6ca1\u6709\u529e\u6cd5\u5c06\u6211\u4eec\u7f16\u8bd1\u5f53\u524d\u6587\u6863 &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/lttt.vanabel.cn\/?p=5151\"> <span class=\"screen-reader-text\">\u4f7f\u7528bundledoc\u6253\u5305LaTeX\u5b8f\u5305\u4f9d\u8d56<\/span> \u9605\u8bfb\u66f4\u591a &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[845,847,846,585,848,644,692],"class_list":["post-5151","post","type-post","status-publish","format-standard","hentry","category-latex","tag-bundledoc","tag-depence","tag-package","tag-perl","tag-tar","tag-tex","tag-zip"],"_links":{"self":[{"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=\/wp\/v2\/posts\/5151","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5151"}],"version-history":[{"count":10,"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=\/wp\/v2\/posts\/5151\/revisions"}],"predecessor-version":[{"id":5164,"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=\/wp\/v2\/posts\/5151\/revisions\/5164"}],"wp:attachment":[{"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}