Skip to content

Commit

Permalink
Release 1.5.0 Pull Request
Browse files Browse the repository at this point in the history
Release 1.5.0
  • Loading branch information
hammy275 authored Apr 7, 2020
2 parents 3774da6 + fc984ef commit 7eb1d28
Show file tree
Hide file tree
Showing 11 changed files with 431 additions and 51 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
**/.pytest_cache/
**/.DS_Store
.idea/
**/__pycache__
**/__pycache__
/.vscode
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ tarstall is a lightweight package manager for Linux (and similar) systems that m
* Ability to keep itself up to date

## Getting Started
Simply download this repo! Make sure you have Python 3 installed and you should be set! You can invoke first time setup by navigating to the directory where tarstall is stored, then going to the ```tarstall_execs``` directory and running ```python3 tarstall -f```. Afterwards, feel free to use ```tarstall -h``` to view a list of commands!
On a system with wget, run the following command: ```wget https://raw.githubusercontent.com/hammy3502/tarstall/master/install_tarstall && python3 install_tarstall```. You may need to enter your root password to install some of the dependencies for tarstall.

NOTE: Dependencies should be installed manually if you're on a system that doesn't use apt! You'll need to get ahold of `git` and `python3-tk` (tkinter for Python 3). From there, you can run the command above, and everything else will be taken care of for you!

