fixup! Add ports to the Sortix repository.
This commit is contained in:
parent
fa1a0d8794
commit
e4cf6910a2
24
Makefile
24
Makefile
|
@ -228,6 +228,30 @@ endif
|
|||
grep -E '^/src(/.*)?$$' | \
|
||||
LC_ALL=C sort > "$(SYSROOT)/tix/manifest/src"
|
||||
|
||||
.PHONY: mirror
|
||||
mirror:
|
||||
@SORTIX_MIRROR_DIR="$(SORTIX_MIRROR_DIR)" \
|
||||
SORTIX_PORTS_DIR="$(SORTIX_PORTS_DIR)" \
|
||||
SORTIX_REPOSITORY_DIR="$(SORTIX_REPOSITORY_DIR)" \
|
||||
SORTIX_PORTS_MIRROR="$(SORTIX_PORTS_MIRROR)" \
|
||||
SYSROOT="$(SYSROOT)" \
|
||||
HOST="$(HOST)" \
|
||||
MAKE="$(MAKE)" \
|
||||
MAKEFLAGS="$(MAKEFLAGS)" \
|
||||
build-aux/build-ports.sh download
|
||||
|
||||
.PHONY: ports-extract
|
||||
ports-extract:
|
||||
@SORTIX_MIRROR_DIR="$(SORTIX_MIRROR_DIR)" \
|
||||
SORTIX_PORTS_DIR="$(SORTIX_PORTS_DIR)" \
|
||||
SORTIX_REPOSITORY_DIR="$(SORTIX_REPOSITORY_DIR)" \
|
||||
SORTIX_PORTS_MIRROR="$(SORTIX_PORTS_MIRROR)" \
|
||||
SYSROOT="$(SYSROOT)" \
|
||||
HOST="$(HOST)" \
|
||||
MAKE="$(MAKE)" \
|
||||
MAKEFLAGS="$(MAKEFLAGS)" \
|
||||
build-aux/build-ports.sh extract
|
||||
|
||||
.PHONY: sysroot-ports
|
||||
sysroot-ports: sysroot-fsh sysroot-base-headers sysroot-system sysroot-source
|
||||
@SORTIX_MIRROR_DIR="$(SORTIX_MIRROR_DIR)" \
|
||||
|
|
|
@ -8,6 +8,15 @@ has_command() {
|
|||
which "$1" > /dev/null
|
||||
}
|
||||
|
||||
# Determine what's supposed to happen.
|
||||
OPERATION=build
|
||||
if [ 1 -le $# ]; then OPERATION="$1"; fi
|
||||
case "$OPERATION" in
|
||||
download|extract|build) ;;
|
||||
*) echo "$0: error: Invalid operation: $OPERATION" >&2
|
||||
exit 1
|
||||
esac
|
||||
|
||||
# Detect if the environment isn't set up properly.
|
||||
if [ -z "$HOST" ]; then
|
||||
echo "$0: error: You need to set \$HOST" >&2
|
||||
|
@ -27,6 +36,8 @@ elif [ -z "$SORTIX_REPOSITORY_DIR" ]; then
|
|||
elif ! [ -d "$SORTIX_PORTS_DIR" ]; then
|
||||
echo "Warning: No ports directory found, third party software will not be built"
|
||||
exit 0
|
||||
elif [ "$OPERATION" != build ]; then
|
||||
: # tix isn't required for downloading and extracting
|
||||
elif ! has_command tix-collection ||
|
||||
! has_command tix-build ||
|
||||
! has_command tix-install; then
|
||||
|
@ -34,6 +45,9 @@ elif ! has_command tix-collection ||
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Load the ports sets.
|
||||
. "$(dirname -- "$0")/ports.conf"
|
||||
|
||||
# Create the mirror directory for downloaded archives.
|
||||
mkdir -p "$SORTIX_MIRROR_DIR"
|
||||
|
||||
|
@ -92,9 +106,52 @@ get_package_dependencies_raw() {(
|
|||
(BUILD_LIBRARIES= &&
|
||||
. $SORTIX_PORTS_DIR/$PACKAGE_DIR/$PACKAGE_DIR.info &&
|
||||
echo "$BUILD_LIBRARIES")
|
||||
else
|
||||
for set in $sets; do
|
||||
if [ $set = $1 ]; then
|
||||
echo $(eval echo \$set_$set)
|
||||
fi
|
||||
done
|
||||
fi
|
||||
)}
|
||||
|
||||
# Include the recursive dependencies if requested.
|
||||
# TODO: This algorithm scales extremely poorly.
|
||||
get_package_dependencies_recursive() {
|
||||
for DEPENDENCY in $(get_package_dependencies_raw $1); do
|
||||
WANT=false
|
||||
if [ "$2" = "!!" ]; then
|
||||
WANT=true
|
||||
else
|
||||
case "$DEPENDENCY" in
|
||||
*"?") ;;
|
||||
*) WANT=true ;;
|
||||
esac
|
||||
fi
|
||||
if $WANT; then
|
||||
DEPENDENCY=$(echo "$DEPENDENCY" | tr -d '?')
|
||||
PACKAGE_DIR=$(echo "$DEPENDENCY" | grep -Eo '^[^\.]*')
|
||||
# Optional dependencies might not exist yet.
|
||||
if [ -f "$SORTIX_PORTS_DIR/$PACKAGE_DIR/$PACKAGE_DIR.info" ]; then
|
||||
echo "$DEPENDENCY"
|
||||
get_package_dependencies_recursive "$DEPENDENCY" "$2"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
PACKAGES=$(for PACKAGE in $PACKAGES; do
|
||||
RECURSION=$(echo "$PACKAGE" | grep -Eo '!*$')
|
||||
PACKAGE=$(echo "$PACKAGE" | grep -Eo '^[^!]*')
|
||||
# TODO: Better way of detecting a port is a set.
|
||||
PACKAGE_DIR=$(echo "$PACKAGE" | grep -Eo '^[^\.]*')
|
||||
if [ -f "$SORTIX_PORTS_DIR/$PACKAGE_DIR/$PACKAGE_DIR.info" ]; then
|
||||
echo "$PACKAGE"
|
||||
fi
|
||||
if [ -n "$RECURSION" ]; then
|
||||
get_package_dependencies_recursive "$PACKAGE" "$RECURSION"
|
||||
fi
|
||||
done | sort -u | tr '\n' ' ')
|
||||
|
||||
# Detect the build-time dependencies for a package with missing optional
|
||||
# dependencies removed.
|
||||
get_package_dependencies() {(
|
||||
|
@ -155,6 +212,14 @@ strip_tix() {
|
|||
rm -rf "$DIR"
|
||||
}
|
||||
|
||||
announce() {
|
||||
cat << EOF
|
||||
================================================================================
|
||||
==== $1
|
||||
================================================================================
|
||||
EOF
|
||||
}
|
||||
|
||||
download_archive_from_url() {(
|
||||
PACKAGE="$1"
|
||||
ARCHIVE="$2"
|
||||
|
@ -162,6 +227,7 @@ download_archive_from_url() {(
|
|||
SHA256SUM="$4"
|
||||
mkdir -p "$SORTIX_MIRROR_DIR/$PACKAGE"
|
||||
if [ ! -e "$SORTIX_MIRROR_DIR/$PACKAGE/$ARCHIVE.sha256sum" ]; then
|
||||
announce "Downloading $1: $ARCHIVE"
|
||||
(if echo "$URL" | grep -Eq '^[a-z][a-z0-9.+-]*://'; then
|
||||
if ! wget -O "$SORTIX_MIRROR_DIR/$PACKAGE/$ARCHIVE.untrusted" -- "$URL"; then
|
||||
echo "warning: Failed to download $ARCHIVE from $URL" >&2
|
||||
|
@ -206,7 +272,7 @@ download_archive() {(
|
|||
fi
|
||||
)}
|
||||
|
||||
extract_package() {(
|
||||
download_package() {(
|
||||
PACKAGE="$1"
|
||||
unset ARCHIVE
|
||||
unset ARCHIVE_2
|
||||
|
@ -217,11 +283,21 @@ extract_package() {(
|
|||
download_archive "$PACKAGE" "$ARCHIVE_2" "$UPSTREAM_SITE_2" "$UPSTREAM_ARCHIVE_2" "$SHA256SUM_2"
|
||||
fi
|
||||
fi
|
||||
)}
|
||||
|
||||
extract_package() {(
|
||||
PACKAGE="$1"
|
||||
unset ARCHIVE
|
||||
unset ARCHIVE_2
|
||||
. "$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE.info"
|
||||
# TODO: Only reextract if actually needed.
|
||||
rm -rf "$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE"
|
||||
mkdir "$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE"
|
||||
if [ -n "$ARCHIVE" ]; then
|
||||
announce "Extracting $1: $ARCHIVE"
|
||||
tar -C "$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE" -xf "$SORTIX_MIRROR_DIR/$PACKAGE/$ARCHIVE" --strip-components=1
|
||||
if [ -n "$ARCHIVE_2" ]; then
|
||||
announce "Extracting $1: $ARCHIVE_2"
|
||||
tar -C "$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE" -xf "$SORTIX_MIRROR_DIR/$PACKAGE/$ARCHIVE_2" --strip-components=1
|
||||
fi
|
||||
fi
|
||||
|
@ -238,14 +314,28 @@ extract_package() {(
|
|||
|
||||
# Build all the packages (if needed) and otherwise install them.
|
||||
for PACKAGE in $PACKAGES; do
|
||||
SOURCE_PACKAGE=$( (SOURCE_PACKAGE= &&
|
||||
. $SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE.info &&
|
||||
echo "$SOURCE_PACKAGE") )
|
||||
# TODO: clean support.
|
||||
|
||||
# download
|
||||
if [ -n "$SOURCE_PACKAGE" ]; then
|
||||
download_package "$SOURCE_PACKAGE"
|
||||
fi
|
||||
download_package "$PACKAGE"
|
||||
if [ "$OPERATION" = download ]; then continue; fi
|
||||
|
||||
# extract
|
||||
if [ -n "$SOURCE_PACKAGE" ]; then
|
||||
extract_package "$SOURCE_PACKAGE"
|
||||
fi
|
||||
extract_package "$PACKAGE"
|
||||
if [ "$OPERATION" = extract ]; then continue; fi
|
||||
|
||||
# build
|
||||
if ! [ -f "$SORTIX_REPOSITORY_DIR/$PACKAGE.tix.tar.xz" ]; then
|
||||
SOURCE_PACKAGE=$( (SOURCE_PACKAGE= &&
|
||||
. $SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE.info &&
|
||||
echo "$SOURCE_PACKAGE") )
|
||||
if [ -n "$SOURCE_PACKAGE" ]; then
|
||||
extract_package "$SOURCE_PACKAGE"
|
||||
fi
|
||||
extract_package "$PACKAGE"
|
||||
announce "Building $1"
|
||||
tix-build \
|
||||
--sysroot="$SYSROOT" \
|
||||
--host=$HOST \
|
||||
|
@ -256,6 +346,7 @@ for PACKAGE in $PACKAGES; do
|
|||
"$SORTIX_PORTS_DIR/$PACKAGE/$PACKAGE"
|
||||
strip_tix "$SORTIX_REPOSITORY_DIR/$PACKAGE.tix.tar.xz"
|
||||
fi
|
||||
announce "Installing $1"
|
||||
tix-install \
|
||||
--collection="$SYSROOT" \
|
||||
--reinstall \
|
||||
|
|
Loading…
Reference in New Issue