Compare commits

...

7 Commits

Author SHA1 Message Date
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
4 changed files with 113 additions and 30 deletions

2
.gitignore vendored
View File

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

View File

@@ -10,6 +10,14 @@ No reason. :)
### Setup ### Setup
**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`. (or mapm.bat if you're crazy) 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)
### Usage ### Usage
@@ -25,8 +33,20 @@ To make a mapm package, go to https://git.maxwellj.xyz/mapm/stable and submit a
├── executable ├── executable
└── Any other files your package needs └── 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, type `checksum`, press enter and type the file path. 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 and hash.
**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 ### 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 both their executables and config files inside one directory, with one symbolic link or launch script in /usr/mapm.
**Is Mapm any good?**
For now, Mapm doesn't have support for dependencies, meaning if your program requires another library, Mapm won't be able to provide those yet. Mapm also hasn't got very many packages right now, as it is still very experimental.

View File

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

View File

@@ -15,7 +15,6 @@ import java.nio.file.Files
import java.nio.file.Paths import java.nio.file.Paths
import kotlin.collections.listOf as listOf import kotlin.collections.listOf as listOf
fun uncompressXZFile(inputFile: String, outputFile: String) { fun uncompressXZFile(inputFile: String, outputFile: String) {
XZInputStream(FileInputStream(inputFile)).use { input -> XZInputStream(FileInputStream(inputFile)).use { input ->
FileOutputStream(outputFile).use { output -> FileOutputStream(outputFile).use { output ->
@@ -53,49 +52,111 @@ fun md5(input:String): String {
return BigInteger(1, md.digest(input.toByteArray())).toString(16).padStart(32, '0') return BigInteger(1, md.digest(input.toByteArray())).toString(16).padStart(32, '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>) { 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("USAGE: mapm [g, r, c, m] [package name] Type 'h' for help")
exitProcess(1)
}
}
var userInput: String = args[0] var userInput: String = args[0]
println(userInput)
if (userInput == "g") { if (userInput == "g") {
val userInput: String = args[1] val userInput: String = args[1]
val linkToUse = "https://git.maxwellj.xyz/mapm/stable/raw/branch/main/$userInput" val linkToUse = "https://git.maxwellj.xyz/mapm/stable/raw/branch/main/$userInput/source"
val dingus = Fuel.get(linkToUse).body.string() val packageLocation = Fuel.get(linkToUse).body.string()
println("Package $userInput found at $dingus") val dependencies = grabDependencies(userInput)
// val packageList = listOf($userInput) println("Downloading packages $userInput $dependencies")
println("Downloading package $userInput")
println("Is this okay?") println("Is this okay?")
val userInputInteractive: String = readln() val userInputInteractive: String = readln()
if (userInputInteractive != "y") { if (userInputInteractive != "y") {
println("Confirmation not given. Exiting...") println("Confirmation not given. Exiting...")
exitProcess(0) exitProcess(0)
} }
val file = File("/usr/mapm/tmp/$userInput.tar.xz") var currentPackage = ""
val fileBytes = Fuel.get(dingus).body.bytes() for (char in dependencies) {
file.writeBytes(fileBytes) if (char.toString() != " ") {
val fileChecksum = Fuel.get("https://git.maxwellj.xyz/mapm/stable/raw/branch/main/$userInput.hash").body.string() currentPackage += char.toString()
if (fileChecksum == md5(file.readText())) { } else {
println("Checksum matches!") grabPackage(currentPackage)
uncompressXZFile(inputFile = "/usr/mapm/tmp/${userInput}.tar.xz", outputFile = "/usr/mapm/tmp/${userInput}.tar") var currentPackage = ""
unarchiveTarFile(tarFilePath = "/usr/mapm/tmp/${userInput}.tar", outputDirectoryPath = "/usr/mapm/") }
Runtime.getRuntime().exec("chmod +x /usr/mapm/${userInput}") }
println("Finished!") grabPackage(userInput)
exitProcess(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.")
exitProcess(1)
}
} else if (userInput == "r") { } else if (userInput == "r") {
val executable = File("/usr/mapm/${args[1]}") val executable = File("/usr/mapm/${args[1]}")
println("Deleting package ${args[1]}") println("Deleting package ${args[1]}")
println("Is this okay? (y/n)") println("Is this okay? (y/n)")
var userInput = readln() var userInput = readln()
if (userInput != "y") { if (userInput != "y") {
executable.delete() executable.delete()
} }
} else if (userInput == "c") { } else if (userInput == "c") {
val userInput = args[1] val userInput = args[1]
val file = File(userInput) val file = File(userInput)
println("Checksum of that file is ${md5(file.readText())}") 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")
} }
} }