diff --git a/Makefile b/Makefile index e16fe43..88861ab 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ all: echo "Python package doesn't need compiling!" install: - install src/maps.py $(DESTDIR)$(prefix)/bin/maps + install src/maps $(DESTDIR)$(prefix)/bin/maps install --mode 644 src/completion.bash $(DESTDIR)$(prefix)/share/bash-completion/completions/maps clean: diff --git a/Readme.md b/Readme.md index ef53882..cd4b7f9 100644 --- a/Readme.md +++ b/Readme.md @@ -1,6 +1,6 @@ # MaPS - MaRDI Packaging System -![](https://img.shields.io/badge/version-0.1--beta-blue) +![](https://img.shields.io/badge/version-0.1-blue) ## Introduction diff --git a/pkg/arch/PKGBUILD b/pkg/arch/PKGBUILD new file mode 100644 index 0000000..9e7d34d --- /dev/null +++ b/pkg/arch/PKGBUILD @@ -0,0 +1,34 @@ +# Maintainer: Aaruni Kaushik +pkgname=maps-git +pkgver=v0.1.alpha.33.g175bddb +pkgrel=1 +pkgdesc="Sandboxing tool for Mathematical Research Software" +arch=('x86_64') +url='https://github.com/aaruni96/maps' +license=('GPL3') +depends=('base-devel' + 'cairo' + 'git' + 'gobject-introspection-runtime' + 'python3' + 'ostree' + 'fuse-overlayfs' + 'python-tomli' + ) +conflicts=('maps') +provides=('maps') +optdepends=() +makedepends=('git') +source=("git+https://github.com/aaruni96/maps.git") +md5sums=('SKIP') +BUILDENV+=('!check') + +pkgver() { + cd "$srcdir/maps" + git describe --tags | sed 's/-/./g' +} + +package(){ + install -Dm 755 "$srcdir/maps/src/maps" "$pkgdir/usr/bin/maps" + install -Dm 644 "$srcdir/maps/src/completion.bash" "$pkgdir/usr/share/bash-completion/completions/maps" +} diff --git a/pkg/debian/build-debian.sh b/pkg/debian/build-debian.sh new file mode 100644 index 0000000..06ff1ff --- /dev/null +++ b/pkg/debian/build-debian.sh @@ -0,0 +1,94 @@ +#!/bin/bash +# step 1: grab the thingy + +wget 'http://github.com/aaruni96/maps/archive/refs/heads/devel.tar.gz' -O maps.tar.gz + +# unpack + +tar -xf maps.tar.gz + +# grab version + +VERSION=$(cat maps-devel/Readme.md | grep -i 'version' | head -n 1 | sed 's/^.*version-//' | sed 's/-.*//') + +#rename + +mv -v maps.tar.gz "maps_${VERSION}.orig.tar.gz" +mv -v maps-devel "maps_${VERSION}" + +# setup the debian specific dirs + +cd "maps_${VERSION}" && mkdir -pv "debian/source" + +# add the format version + +echo "3.0 (quilt)" > "debian/source/format" + +echo "maps (0.1-1) UNRELEASED; urgency=medium + + * Initial release. + + -- Aaruni Kaushik Thu, 16 Nov 2023 15:00:38 +0100" > "debian/changelog" + +# add control + + echo 'Source: maps +Maintainer: Aaruni Kaushik +Section: misc +Priority: optional +Standards-Version: 4.6.0.1 +Build-Depends: debhelper-compat (= 13) + +Package: maps +Architecture: amd64 +Depends: ${shlibs:Depends}, ${misc:Depends}, libcairo2-dev, git, gcc (>= 11), python3, python3-dev, libgirepository1.0-dev, libostree-dev, fuse-overlayfs, python3-venv, libcap-dev, autoconf, python3-gi, python3-tomli +Description: Mathematical Packaging System + MaPS helps mathematicians create and publish software runtimes, + as well as deploy and run software inside published runtimes.' > "debian/control" + +# add copyright + +echo 'Format: http://dep.debian.net/deps/dep5 +Upstream-Name: MaPS +Source: https://github.com/aaruni96/maps + +Files: * +Copyright: 2023 Aaruni Kaushi +License: GPL-3.0 + +License: GPL-3.0 + This package 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 package 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 package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + . + On Debian systems, the complete text of the GNU General + Public License can be found in `/usr/share/common-licenses/GPL-3.`' > "debian/copyright" + + # debian.dirs + + echo "usr/bin +usr/share/bash-completion/completions" > "debian/maps.dirs" + +# debian rules + +echo '#!/usr/bin/make -f +%: + dh $@ + +override_dh_auto_install: + $(MAKE) DESTDIR=$$(pwd)/debian/maps prefix=/usr install' > "debian/rules" + +# try building, see what happens + +debuild -us -uc + diff --git a/pkg/debian/make-release.sh b/pkg/debian/make-release.sh new file mode 100644 index 0000000..0718f38 --- /dev/null +++ b/pkg/debian/make-release.sh @@ -0,0 +1,33 @@ +#!/bin/sh +set -e + +do_hash() { + HASH_NAME=$1 + HASH_CMD=$2 + echo "${HASH_NAME}:" + for f in $(find -type f); do + f=$(echo $f | cut -c3-) # remove ./ prefix + if [ "$f" = "Release" ]; then + continue + fi + echo " $(${HASH_CMD} ${f} | cut -d" " -f1) $(wc -c $f)" + done +} + +cat << EOF +Origin: RPTU Testing Repository +Label: RPTU +Suite: stable +Codename: stable +Version: 1.0 +Architectures: amd64 arm64 arm7 i386 +Components: main +Description: Repo for experimental software made in RPTU Kaiserslauatern +Date: $(date -Ru) +EOF +do_hash "MD5Sum" "md5sum" +do_hash "SHA1" "sha1sum" +do_hash "SHA256" "sha256sum" + +# Remember to also run +# dpkg-scanpackages --arch amd64 pool \ No newline at end of file diff --git a/src/completion.bash b/src/completion.bash index bcf060b..591ea96 100644 --- a/src/completion.bash +++ b/src/completion.bash @@ -7,7 +7,7 @@ _maps_completions() # if completing the first word if [ $cword -eq 1 ]; then - COMPREPLY=($(compgen -W "runtime remote package --help -h --command -d --deploy -l --list --repo --reset -r --run -u --uninstall --verbose" -- $cur)) + COMPREPLY=($(compgen -W "runtime remote package --help -h --command -d --deploy -l --list --list-local --repo --reset -r --run -u --uninstall --verbose" -- $cur)) return fi @@ -45,7 +45,7 @@ _maps_completions() fi # for "package" specified case if [ "${COMP_WORDS[1]}" == "package" ]; then - if [ $prev == "-c" -o $prev == "--commit" -o $prev == "-i" -o $prev == "--initialize" -o $prev == "-s" -o $prev == "-sandbox" ]; then + if [ $prev == "-c" -o $prev == "--commit" -o $prev == "-i" -o $prev == "--initialize" -o $prev == "-s" -o $prev == "--sandbox" ]; then COMPREPLY=($(compgen -o dirnames -- "$cur")) return fi @@ -53,7 +53,7 @@ _maps_completions() fi if [ $prev == "runtime" ]; then - COMPREPLY=($(compgen -W "-h --help --command -d --deploy -l --list --repo --reset -r --run -u --uninstall --verbose" -- $cur)) + COMPREPLY=($(compgen -W "-h --help --command -d --deploy -l --list --list-local --repo --reset -r --run -u --uninstall --verbose" -- $cur)) return fi @@ -65,7 +65,7 @@ _maps_completions() fi if [ $prev == "package" ]; then - if [ $cword -eq 3 ]; then + if [ $cword -eq 2 ]; then COMPREPLY=($(compgen -W "-h --help -c --commit -i --initialize -s --sandbox -v --verbose" -- $cur)) return fi diff --git a/src/maps b/src/maps index 8599d24..838a545 100755 --- a/src/maps +++ b/src/maps @@ -14,7 +14,7 @@ import gi gi.require_version("OSTree", "1.0") from gi.repository import OSTree, GLib -VERSION = '0.1-beta' +VERSION = '0.1' BWRAP_DEFAULT = f"{os.getenv('HOME')}/.var/org.mardi.maps/deps/bubblewrap/bwrap" if os.getenv('BWRAP_CMD') is not None: BWRAP = str(os.getenv('BWRAP_CMD')) @@ -89,6 +89,7 @@ def addCLI(): help="Start a sandbox at LOCATION") parser_pack.add_argument('-v', '--verbose', dest='VERBOSE', action='store_true', help="enable verbose output") + parser_pack.add_argument('--repo', dest='REPO', help="Repository to use") return parser, parser_runtime, parser_remote, parser_pack @@ -253,7 +254,7 @@ def mode_run(args): senv["LC_ALL"] = "C" # ignore SIGINT signal.signal(signal.SIGINT, signal.SIG_IGN) - rstatus = subprocess.run((f"{BWRAP} --no-int-term --unshare-user --unshare-pid " + rstatus = subprocess.run((f"{BWRAP} --forward-signals --unshare-user --unshare-pid " f"--bind {DATADIR}/live / --bind {HOME}/Public {senv['HOME']}/Public" " --die-with-parent --proc /proc --dev /dev --uid 0 --gid 0 " f"{command}").split(), @@ -286,7 +287,7 @@ def download(args, repo, remote, refname, cerror=0): with concurrent.futures.ThreadPoolExecutor() as executor: progress = OSTree.AsyncProgress.new() future = executor.submit(zipped_pull, [repo, remote, refname, progress]) - print(f"Downloading {refname} from {remote}") + print(f"Downloading {refname} from {remote}. This may take some time.\nPlease wait...") while True: sys.stdout.write(next(SPINNER)) sys.stdout.flush() @@ -335,7 +336,7 @@ def uninstall_runtime(repo, args): if VERBOSE: print("Marking branch for deletion from repo...") repo.set_ref_immediate(remote, runtime, None, None) - repo.prune(OSTree.RepoPruneFlags(0), -1, None) + repo.prune(OSTree.RepoPruneFlags(2), -1, None) break if not (FLAG1 and FLAG2): @@ -454,9 +455,9 @@ def mode_package(repo, args): senv["LC_ALL"] = "C" # ignore SIGINT signal.signal(signal.SIGINT, signal.SIG_IGN) - rstatus = subprocess.run([BWRAP, "--no-int-term", "--unshare-user", "--unshare-pid", + rstatus = subprocess.run([BWRAP, "--forward-signals", "--unshare-user", "--unshare-pid", "--bind", args.LOCATION, "/", "--proc", "/proc", "--dev", "/dev", - "----die-with-parent", "--uid", "0", "--gid", "0", "bash", + "--die-with-parent", "--uid", "0", "--gid", "0", "bash", "--norc"], env=senv, check=False) if VERBOSE: @@ -469,7 +470,7 @@ def mode_package(repo, args): # we are given TREE and BRANCH. All we have to do is commit TREE to BRANCH with concurrent.futures.ThreadPoolExecutor() as executor: future = executor.submit(commit, [repo, args.COMMIT[0], args.COMMIT[1]]) - print(f"Committing {args.COMMIT[0]} as {args.COMMIT[1]}") + print(f"Committing {args.COMMIT[0]} as {args.COMMIT[1]}. Please wait...") while True: sys.stdout.write(next(SPINNER)) sys.stdout.flush() @@ -525,6 +526,7 @@ def reset(runtime): else: opts = '-rf' subprocess.run(f"rm {opts} {DATADIR}/live/*".split(), check=True) + print(f"{runtime} reset successfully!") # runtime mode: the default path for execution @@ -539,7 +541,7 @@ def mode_runtime(repo, args): refs = list(repo.list_refs()[1].keys()) if refs: for ref in sorted(refs): - print(f"{ref.split(':')[1]}") + print(f"{ref.split(':')[-1]}") elif args.RESET: reset(args.RESET) elif args.UNINSTALL: