diff --git a/README.md b/README.md index 18e3ae5..a4f8ef0 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,9 @@ Command line tool for dns resolution --- ## PM Package manager `oppm` is good. No denying it. But it has it's limitations. The main one for me : requiring a github repository (ironic I know).\ -To fix this issue, I created a package format using tar as container. +To fix this issue, I created a package format using tar as container.\ + +You can find instructions to make a installation floppy [here](pm_installer/) ### [pm](pm/) The package manager. Install, uninstall and keep track of installed packages. diff --git a/pm/README.md b/pm/README.md index a3eef57..8f9d1f8 100644 --- a/pm/README.md +++ b/pm/README.md @@ -4,6 +4,10 @@ Package manager for OpenOS. Use tar archive as package container ## Installation - run `oppm install pm` +or + +Create a installation floppy. Installation and script can be found [here](../pm_installer/). + ## Usage **Install a package :**\ diff --git a/pm_get/README.md b/pm_get/README.md index a4882de..446f78f 100644 --- a/pm_get/README.md +++ b/pm_get/README.md @@ -1,6 +1,13 @@ # pm_get Download and install pm packages from a repository on internet. +## Installation +- run `oppm install pm` + +or + +Create a installation floppy. Installation and script can be found [here](../pm_installer/). + ## Usage : - `pm-get install ` : install the package - `pm-get uninstall [--autoremove] [--purge]` : uninstall the package. Optionally remove configurations files and/or old dependance no longer needed diff --git a/pm_installer/README.md b/pm_installer/README.md new file mode 100644 index 0000000..0f3261a --- /dev/null +++ b/pm_installer/README.md @@ -0,0 +1,7 @@ +# PM installation floppy creation tool + +## Usage : +- Insert a empty floppy +- run `wget https://github.com/AR2000AR/openComputers_codes/raw/master/pm_installer/download.lua /tmp/pmInstaller.lua` +- run `/tmp/pmInstaller.lua `. Do not forget to replace `` with the empty floppy's path +You now have a installation floppy for `pm` and `pm-get`. You can install them with `install` \ No newline at end of file diff --git a/pm_installer/download.lua b/pm_installer/download.lua new file mode 100644 index 0000000..98aa3dd --- /dev/null +++ b/pm_installer/download.lua @@ -0,0 +1,38 @@ +local shell = require("shell") +local filesystem = require("filesystem") +local os = require("os") +local floppy = '' +local baseURL = 'https://github.com/AR2000AR/openComputers_codes/raw/master/' + +local function wget(...) + shell.execute(table.concat({"wget -f", ...}, " ")) +end +local function mkdir(...) + shell.execute(table.concat({"mkdir", ...}, " ")) +end +local f = string.format +local function concatPath(...) return table.concat({...}, '/') end + +local args, opts = shell.parse(...) +if (not filesystem.exists(args[1]) or not filesystem.isDirectory(args[1])) then + print("No target for the installation disk creation") + os.exit(1) +end +floppy = args[1] + +mkdir(concatPath(floppy, 'bin')) +mkdir(concatPath(floppy, 'lib')) +local files = { + ['pm_get/bin/pm-get.lua'] = 'bin/pm-get.lua', + ['pm/bin/pm.lua'] = 'bin/pm.lua', + ['pm/lib/pm.lua'] = 'lib/pm.lua', + ['tar/lib/tar.lua'] = 'lib/tar.lua', + ['pm_installer/floppy/.install'] = '.install', + ['pm_installer/floppy/.prop'] = '.prop', + ['packages/pm.tar'] = 'pm.tar', + ['packages/pm_get.tar'] = 'pm_get.tar', + ['packages/libtar.tar'] = 'libtar.tar', +} +for src, dst in pairs(files) do + wget(concatPath(baseURL, src), concatPath(floppy, dst)) +end diff --git a/pm_installer/floppy/.install b/pm_installer/floppy/.install new file mode 100644 index 0000000..0dcca5e --- /dev/null +++ b/pm_installer/floppy/.install @@ -0,0 +1,27 @@ +local shell = require("shell") +local package = require("package") +local component = require("component") +local filesystem = require("filesystem") + + +local FROM = _ENV.install.from +local exists = filesystem.exists + +--init path +local oldPackagePath = package.path +package.path = table.concat({oldPackagePath, string.format("%s/lib/?.lua", FROM)}, ";") + + +--install +if (exists(FROM .. "libtar.tar") and exists(FROM .. "pm.tar")) then + shell.execute(FROM .. "bin/pm install --allow-same-version " .. FROM .. "libtar.tar") + shell.execute(FROM .. "bin/pm install --allow-same-version " .. FROM .. "pm.tar") +end +if (component.isAvailable("internet")) then + shell.execute(FROM .. "bin/pm install --allow-same-version " .. FROM .. "pm_get.tar") + shell.execute("pm-get update") + shell.execute("pm-get upgrade") +end + +--reset path +package.path = oldPackagePath diff --git a/pm_installer/floppy/.prop b/pm_installer/floppy/.prop new file mode 100644 index 0000000..aba71d6 --- /dev/null +++ b/pm_installer/floppy/.prop @@ -0,0 +1 @@ +{label='Package Manager', setlabel=false, setboot=false, reboot=false} \ No newline at end of file