apkbuilder

commit f1efc69eefd1c35121b1e3f8e0582ed7242808d8

Author: Pedro Lucas Porcellis <porcellis@eletrotupi.com>

Initial fleshing

 COPYING | 26 ++++++++++++++++++++
 README | 14 +++++++++++
 apkbuilder | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++


diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000000000000000000000000000000000000..aeec24df2feb68225e0b997fde587137b3c2b455
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,26 @@
+Copyright 2021 Pedro Lucas Porcellis <porcellis@eletrotupi.com>
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation
+and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its contributors
+may be used to endorse or promote products derived from this software without
+specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.




diff --git a/README b/README
new file mode 100644
index 0000000000000000000000000000000000000000..53a8820cfb20be9b98a3f899754f3401e68cfbd9
--- /dev/null
+++ b/README
@@ -0,0 +1,14 @@
+								apkbuilder
+
+It automatically keeps everything tidy on a package repository of APKBUILDs.
+
+								  USAGE
+
+Run apkbuilder update to update the repository. It'll basically fetch from
+origin master.
+
+Run apkbuilder build to rebuild every package or specify a list of packages.
+
+								   LICENSE
+
+Check COPYING, but it's under the terms of the MIT license.




diff --git a/apkbuilder b/apkbuilder
new file mode 100755
index 0000000000000000000000000000000000000000..1fdd0c394d239638f41763a9947ad63e797093ee
--- /dev/null
+++ b/apkbuilder
@@ -0,0 +1,71 @@
+#!/bin/sh -eu
+
+usage() {
+	printf "%s\n\n" "Usage: $0 [action] [flags...] [args...]"
+	printf "\n%s\n" "$0 build <packages...>"
+	printf "\t%s\n" "Update repository and build the specified packages, or all of them"
+	printf "\n%s\n" "$0 update"
+	printf "\t%s\n" "Update repository"
+}
+
+main_repository() {
+	printf "%s" "$HOME/pacotes.eletrotupi.com"
+}
+
+pkgdir() {
+	printf "%s/pkgs/%s" $(main_repository) $1
+}
+
+build() {
+	update
+	pkgs=""
+
+	if [ $# -eq 0 ]
+	then
+		printf "No package specified. Building everyone. \n\n"
+
+		# Get all packages, excluding . & pkgs. Then strip pkgs from each line
+		pkgs="$(find pkgs -maxdepth 1 -type d -not -name . -not -name pkgs | sed -e 's/pkgs\///')"
+	else
+		pkgs="$@"
+	fi
+
+	for pkg in "$pkgs"
+	do
+		echo "$pkg"
+	done
+}
+
+build_package() {
+	printf "Building %s\n\n" $1
+	cd $(pkgdir $1)
+
+	abuild -r
+}
+
+update() {
+	repositories=$(main_repository)
+	cd "$repositories"
+	git pull origin master
+}
+
+if [ $# -lt 1 ]
+then
+	usage
+	exit 1
+fi
+
+cmd="$1"
+shift
+
+case "$cmd" in
+	update)
+		update "$@"
+		;;
+	build)
+		build "$@"
+		;;
+	help|-h)
+		usage
+		;;
+esac