Skip to content

Instantly share code, notes, and snippets.

@przemoc
Last active February 6, 2018 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save przemoc/3c575f2d855ba62680159c426a68f84c to your computer and use it in GitHub Desktop.
Save przemoc/3c575f2d855ba62680159c426a68f84c to your computer and use it in GitHub Desktop.
Simplistic abuild wrapper for building packages out-of-the-tree.
#!/bin/sh
# SPDX-License-Identifier: MIT
## Copyright (C) 2017 Przemyslaw Pawelczyk <przemoc@gmail.com>
##
## This script is licensed under the terms of the MIT license.
## https://opensource.org/licenses/MIT
#
# abuild.sh
# Simplistic abuild wrapper for building packages out-of-the-tree.
#
# Put it in its own directory, and everything will be generated there.
# Why? Because I strongly dislike the idea of polluting local aports clone.
# I keep the script in ~/abuild/. You can also put symlink to it in ~/bin/.
if [ $# -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "usage: $0 [-f] [-K] [--] [PATH-TO-APKBUILD-FILE-OR-DIR-WITH-IT]..."
exit 0
fi
ORIGPWD=$(pwd)
TOPDIR=$(readlink -f "${0%/*}")
echo TOPDIR="$TOPDIR"
REPODEST="$TOPDIR/repo"
mkdir -p "$REPODEST"
echo REPODEST="$REPODEST"
export REPODEST
SRCDEST="$TOPDIR/sources"
mkdir -p "$SRCDEST"
echo SRCDEST="$SRCDEST"
export SRCDEST
srcdir="$TOPDIR/.src"
mkdir -p "$srcdir"
echo srcdir="$srcdir"
export srcdir
pkgbasedir="$TOPDIR/.pkg"
mkdir -p "$pkgbasedir"
echo pkgbasedir="$pkgbasedir"
export pkgbasedir
FORCE=
if [ "$1" = "-f" ]; then
FORCE=-f
shift
fi
KEEP=
if [ "$1" = "-K" ]; then
KEEP=-K
shift
fi
[ "$1" != "--" ] || shift
export APKBUILD
cd "$TOPDIR"
while [ $# -gt 0 ]; do
APKBUILD="$1"
shift
[ "${APKBUILD#/}" != "$APKBUILD" ] || APKBUILD="$ORIGPWD/${APKBUILD#./}"
[ "${APKBUILD%/APKBUILD}" != "$APKBUILD" ] || APKBUILD="${APKBUILD%/}/APKBUILD"
echo APKBUILD="$APKBUILD"
if ! [ -r "$APKBUILD" ]; then
echo "$0: $APKBUILD is not readable!" >&2
continue
fi
abuild $FORCE $KEEP -r
done
@przemoc
Copy link
Author

przemoc commented Feb 6, 2018

commit c579a38229027d2664457654b5e107f4a5ff3fa2
Author: Przemyslaw Pawelczyk <przemoc@gmail.com>
Date:   2018-02-06 15:09:59 +0100

    abuild.sh: Add copyright notice and MIT license notice.

commit 8fc74bff24c2a7b6fd7fb6076ededf570f0e4633
Author: Przemyslaw Pawelczyk <przemoc@gmail.com>
Date:   2018-02-06 15:10:32 +0100

    Add SPDX License Identifier.

    The Software Package Data Exchange (SPDX) is a good initiative, it has
    matured over time and deserves accelerated adoption in open-source.

    https://spdx.org/learn
    https://spdx.org/using-spdx
    https://spdx.org/license-list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment