Compare commits

..

10 Commits

Author SHA1 Message Date
bbb6fd6b44 Update README.md 2024-10-01 11:26:12 +10:00
eae8400600 Update README.md 2024-10-01 11:24:26 +10:00
7ff00d7cf0 Update src/main/kotlin/Main.kt 2024-10-01 11:11:54 +10:00
f73a32e72c Update README.md 2024-09-20 13:40:37 +10:00
8ee75e4b6f Update README.md 2024-09-20 13:29:59 +10:00
Maxwell Jeffress
59056dbdfc Cope better when not enough arguments are inputted 2024-09-20 13:23:50 +10:00
Maxwell Jeffress
2a8f65c953 I can't remember what I worked on just have a look 2024-09-19 13:17:06 +10:00
Maxwell Jeffress
75b49147df Add help dialog 2024-09-11 13:24:42 +10:00
Maxwell Jeffress
ea5bb86f7e Update package version 2024-09-11 13:17:12 +10:00
Maxwell Jeffress
4271b28acd Start work on deletions, command line arguments 2024-09-11 13:15:05 +10:00
4 changed files with 146 additions and 42 deletions

2
.gitignore vendored
View File

@ -9,6 +9,8 @@ gradlew
gradlew.bat
.kotlin
test
### IntelliJ IDEA ###
.idea
.idea/modules.xml

View File

