sortix-mirror/build-aux/clean-ports.sh
Jonas 'Sortie' Termansen 9588b0d3db Add ports to the Sortix repository.
This change imports the ports collection from the former porttix and srctix
repositories and converts them to port(5) files with metadata pointing to
the upstream release tarballs with patches checked into this repository.
Ports are now developed and versioned along with the operating system and
are automatically built per the PACKAGES environment variable. The patches
are licensed under the same license as the relevant ports.

Tix has gained support for the new port(5) format. tix-port(8) is the new
high level ports build even point that handles downloading pstream releases
into the new mirror cache directory, applying the patches, building the port
with the lower-level tix-build(8), and finally installing the binary
package. The new tix-vars(8) program parses port(5) files and the new
tix-rmdiff(8) program produces input for tix-rmpatch(8).

The old doc/ directory is discontinued in favor of manual pages documenting
the new ports system.

The obsolete porttix-create(8) and srctix-create(8) programs are removed.
2022-06-13 22:29:53 +02:00

63 lines
2 KiB
Bash
Executable file

set -e
make_dir_path_absolute() {
(cd "$1" && pwd)
}
has_command() {
which "$1" > /dev/null
}
# Detect if the environment isn't set up properly.
if [ -z "$SORTIX_PORTS_DIR" ]; then
echo "$0: error: You need to set \$SORTIX_PORTS_DIR" >&2
exit 1
elif ! [ -d "$SORTIX_PORTS_DIR" ] ||
[ "$(ls "$SORTIX_PORTS_DIR") | wc -l" = 0 ]; then
exit 0
elif ! has_command tix-vars; then
echo "$0: warning: Can't clean ports directory without Tix locally installed." >&2
exit 0
fi
# Make paths absolute for later use.
SORTIX_PORTS_DIR=$(make_dir_path_absolute "$SORTIX_PORTS_DIR")
# Clean all the packages.
for PACKAGE in $("$(dirname -- "$0")"/list-packages.sh 'all!'); do
if [ "$1" = distclean ]; then
DEVELOPMENT=$(tix-vars -d false $SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE.port \
DEVELOPMENT)
if [ "$DEVELOPMENT" = true ]; then
case "$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE.version" in
*.development)
echo "Port is in development: '$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE'"
continue
;;
esac
fi
if [ -e "$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE" ]; then
echo "Removing '$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE'"
fi
rm -rf "$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE"
rm -rf "$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE.upstream"
rm -f "$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE.version"
rm -f "$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE.version.new"
fi
if [ -e "$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE.version" -o \
-e "$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE.version.new" ]; then
SOURCE_PORT=$(tix-vars -d '' $SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE.port \
SOURCE_PORT)
if [ -z "$SOURCE_PORT" ] ||
[ -e "$SORTIX_PORTS_DIR/$SOURCE_PORT/$SOURCE_PORT" ]; then
tix-build \
--sysroot="/" \
--prefix= \
--destination="/" \
--start=clean \
--end=clean \
${SOURCE_PORT:+--source-port "$SORTIX_PORTS_DIR/$SOURCE_PORT/$SOURCE_PORT"} \
"$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE"
fi
fi
done