diff options
-rw-r--r-- | README.md | 51 | ||||
-rw-r--r-- | SPEC.md | 209 | ||||
-rwxr-xr-x | build.sh | 6 | ||||
-rw-r--r-- | src/lpm.c (renamed from lpm.c) | 2 | ||||
-rw-r--r-- | src/lpm.lua (renamed from lpm.lua) | 0 |
5 files changed, 245 insertions, 23 deletions
@@ -1,26 +1,40 @@ # Lite XL Plugin Manager -My attempt at a lite-xl plugin manager. A standalone binary that provides an easy way of installing, and uninstalling plugins from lite-xl. +A standalone binary that provides an easy way of installing, and uninstalling +plugins from lite-xl, as well as different version fo lite-xl. -Can be used by a package manager plugin that works from inside the editor and calls this. +Can be used by a package manager plugin that works from inside the editor +and calls this binary. Releases forthcoming, should be available on Windows, Mac, Linux and FreeBSD. -Also contains a plugin_manager.lua plugin to integrate the binary with lite in the form of an easy-to-use GUI. +Also contains a plugin_manager.lua plugin to integrate the binary with lite in +the form of an easy-to-use GUI. + +By default, `lpm` will automatically consume the specification in the `latest` +branch of this repository. + +## Specification + +For details about the `manifest.json` files that `lpm` consumes, +[see here](SPEC.md). ## Quickstart -If you have a C compiler, and `git`, and want to compile from scratch, you can do: +If you have a C compiler, and `git`, and want to compile from scratch, +you can do: ``` -git clone git@github.com:adamharrison/lite-xl-plugin-manager.git --shallow-submodules \ - --recurse-submodules && cd lite-xl-plugin-manager && ./build.sh && ./lpm +git clone git@github.com:adamharrison/lite-xl-plugin-manager.git \ + --shallow-submodules --recurse-submodules && cd lite-xl-plugin-manager &&\ + ./build.sh && ./lpm ```` -If you want to build it quickly, and have the right modules installed, you can do: +If you want to build it quickly, and have the right modules installed, you can +do: ``` -./build.sh -lz -lssl -lgit2 -lcurl -lcrypto -llua +./build.sh -larchive -llzma -lz -lssl -lgit2 -lz -lcurl -lcrypto -llua ``` CI is enabled on this repository, so you can grab Windows and Linux builds from the @@ -30,9 +44,11 @@ You can get a feel for how to use `lpm` by typing `./lpm --help`. ## Supporting Libraries -Unlike lite, due to the precense of the beast of a library that is OpenSSL, I've made no attempt to limit the amount -of libraries being linked in here, I'm only ensuring that everything can be linked statically as much as possible. As -seen with the `lib` folder, the following external libraries are used to build `lpm`: +Unlike lite, due to the precense of the beast of a library that is OpenSSL, +I've made no attempt to limit the amount of libraries being linked in here, +I'm only ensuring that everything can be linked statically as much as possible. +As seen with the `lib` folder, the following external libraries are used to +build `lpm`: * lua (core program written in) * OpenSSL (https/SSL support) @@ -47,24 +63,20 @@ seen with the `lib` folder, the following external libraries are used to build ` To make pre-fab lite builds, you can easily use `lpm` in CI. If you had a linux build container, you could do something like: ```sh - curl https://github.com/adamharrison/lite-xl-plugin-manager/releases/download/v0.1/lpm.x86_64-linux > lpm export LITE_USERDIR=lite-xl/data && export LPM_CACHE=/tmp/cache ./lpm add https://github.com/adamharrison/lite-xl-plugin-manager && ./lpm install plugin_manager lsp - ``` ## Usage ```sh - -lpm update && lpm install aligncarets +lpm install aligncarets lpm uninstall aligncarets +``` -lpm add https://github.com/adamharrison/lite-xl-plugin-manager.git -lpm install plugin_manager -lpm rm https://github.com/adamharrison/lite-xl-plugin-manager.git - +```sh +lpm --help ``` ## Building @@ -80,3 +92,4 @@ lpm rm https://github.com/adamharrison/lite-xl-plugin-manager.git ``` CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-gcc-ar WINDRES=x86_64-w64-mingw32-windres LZMA_CONFIGURE="--host=x86_64-w64-mingw32" ARCHIVE_CONFIGURE="-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_SYSTEM_NAME=Windows" CURL_CONFIGURE="-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_SYSTEM_NAME=Windows" GIT2_CONFIGURE="-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DBUILD_CLAR=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_SYSTEM_NAME=Windows -DDLLTOOL=x86_64-w64-mingw32-dlltool" SSL_CONFIGURE=mingw ./build.sh -DLPM_VERSION='"'$VERSION-x86_64-windows-`git rev-parse --short HEAD`'"' ``` + @@ -0,0 +1,209 @@ +# Manifest Specification + +A lite-xl manifest is a JSON file contains three different keys: + +* Remotes +* Plugins +* Lite-XLs + +## Remotes + +A simple array of string repository identifiers. A repository identifier takes +the form of a git remote url, i.e. `<url>:<ref>`. An example would be: + +`https://github.com/adamharrison/lite-xl-plugin-manager.git:latest` + +## Plugins + +Plugins are the primary objects specified in this specification. A plugin +consists of a series of metadata, the path to the plugin in this repository, +or its location on a remote repository, or a publically accessible URL,and a +set of files to be downloaded with the plugin (usually releases, but can be +data files, or fonts, or anything else). + +Plugins can specify optionally specify a type, which determines where they're +installed. Currently two types are supported: + +* `library` +* `plugin` + +Plugins are classified into two categories. `singleton` plugins, and `complex` +plugins. Plugins are listed a `singleton` if and only if they consist of exactly +one file, have an empty or absent `files` specification, and do not specify +a `remote`. Singleton plugins consist of exactly one `.lua` file, named after +the plugin. Complex plugins are contained within a folder, and have an +`init.lua` or `init.so` file that loads other components within it. + +The vast majority of plugins are `singleton` plugins. + +### Metadata + +* `name`: The name of the plugin. +* `version`: The plugin's semantic version. +* `description`: An english-language description of the plugin. +* `mod_version`: The mod_version this plugin is compatible with. +* `provides`: An optional array of strings that are a shorthand of functionality + this plugin provides. Can be used as a dependency. +* `dependencies`: Optionally a hash of dependencies required, or optional + for this plugin. +* `tags`: Optional freeform tags that may describe attributes of the plugin. + +### Dependencies + +Depedencies are specified in an object, with the key being the name of the +plugin depended upon, or a `provides` alias. + +Dependency values are an object which contain the following keys: + +* `version`: A version specifier. (see below). +* `optional`: A boolean that determines whether the dependency is optional. + +### Remote Repository + +If a plugin likes, it can specify a particular repository, pinned at a specific +commit to be used as a source for its data. In that case, the package manager +must download the repository, and interpret the manifest file found there. + +### Files + +Files are objects that contain at least two keys, `url`, and `checksum`. They +can also optionally contain the `arch` and `path` keys. + +* `url` represents the URL to grab the particular file from. +* `checksum` is the sha256hex checksum for the file. +* `arch` is the lite-xl/clang architecture tuple that the file is relevant for. + if omitted, file is to be assumed to be valid for all arhcitectures. +* `path` is the location to install this file inside the plugin's directory. + +If a file is an archive, of either `.zip` or `.tar.gz`, it will automatically +be extracted inside the plugin's directory. + +## Lite-XLs + +Lite-XLs represent different version of lite-xl that are registered in this +repository. Lite-XLs has the following metadata, as well as a `files` array. + +* `version`: A version specifier. Must take the form of x.x(.x)(-suffix). + Suffixes can be used to denote different flavours of lite-xl. +* `mod_version`: The modversion the binary corresponds to. + +### Files + +The files array is identical to that of the `files` array under `plugins`. +Conventionally, there should be a single file per architecture that is a +`.tar.gz` or `.zip` containing all necessary files for `lite-xl` to run. + +## Version Specifiers + +When asking for a version, all fields can use inequality operators to specify +the version to be asked for. As an example, `>=0.1` can be used to specify +that any version greater than `0.1` can be used. + +## Example File + +```yaml +{ + "plugins": [ # The plugins array contains a list of all plugins registered on this repository. + { + "name": "plugin_manager", # Unique name, used to reference the plugin. + "version": "0.1", # Semantic version. + "description": "A GUI interface to the Adam's lite plugin manager.", # English description of the plugin. + "path": "plugins/plugin_manager", # The path to the plugin in this repository. + "mod_version": 3, # The mod_version this plugin corresponds to. + "provides": [ # A list of small strings that represent functionalities this plugin provides. + "plugin-manager" + ], + "files": [ # A list of files (usually binaries) this plugin requires to function. + { + "url": "https://github.com/adamharrison/lite-xl-plugin-manager/releases/download/v0.1/lpm.x86_64-linux", # A publically accessible to download from. + "arch": "x86_64-linux", # The lite-xl/clang target tuple that represents the architecture this file is for. + "checksum": "d27f03c850bacdf808436722cd16e2d7649683e017fe6267934eeeedbcd21096" # the sha256hex checksum that corresponds to this file. + }, + { + "url": "https://github.com/adamharrison/lite-xl-plugin-manager/releases/download/v0.1/lpm.x86_64-windows.exe", + "arch": "x86_64-windows", + "checksum": "2ed993ed4376e1840b0824d7619f2d3447891d3aa234459378fcf9387c4e4680" + } + ], + "dependencies": { + "json": {} # Depeneds on `json`, can be a plugin's name or one of its `provides`. + } + }, + { + "name": "json", + "version": "1.0", + "description": "JSON support plugin, provides encoding/decoding.", + "type": "library", + "path": "plugins/json.lua", + "provides": [ + "json" + ] + }, + { + "tags": ["language"], + "description": "Syntax for .gitignore, .dockerignore and some other `.*ignore` files", + "version": "1.0", + "mod_version": 3, + "remote": "https://github.com/anthonyaxenov/lite-xl-ignore-syntax:2ed993ed4376e1840b0824d7619f2d3447891d3aa234459378fcf9387c4e4680", # The remote to be used for this plugin. + "name": "language_ignore" + }, + { + "description": "Provides a GUI to manage core and plugin settings, bindings and select color theme. Depends on widget.", + "dependencies": { + "toolbarview": { "version": ">=1.0" }, + "widget": { "version": ">=1.0" } + }, + "version": "1.0", + "mod_version": "3", + "path": "plugins/settings.lua", + "name": "settings" + }, + { + "description": "Syntax for Kaitai struct files", + "url": "https://raw.githubusercontent.com/whiteh0le/lite-plugins/main/plugins/language_ksy.lua?raw=1", # URL directly to the singleton plugin file. + "name": "language_ksy", + "version": "1.0", + "mod_version": 3, + "checksum": "08a9f8635b09a98cec9dfca8bb65f24fd7b6585c7e8308773e7ddff9a3e5a60f", # Checksum for this particular URL. + } + ], + "lite-xls": [ # An array of lite-xl releases. + { + "version": "2.1-simplified", # The version, followed by a release suffix defining the release flavour. The only releases that are permitted to not have suffixes are official relases. + "mod_version": 3, # The mod_version this release corresponds to. + "files": [ # Identical to `files` under `plugins`, although these are usually simply archives to be extracted. + { + "arch": "x86_64-linux", + "url": "https://github.com/adamharrison/lite-xl-simplified/releases/download/v2.1/lite-xl-2.1.0-simplified-x86_64-linux.tar.gz", + "checksum": "b5087bd03fb491c9424485ba5cb16fe3bb0a6473fdc801704e43f82cdf960448" + }, + { + "arch": "x86_64-windows", + "url": "https://github.com/adamharrison/lite-xl-simplified/releases/download/v2.1/lite-xl-2.1.0-simplified-x86_64-windows.zip", + "checksum": "f12cc1c172299dd25575ae1b7473599a21431f9c4e14e73b271ff1429913275d" + } + ] + }, + { + "version": "2.1-simplified-enhanced", + "mod_version": 3, + "files": [ + { + "arch": "x86_64-linux", + "url": "https://github.com/adamharrison/lite-xl-simplified/releases/download/v2.1/lite-xl-2.1.0-simplified-x86_64-linux-enhanced.tar.gz", + "checksum": "4625c7aac70a2834ef5ce5ba501af2d72d203441303e56147dcf8bcc4b889e40" + }, + { + "arch": "x86_64-windows", + "url": "https://github.com/adamharrison/lite-xl-simplified/releases/download/v2.1/lite-xl-2.1.0-simplified-x86_64-windows-enhanced.zip", + "checksum": "5ac009e3d5a5c99ca7fbd4f6b5bd4e25612909bf59c0925eddb41fe294ce28a4" + } + ] + } + ], + "remotes": [ # A list of remote specifiers. The plugin manager will pull these in and add them as additional repositories if specified to do so with a flag. + "https://github.com/lite-xl/lite-xl-plugins.git:2.1", + "https://github.com/adamharrison/lite-xl-simplified.git:v2.1" + ] +} +``` @@ -5,7 +5,7 @@ : ${BIN=lpm} : ${JOBS=4} -SRCS="*.c" +SRCS="src/*.c" LDFLAGS="$LDFLAGS -lm -pthread -static-libgcc" [[ "$@" == "clean" ]] && rm -rf lib/libgit2/build lib/zlib/build lib/openssl/build lib/curl/build lib/libarchive/build-tmp lib/liblzma/build lib/prefix $BIN *.exe && exit 0 @@ -29,7 +29,7 @@ if [[ "$@" != *"-lcurl"* ]]; then [ ! -e "lib/curl/build" ] && cd lib/curl && mkdir build && cd build && cmake .. -G="Unix Makefiles" $CURL_CONFIGURE -DCURL_USE_LIBPSL=OFF -DCURL_DISABLE_LDAPS=ON -DUSE_OPENSSL=ON -DCURL_DISABLE_LDAP=ON -DCMAKE_INSTALL_PREFIX=`pwd`/../../prefix -DUSE_LIBIDN2=OFF -DENABLE_UNICODE=OFF -DBUILD_CURL_EXE=OFF -DCURL_USE_LIBSSH2=OFF -DOPENSSL_ROOT_DIR=`pwd`/../../prefix -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_LIBDIR=lib && $MAKE -j $JOBS && $MAKE install && cd ../../../ LDFLAGS="-Llib/curl/build -Llib/prefix/lib -l:libcurl.a $LDFLAGS" && CFLAGS="$CFLAGS -Ilib/prefix/include -DCURL_STATICLIB" fi -if [[ "$@" != *"-lzma"* ]]; then +if [[ "$@" != *"-llzma"* ]]; then [ ! -e "lib/liblzma/build" ] && cd lib/liblzma && mkdir build && cd build && ../configure $LZMA_CONFIGURE --prefix=`pwd`/../../prefix && $MAKE -j $JOBS && $MAKE install && cd ../../../ LDFLAGS="-Llib/liblzma/build -Llib/prefix/lib -l:liblzma.a $LDFLAGS" && CFLAGS="$CFLAGS -Ilib/prefix/include" fi @@ -41,7 +41,7 @@ fi [[ "$@" != *"-llua"* ]] && CFLAGS="$CFLAGS -Ilib/lua -DMAKE_LIB=1" && SRCS="$SRCS lib/lua/onelua.c" # Build the pre-packaged lua file into the executbale. -xxd -i lpm.lua > lpm.lua.c +xxd -i src/lpm.lua > src/lpm.lua.c [[ $OSTYPE != 'msys'* && $CC != *'mingw'* && $CC != "emcc" ]] && LDFLAGS=" $LDFLAGS -ldl -pthread" [[ $OSTYPE == 'msys'* || $CC == *'mingw'* ]] && LDFLAGS="$LDFLAGS -lbcrypt -lws2_32 -lz -lwinhttp -lole32 -lcrypt32 -lrpcrt4" @@ -320,7 +320,7 @@ static int lpm_init(lua_State* L) { const char* path = luaL_checkstring(L, 1); const char* url = luaL_checkstring(L, 2); git_repository* repository; - if (git_repository_init(&repository, path, 0) != 0) + if (git_repository_init(&repository, path, 0)) return luaL_error(L, "git init error: %s", git_error_last_string()); git_remote* remote; if (git_remote_create(&remote, repository, "origin", url)) { |