@ -2,7 +2,7 @@
### What is Mapm?
Mapm is a package manager (written in Kotlin) for, you know, managing packages. So far it's VERY early in development. Mapm is designed to run on the JVM, while using a UNIX-like system.
Mapm is a package manager (written in Kotlin) for, you know, managing packages. So far it's VERY early in development. Mapm is designed to run on the JVM, while using Linux system (as the packages are only compiled for Linux at present).
### Why?
@ -10,23 +10,54 @@ No reason. :)
### Setup
Make directories /usr/mapm and /usr/mapm/tmp. Add /usr/mapm to path. Download the files and make sure Gradle is installed. Run `gradle distTar` to compile a Tar file with all the needed Jars in it, including mapm. Untar the archive in build/distributions. Run `./(where tar extracted to)/bin/mapm`. (or mapm.bat if you're crazy)
**Make sure Java 17 or later is installed! Mapm is built targeting 17 or later, so it will not run on older versions!**
#### Express
Run the command `curl https://maxwellj.xyz/mapm/mapm.sh | bash`. This will run an express setup script.
#### Manual
Make directories /usr/mapm and /usr/mapm/tmp. Add /usr/mapm to path. Download the files and make sure Gradle is installed. Run `gradle distTar` to compile a Tar file with all the needed Jars in it, including mapm. Untar the archive in build/distributions. Run `./(where tar extracted to)/bin/mapm`.
### Usage
Run mapm. For now, command line arguments aren't supported, but this is planned for a later date. Once you're in mapm, you can type `grab` and press enter. Type the thing you want and it will download.
Mapm has a few options for the command line. So far these are:
* g: Grab a package from the internet.
* r: Remove a package from your system. (work in progress)
* c: Make a checksum that Mapm can reproduce and recognise.
* m: Automatically make a Mapm package (work in progress)
* h: Get help.
Some example commands:
* `mapm g mash`: Grab the package `mash` and install it.
* `mapm r mash`: Remove the package `mash` from your computer.
* `mapm c mash-0.0.2.tar.xz`: Generate a checksum for the file `mash-0.0.2.tar.xz`
### Making a mapm package
To make a mapm package, go to https://git.maxwellj.xyz/mapm/stable and submit a pull request. Add your package's name as the file name, and the link to where your package is stored as the contents. Don't add anything more or you'll confuse mapm. Make sure the link points to a .tar.xz archive. The file structure should be like this:
```
├── (packagename) (A symbolic link to your executable in packagename.d)
├── (packagename) (Your executable)
└── (packagename).d
├── executable
└── Any other files your package needs
```
Zip all that up into a .tar.xz file, upload it to your server and add the link to your pull request. After creating the .tar.xz, use Mapm to create a checksum for the file. Run mapm, type `checksum`, press enter and type the file path. Press enter and copy the checksum to `(packagename).hash` inside your pull request.
Zip all that up into a .tar.xz file and upload it to your own server. After creating the .tar.xz, use Mapm to create a checksum for the file. Run `mapm c (file name` to get the checksum. For now, there is no polished system for package processing, so for now send an email to max AT maxwellj.xyz with the package link, hash and all dependencies required to run your program.
**Note**: If your package requires an update, make sure to email an updated link and hash, otherwise Mapm will reject your package when it is being installed.
### Making your own repo
For now, this isn't a thing, but you'll be able to when configuration is a thing.
For now, this isn't a thing, but you'll be able to when configuration is a thing.
### FAQ's
**What is mapm?**
Mapm is a package manager, intended for UNIX-based/like OSes, running on the JVM. Mapm packages are organised neatly in /usr/mapm. When built around Mapm, packages have their config files inside one directory, with an executable in /usr/mapm.
**Is Mapm any good?**
Mapm is in constant development, and things may break. Automatic update detection is not avaliable yet, meaning it is harder to patch security holes for now.

View File

@ -10,7 +10,7 @@ application {
}
group = "xyz.maxwellj.mapm"
version = "0.0.1"
version = "0.0.3"
repositories {
mavenCentral()

View File

@ -13,7 +13,7 @@ import java.io.BufferedInputStream
import java.io.FileInputStream
import java.nio.file.Files
import java.nio.file.Paths
import kotlin.collections.listOf as listOf
fun uncompressXZFile(inputFile: String, outputFile: String) {
XZInputStream(FileInputStream(inputFile)).use { input ->
@ -52,40 +52,111 @@ fun md5(input:String): String {
return BigInteger(1, md.digest(input.toByteArray())).toString(16).padStart(32, '0')
}
suspend fun main() {
println("Welcome to Mapm! What would you like to do? Type help for some help.")
val userInput = readln()
if (userInput == "grab") {
println("What would you like to grab?")
val userInput = readln()
val linkToUse = "https://git.maxwellj.xyz/mapm/stable/raw/branch/main/$userInput"
val dingus = Fuel.get(linkToUse).body.string()
println(dingus)
val file = File("/usr/mapm/tmp/$userInput.tar.xz")
// file.writeBytes((Fuel.get(dingus).body.string()).toByteArray())
val fileBytes = Fuel.get(dingus).body.bytes()
file.writeBytes(fileBytes)
val fileChecksum = Fuel.get("https://git.maxwellj.xyz/mapm/stable/raw/branch/main/$userInput.hash").body.string()
if (fileChecksum == md5(file.readText())) {
println("Checksum matches!")
uncompressXZFile(inputFile = "/usr/mapm/tmp/${userInput}.tar.xz", outputFile = "/usr/mapm/tmp/${userInput}.tar")
unarchiveTarFile(tarFilePath = "/usr/mapm/tmp/${userInput}.tar", outputDirectoryPath = "/usr/mapm/")
Runtime.getRuntime().exec("chmod +x /usr/mapm/${userInput}")
println("Finished!")
exitProcess(0)
suspend fun grabDependencies(input:String): String {
val dependencyList = Fuel.get("https://git.maxwellj.xyz/mapm/stable/raw/branch/main/$input/dependencies").body.string()
return(dependencyList)
}
suspend fun grabPackage(input:String): Int {
println("Downloading package $input...")
val linkToUse = "https://git.maxwellj.xyz/mapm/stable/raw/branch/main/$input/source"
val packageLocation = Fuel.get(linkToUse).body.string()
val file = File("/usr/mapm/tmp/$input.tar.xz")
val fileBytes = Fuel.get(packageLocation).body.bytes()
file.writeBytes(fileBytes)
val fileChecksum = Fuel.get("https://git.maxwellj.xyz/mapm/stable/raw/branch/main/$input/hash").body.string()
if (fileChecksum == md5(file.readText())) {
println("Checksum matches!")
uncompressXZFile(inputFile = "/usr/mapm/tmp/${input}.tar.xz", outputFile = "/usr/mapm/tmp/${input}.tar")
unarchiveTarFile(tarFilePath = "/usr/mapm/tmp/${input}.tar", outputDirectoryPath = "/usr/mapm/")
Runtime.getRuntime().exec("chmod +x /usr/mapm/${input}")
println("Finished!")
return(0)
} else {
println("Checksum doesn't match! Aborting...")
println("Please tell Max or your app's developer to use mapm to generate a new checksum. If the checksum is right, check your internet connection security.")
return(1)
}
}
suspend fun main(args: Array<String>) {
if (args.size < 2) {
if (args.size == 1) {
if (args[0] == "h") {
println("mapm - Max's Package Manager")
println("Version 0.0.3")
println("(C) Maxwell Jeffress 2024, licensed under the GNU GPL V3")
println("")
println("---Help---")
println("Arguments that can be run")
println("g Grab a package from the internet")
println("r Remove a package")
println("c Generate a checksum for a package")
println("")
println("More info at the following links:")
println("https://maxwellj.xyz/mapm")
println("https://git.maxwellj.xyz/max/mapm")
exitProcess(0)
} else {
println("USAGE: mapm [g, r, c, m] [package name] Type 'h' for help")
exitProcess(1)
}
} else {
println("Checksum doesn't match! Aborting...")
println("Please tell Max or your app's developer to use mapm to generate a new checksum. If the checksum is right, check your internet connection security.")
exitProcess(1)
}
} else if (userInput == "delete") {
println("What would you like to delete?")
val userInput = readln()
} else if (userInput == "checksum") {
println("What file would you like to generate a checksum of? Type the whole path")
val userInput = readln()
println("USAGE: mapm [g, r, c, m] [package name] Type 'h' for help")
exitProcess(1)
}
}
var userInput: String = args[0]
if (userInput == "g") {
val userInput: String = args[1]
val linkToUse = "https://git.maxwellj.xyz/mapm/stable/raw/branch/main/$userInput/source"
val packageLocation = Fuel.get(linkToUse).body.string()
val dependencies = grabDependencies(userInput)
println("Downloading packages $userInput $dependencies")
println("Is this okay?")
val userInputInteractive: String = readln()
if (userInputInteractive != "y") {
println("Confirmation not given. Exiting...")
exitProcess(0)
}
var currentPackage = ""
for (char in dependencies) {
if (char.toString() != " ") {
currentPackage += char.toString()
} else {
grabPackage(currentPackage)
var currentPackage = ""
}
}
grabPackage(userInput)
} else if (userInput == "r") {
val executable = File("/usr/mapm/${args[1]}")
println("Deleting package ${args[1]}")
println("Is this okay? (y/n)")
var userInput = readln()
if (userInput != "y") {
executable.delete()
}
} else if (userInput == "c") {
val userInput = args[1]
val file = File(userInput)
println("Checksum of that file is ${md5(file.readText())}")
} else if (userInput == "m") {
println("this feature is in progress")
println("")
} else if (userInput == "h") {
println("mapm - Max's Package Manager")
println("Version 0.0.3")
println("(C) Maxwell Jeffress 2024, licensed under the GNU GPL V3")
println("")
println("---Help---")
println("Arguments that can be run")
println("g Grab a package from the internet")
println("r Remove a package")
println("c Generate a checksum for a package")
println("")
println("More info at the following links:")
println("https://maxwellj.xyz/mapm")
println("https://git.maxwellj.xyz/max/mapm")
}
}
}