0

I've been using TeX Live 2018 and installed some packages to that, now that 2019 is out, I need to intall that new version (windows). I am using basis scheme install option (plain and latex) for normal reasons. Is it possible to like import 2018 packages, which are installed on my computer to 2019? Or idk, install them again but not manually like create a list or something?

Another sub question would be if it is possible to copy the packages to another computer, or copy the list of those packages and on other computer click on it and install them in 1 go.

A.Ston
  • 129
  • 1
    This question has been asked before, but no real solutions have been provided. See for example https://tex.stackexchange.com/questions/179925/is-there-a-way-to-transfer-the-state-of-tlmgr-from-texlive-2013-to-2014, https://tex.stackexchange.com/questions/342219/upgrading-from-texlive-2014-to-2016, https://tex.stackexchange.com/questions/377233/transfer-installed-packages-when-installing-a-new-texlive-release. One way is to create a list of installed packages (https://tex.stackexchange.com/questions/56009/how-to-print-the-list-of-packages-installed-on-tex-live-to-a-file) – Marijn Jun 07 '19 at 12:26
  • and use that list to install the same packages again in the new installation with tlmgr (with some batch processing to transform the list in a sequence of tlmgr commands). But it is rather impractical, it would be nice if TeX Live would implement a proper updating procedure instead of 'just start from scratch every time'. – Marijn Jun 07 '19 at 12:28
  • ok, Ive created a list of the installed packages, its 278 for me, most of which are probably from the standard installation, is it possible to import this list on another PC/verstion through tlmgr or even tex live manager? I have no idea on how to do batch processing or so. – A.Ston Jun 07 '19 at 13:50
  • See for example https://stackoverflow.com/questions/155932/how-do-you-loop-through-each-line-in-a-text-file-using-a-windows-batch-file. In this case you can do for /F "tokens=*" %%A in (mypackages.txt) do tlmgr install %%A in a cmd.exe terminal (untested, I don't have Windows here so I just copy-pasted it). – Marijn Jun 07 '19 at 15:52
  • 1
    I made it, I used matlab though to import both files (2018 package list and 2019 package list), used some regexp to get lists of pure package names and checked those for differences. That would be packages in old file which are not in new file. So exported those as a simple string with spaces inbetween. Then I just type tlmgr install and copy that string behind this command, it installs all packages then ^.^. Also awesome to port the packages to another computer. Thanks for help! – A.Ston Jun 07 '19 at 20:14
  • Good to hear that it worked. Note that your method may not work if you want to install hundreds of packages at the same time, because there is a limit to the length of the command line. With a batch script that is not a problem. Also, if a package failed for some reason it is easier to skip/recover/log this in a script than with a long command line. – Marijn Jun 07 '19 at 20:28
  • Hi @Marijn, i've looked through this again and tried to create a Batch file. I use your loop from above, it works, but then the window closes as soon as the loop ends, if i add a 'ECHO Done!' and 'PAUSE' afterwards, it is not executed, the window still closes. Also if I have 2 texlive distributions installed, how does it know which one to take? like 2018 or 2019? it starts through cmd and not tex live command prompt. – A.Ston Aug 22 '19 at 08:16
  • Again untested (I don't have Windows here), but apparently you can put cmd /k at the end of your batch file to keep the window open, or alternatively run the file itself with cmd /k yourbatchfile.bat (see https://stackoverflow.com/questions/17957076/keep-cmd-open-after-bat-file-executes). – Marijn Aug 22 '19 at 11:15
  • For tlmgr you can check with tlmgr --version to see which version it is. Presumably the version of TeX Live that you installed most recently is the one in the path. If it is not the one you want you can use the absolute (full) file path inside of the batch file, something like C:\texlive\2018\texmf-dist\bin\x86_64\tlmgr.exe or similar. – Marijn Aug 22 '19 at 11:17
  • no, cmd /k at the end does not work. the only way I managed the window to stay open is through cmd /k "for /F "tokens=*" %%A in (mypackages.txt) do tlmgr install %%A" but using this the following commands after this line won't execute. It has something to do with the tlmgr install package in the batch file, because even without a loop, this single command stops the batch file after the line's execution – A.Ston Aug 22 '19 at 13:33

1 Answers1

1

I solved this as follows: After installation of the new distribution (both are now installed)

  • Open old Tex Live command-line and type tlmgr list --only-installed > old.txt.
  • Open new Tex Live command-line and type tlmgr list --only-installed > new.txt.

Now copy those 2 files into a same folder, then I wrote a little script in MATLAB, it is simple and it probably can also be written in any other language, here it is:

oldfile=fopen('old.txt');
oldtext=fread(oldfile,'*char')';
fclose(oldfile);
oldpackages=regexp(oldtext,'(?<=i )[\w\.\-]+(?=:)','match')';
clear oldfile oldtext

newfile=fopen('new.txt');
newtext=fread(newfile,'*char')';
fclose(newfile);
newpackages=regexp(newtext,'(?<=i )[\w\.\-]+(?=:)','match')';
clear newfile newtext

packagestoadd=strjoin(oldpackages(~ismember(oldpackages,newpackages)));
clear newpackages oldpackages

the packagestoadd variable now contains all names of packages, which are installed on the old distribution but not on the new one.

  • Now go to the new TeX Live command-line again (you have to open it as admin if it is installed in a folder like Programm files though), type tlmgr install and copy the string from the mentioned variable right after this command.

Edit: I have wrote this script in C++ and compiled it, here is the code:

#include <set>
#include <regex>
#include <fstream>
using namespace std;

int main()
{
    regex re("^i ([\\w\\.\\-]+):");
    smatch match;
    string line;
    ifstream newFile("new.txt");
    set<string> newPackages;
    while (getline(newFile, line))
    {
        regex_search(line, match, re);
        newPackages.insert(match.str(1));
    }
    newFile.close();
    ifstream oldFile("old.txt");
    ofstream file("toadd.txt");
    while (getline(oldFile, line))
    {
        regex_search(line, match, re);
        if (newPackages.find(match.str(1)) == newPackages.end())
        {
            file << match.str(1) << endl;
        }
    }
    oldFile.close();
    file.close();
}

I have also compiled it for windows x64, you can use it without additional software. there is also a batch file, which then installs TeX Live packages automatically. I upload it here: C++ executable. To use it simply download, put in any folder on your PC, then let TeX Live command line create the 2 text files (must be named old.txt and new.txt) and put them into the same folder as the 2 downloaded files. Then simply double click on the bat file.

If you installed your TeX Live in the Programm Files folder, which needs admit permissions, you will need to run cmd or TeX Live command line as admin, navigate to the folder in which you copied the files (with cd command) and then type import texlive packages.bat.

If you just want to know the difference, you can double click on the exe file, it will only create a new text file containing the missing packages in new.txt.

A.Ston
  • 129
  • maybe some kind soul could write this script in C++ and make an exe file or something that does not require additional software, for easyer use for others. – A.Ston Jun 07 '19 at 20:35