## More Info
Tons of more information is provided in the Wiki. The [Basic Usage section of the wiki](https://github.com/hammy3502/tarstall/wiki/Basic-Usage) provides examples, usage, etc. for most commands while the [Features section of the wiki](https://github.com/hammy3502/tarstall/wiki/Features) details all of the features of tarstall.
8 changes: 4 additions & 4 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""tarstall: A package manager for managing archives
Copyright (C) 2019 hammy3502
Copyright (C) 2020 hammy3502
tarstall is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -22,9 +22,9 @@

###VERSIONS###

version = "1.4.2"
prog_internal_version = 73
file_version = 11
version = "1.5.0"
prog_internal_version = 82
file_version = 13

#############

Expand Down
2 changes: 1 addition & 1 deletion generic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""tarstall: A package manager for managing archives
Copyright (C) 2019 hammy3502
Copyright (C) 2020 hammy3502
tarstall is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
180 changes: 180 additions & 0 deletions install_tarstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
#!/usr/bin/python3

import sys
import os
from subprocess import call
from shutil import which, rmtree

columns = int(os.popen('stty size', 'r').read().split()[1])

def status(msg):
"""Print Status Message.
Prints "major" messages for the end user.
Args:
msg (str): Message to print.
"""
print("#"*int(columns*0.75))
print(msg)
print("#"*int(columns*0.75))


def run(cmds):
"""Run Command.
A tiny function that simply uses 'call', and returns whether or not the call exited successfully.
Args:
cmds (str[]): The command list to pass to call()
Returns:
bool: Whether or not the call() succeeded.
"""
err = call(cmds)
return err == 0


def install_package(pkg):
"""Installs a Package.
Installs the specified package using the distro's package manager.
Currently supports the following package managers:
* apt
* apt-get
* dnf
* pacman
Dictionary format:
If a given package has a different name depending on the package manager (ie. Debian systems having 'python3-tk'
while Arch systems having 'tk'), a dict can be used to specify that.
Example:
{"apt": "python3-tk", "dnf": "python3-tkinter", "pacman": "tk"}
The above example will install the package "python3-tk" if the user is using apt OR apt-get,
"python3-tkinter" if the user is using dnf, or "tk" if the user is using pacman.
Args:
pkg (str/dict): If a string, the package to install. See above for dictionary format.
"""
if type(pkg) is not str:
if which("apt") is not None or which("apt-get") is not None:
pkg = pkg["apt"]
elif which("dnf") is not None:
pkg = pkg["dnf"]
elif which("pacman") is not None:
pkg = pkg["pacman"]
else:
status("This script only supports automatic program installtion through apt(-get), dnf, and pip; please install {} manually!".format(pkg))
sys.exit(1)
if which("apt") is not None:
passed = run(["sudo", "apt", "install", pkg, "-y"])
elif which("apt-get") is not None:
passed = run(["sudo", "apt-get", "install", pkg, "-y"])
elif which("dnf") is not None:
passed = run(["sudo", "dnf", "install", pkg, "-y"])
elif which("pacman") is not None:
passed = run(["sudo", "pacman", "-S", pkg, "--noconfirm"])
else:
status("This script only supports automatic program installtion through apt(-get), dnf, and pip; please install {} manually!".format(pkg))
sys.exit(1)
if not passed:
status("Error installing package {}! Please install it manually, and/or read the error above for information how to resolve this error!".format(pkg))
sys.exit(1)


def setup():
# Checks
status("Checking for anything missing for tarstall setup")
supported_package_managers = ["apt", "apt-get", "dnf", "pacman"]
supported_shells = ["bash", "zsh"]
if which("sudo") is None:
status("Please install 'sudo'!")
sys.exit(1)
supported = False
for manager in supported_package_managers:
if which(manager) is not None:
supported = True
break
if not supported:
status("You currently don't have a supported package manager! Currently supported package managers are: " + ", ".join(supported_package_managers))
sys.exit(1)
shell = os.environ["SHELL"]
shell_supported = False
for sshell in supported_shells:
if sshell in shell:
shell_supported = True
break
if not shell_supported:
print(shell)
msg = "WARNING: YOUR SHELL IS NOT SUPPORTED!\n\nYOU WILL HAVE TO MANUALLY ADD ~/.tarstall/tarstall_execs TO YOUR PATH, " \
"AND ANY PATH/BINLINK FUNCTIONS WILL NOT WORK!\nWOULD YOU LIKE TO PROCEED WITH INSTALLATION ANYWAYS?"
status(msg)
should_proceed = input("Type 'YES' to continue; anything else to exit... ")
if should_proceed.lower() != "yes":
status("Installation cancelled!")
sys.exit(1)
print("All of the checks passed!\n\n\n")

# User information
status("Welcome!\nThis installer is going to install tarstall! You'll need to enter your sudo password at some points. " +
"This will use your distro's package manager along with pip to install the dependencies required for tarstall!")
cancel = input("When you're ready to start installation, press ENTER! If you would like to cancel, type 'c', then press ENTER!")
if cancel.lower() == 'c':
status("Cancelling tarstall setup...")
sys.exit()

# Install git and wget
status("Installing git and wget")
install_package("git")
install_package("wget")

# Clone repository
status("Getting a copy of tarstall")
try:
rmtree("/tmp/tarstall-setup")
except FileNotFoundError:
pass
os.mkdir("/tmp/tarstall-setup")
os.chdir("/tmp/tarstall-setup")
if not run(["git", "clone", "https://github.com/hammy3502/tarstall.git"]):
status("Error while getting the tarstall repository!")
try:
rmtree("/tmp/tarstall-setup")
except FileNotFoundError:
pass
sys.exit(1)
os.chdir("/tmp/tarstall-setup/tarstall")

# Install requirements
status("Installing tarstall's requirements")
if not run([sys.executable, "-m", "pip", "install", "-r", "requirements.txt", "--user"]):
install_package({"apt": "python3-pip", "dnf": "python3-pip", "pacman": "python-pip"})
if not run([sys.executable, "-m", "pip", "install", "-r", "requirements.txt", "--user"]) or not \
run([sys.executable, "-m", "pip", "install", "-r", "requirements-gui.txt", "--user"]):
status("An error occured while installing the GUI requirements!")
sys.exit(1)

# Test tkinter (since we can't install it through pip)
status("Installing tkinter")
try:
import tkinter
del tkinter
print("Thanks for having tkinter already installed!")
except ImportError:
install_package({"apt": "python3-tk", "dnf": "python3-tkinter", "pacman": "tk"})

# Pass control to tarstall
status("Running tarstall installation")
run([sys.executable, "./tarstall_execs/tarstall", "-f"])

# Removing tarstall setup directory
try:
rmtree("/tmp/tarstall-setup")
except FileNotFoundError:
pass

if __name__ == "__main__":
setup()
Loading

0 comments on commit 7eb1d28

Please sign in to comment.