-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunKitInstaller.m
More file actions
93 lines (75 loc) · 3.99 KB
/
FunKitInstaller.m
File metadata and controls
93 lines (75 loc) · 3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
(* ::Package:: *)
(************************************************************************)
(* This file was generated automatically by the Mathematica front end. *)
(* It contains Initialization cells from a Notebook file, which *)
(* typically will have the same name as this file except ending in *)
(* ".nb" instead of ".m". *)
(* *)
(* This file is intended to be loaded into the Mathematica kernel using *)
(* the package loading commands Get or Needs. Doing so is equivalent *)
(* to using the Evaluate Initialization Cells menu command in the front *)
(* end. *)
(* *)
(* DO NOT EDIT THIS FILE. This entire file is regenerated *)
(* automatically each time the parent Notebook file is saved in the *)
(* Mathematica front end. Any changes you make to this file will be *)
(* overwritten. *)
(************************************************************************)
(* ::Input::Initialization:: *)
FunKitInstaller::allowinternetuse="You have forbidden Mathematica to access the internet. Either allow Mathematica to access the internet or download FunKit from github manually.";
If[Not["AllowInternetUse" /. SystemInformation["Network"]],
Message[FunKitInstaller::allowinternetuse];
Abort[];
];
(* just for backwards compatibility *)
If[ToString[Context[URLDownload]]=!="System`",
URLDownload=URLSave
];
(* ::Input::Initialization:: *)
FunKitZipLocation="https://github.com/satfra/FunKit/archive/refs/heads/main.zip";
FunKitInstallDir=FileNameJoin[{$UserBaseDirectory,"Applications"}];
(* ::Input::Initialization:: *)
FunKitInstaller::zipdownloadfailed="Download from "<>FunKitZipLocation<>" failed.";
FunKitInstaller::installationfailed="\nInstallation failed. Please read the error messages for more information!";
Print["Downloading FunKit ..."];
FunKitArchive=FileNameJoin[{$TemporaryDirectory,"FunKit.zip"}];
URLDownload[FunKitZipLocation,FunKitArchive]
tmpFunKitImport=Import[FunKitArchive];
If[tmpFunKitImport==="{\"error\":\"Not Found\"}"||tmpFunKitImport==="404: Not Found",
Message[FunKitInstaller::zipdownloadfailed];Abort[];
];
newVersionString=(List@@Import[FunKitArchive,FileNameJoin[{"FunKit-main","PacletInfo.m"}]])[[1]]["Version"];
FunKitFiles=FileNameJoin[{FunKitInstallDir,#}]&/@Import[FunKitArchive];
FunKitFilesExist=FileExistsQ/@FunKitFiles;
FunKitExistingInstallation=Or@@FunKitFilesExist;
FunKitExistingPacletInfo=FileNameJoin[{FunKitInstallDir,"FunKit","PacletInfo.m"}];
FunKitExistingVersionString=If[FileExistsQ[FunKitExistingPacletInfo],(List@@Import[FunKitArchive,FileNameJoin[{"FunKit-main","PacletInfo.m"}]])[[1]]["Version"],"unknown"];
(* ::Input::Initialization:: *)
deleteExisting=False;
deleteExisting=If[FunKitExistingInstallation,
ChoiceDialog["The installer has found an existing FunKit installation.
Do you want to overwrite the existing installation version "<>FunKitExistingVersionString<>" with version "<>newVersionString<>"?
Otherwise the installation will be aborted.",
WindowTitle->"FunKit Installation",WindowSize->{Medium,All}],False];
If[deleteExisting,DeleteFile[Pick[FunKitFiles,FunKitFilesExist]]];
If[FunKitExistingInstallation&&deleteExisting===False,
(*abort installation*)
Print["FunKit installation aborted."];,
(*install FunKit*)
installationSuccess=Check[
ExtractArchive[FunKitArchive,FunKitInstallDir];
If[DirectoryQ[FunKitInstallDir~~"/FunKit"],
DeleteDirectory[FunKitInstallDir~~"/FunKit",DeleteContents->True];
];
RenameDirectory[FunKitInstallDir~~"/FunKit-main",FunKitInstallDir~~"/FunKit"];
Get["FunKit`"];
,$Failed];
If[installationSuccess===$Failed,
(*installation failed*)
Message[FunKitInstaller::installationfailed];,
(*installation successful*)
PacletDataRebuild[];
Print["Installation was successful."];
];
];
Quiet[DeleteFile[FunKitArchive]];