latest pushes

This commit is contained in:
2024-10-10 15:03:19 -04:00
parent 90443263be
commit 76f6864955
6 changed files with 195 additions and 2 deletions

8
.gitignore vendored Normal file
View File

@@ -0,0 +1,8 @@
publish.sh
build
MANIFEST.in
tests
setup.py
setup.cfg
dist
src/bellande_rust_executable.egg-info

View File

@@ -1,7 +1,31 @@
# Bellronos Installer
Install bellronos Programming Languages into your Operating System
## Install pip with sudo or bell
- `sudo pip install bellronos_installer`
- `bell pip install bellronos_installer`
## Usage of bellronos Installer
- **To use this script, you would run it with sudo privileges and specify an action:**
- To install a specific version: sudo bellronos_installer install --version <branch_name>
- To list available versions: sudo bellronos_installer list
- To install the latest version: sudo bellronos_installer latest
- To use the upload placeholder: sudo bellronos_installer update
## Website PYPI
- https://pypi.org/project/bellronos_installer
### Upgrade (if not upgraded)
- `pip install --upgrade bellronos_installer`
```
Name: bellronos_installer
Summary: Install Bellronos Programming Languages into your Operating System
Home-page: github.com/Architecture-Mechanism/bellronos_installer
Author: Ronaldson Bellande
Author-email: ronaldsonbellande@gmail.com
License: GNU General Public License v3.0
```
## License
Bellronos Installer is distributed under the [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html), see [LICENSE](https://github.com/Architecture-Mechanism/bellronos_installer/blob/main/LICENSE) and [NOTICE](https://github.com/Architecture-Mechanism/bellronos_installer/blob/main/LICENSE) for more information.
BellandeOS Programming Language Installer is distributed under the [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html), see [LICENSE](https://github.com/Architecture-Mechanism/bellronos_installer/blob/main/LICENSE) and [NOTICE](https://github.com/Architecture-Mechanism/bellronos_installer/blob/main/LICENSE) for more information.

3
git_scripts/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
fix_errors.sh
push.sh
repository_recal.sh

1
src/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
bellronos_installer.egg-info

View File

View File

@@ -0,0 +1,157 @@
# Copyright (C) 2024 Bellande Architecture Mechanism Research Innovation Center, Ronaldson Bellande
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#!/usr/bin/env python3
import os
import shutil
import sys
import requests
import argparse
import subprocess
from packaging import version
GITHUB_API_URL = "https://api.github.com/repos/Architecture-Mechanism/bellronos/branches"
GITHUB_RAW_URL = "https://raw.githubusercontent.com/Architecture-Mechanism/bellronos"
BELLRONOS_INSTALL_PATH = "/usr/local/bin/bellronos"
def get_available_versions():
try:
response = requests.get(GITHUB_API_URL)
response.raise_for_status()
branches = response.json()
return [branch['name'] for branch in branches]
except requests.RequestException as e:
print(f"Error fetching branches: {e}")
print(f"Response status code: {e.response.status_code if e.response else 'N/A'}")
print(f"Response content: {e.response.content if e.response else 'N/A'}")
return []
def download_bellronos(branch):
url = f"{GITHUB_RAW_URL}/{branch}/executable/bellronos"
try:
response = requests.get(url)
response.raise_for_status()
with open("bellos_executable", "wb") as f:
f.write(response.content)
return True
except requests.RequestException as e:
print(f"Error downloading Bellos from branch {branch}: {e}")
return False
def setup_bellos(version=None):
if version:
if not download_bellos(version):
return
bellos_executable = "bellos_executable"
else:
bellos_executable = "executable/bellos"
if not os.path.exists(bellos_executable):
print(f"Error: {bellos_executable} not found.")
return
try:
shutil.copy2(bellos_executable, BELLRONOS_INSTALL_PATH)
os.chmod(BELLRONOS_INSTALL_PATH, 0o755) # Make it executable
print(f"Bellos has been copied to {BELLRONOS_INSTALL_PATH}")
except IOError as e:
print(f"Error copying file: {e}")
return
if version:
os.remove(bellos_executable)
print("Bellronos has been set up successfully.")
def list_versions():
versions = get_available_versions()
if versions:
print("Available Bellronos versions:")
for v in versions:
print(f"- {v}")
else:
print("No versions found or unable to fetch versions.")
def install_latest():
versions = get_available_versions()
if versions:
latest = max(versions, key=lambda x: version.parse(x) if x != 'main' else version.parse('0'))
if latest == 'main':
print("No versioned branches found. Installing from main branch.")
else:
print(f"Installing latest version: {latest}")
setup_bellos(latest)
else:
print("Unable to determine the latest version. Installing from main branch.")
setup_bellos()
def get_current_version():
try:
result = subprocess.run([BELLRONOS_INSTALL_PATH, "--version"], capture_output=True, text=True)
return result.stdout.strip()
except FileNotFoundError:
return "Not installed"
except subprocess.CalledProcessError:
return "Unknown"
def get_latest_version():
versions = get_available_versions()
if versions:
return max(versions, key=lambda x: version.parse(x) if x != 'main' else version.parse('0'))
return "main"
def update_bellos():
current_version = get_current_version()
latest_version = get_latest_version()
if current_version == "Not installed":
print("Bellronos is not installed. Installing the latest version.")
install_latest()
elif current_version == "Unknown":
print("Unable to determine the current version. Proceeding with update.")
setup_bellos(latest_version)
elif current_version == latest_version:
print(f"Bellos is already up to date (version {current_version}).")
else:
print(f"Updating Bellronos from version {current_version} to {latest_version}")
setup_bellos(latest_version)
def main():
if os.geteuid() != 0:
print("This script must be run with sudo privileges.")
sys.exit(1)
parser = argparse.ArgumentParser(description="Bellronos Setup Script")
parser.add_argument("action", choices=["install", "list", "latest", "update"],
help="Action to perform: install, list versions, install latest, or update")
parser.add_argument("--version", help="Specify version to install")
args = parser.parse_args()
if args.action == "install":
if args.version:
setup_bellos(args.version)
else:
print("Please specify a version to install with --version, or use 'latest' to install the latest version.")
elif args.action == "list":
list_versions()
elif args.action == "latest":
install_latest()
elif args.action == "update":
update_bellos()
if __name__ == "__main__":
main()