mirror of
https://github.com/chocolate-doom/chocpkg.git
synced 2024-11-10 07:11:39 +00:00
Remove pinning of a package to a PACKAGE_TYPE.
Previously a particular package could only ever be installed to target or native. Instead, allow any package to be installed to either, with target being the default. Native packages can only ever have native dependencies, but target packages can depend on native ones in order to install tools which they need for their build process.
This commit is contained in:
parent
e6a0dfda11
commit
14bef92feb
7 changed files with 45 additions and 28 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
||||||
build
|
build
|
||||||
|
build.native
|
||||||
install
|
install
|
||||||
install.native
|
install.native
|
||||||
packages
|
packages
|
||||||
|
|
|
@ -36,12 +36,15 @@ basic_setup() {
|
||||||
PATH="$CHOCPKG_ROOT/chocpkg:$PATH"
|
PATH="$CHOCPKG_ROOT/chocpkg:$PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
PACKAGES_DIR="$CHOCPKG_ROOT/packages"
|
||||||
INSTALL_DIR="$CHOCPKG_ROOT/install"
|
INSTALL_DIR="$CHOCPKG_ROOT/install"
|
||||||
NATIVE_INSTALL_DIR="$CHOCPKG_ROOT/install.native"
|
NATIVE_INSTALL_DIR="$CHOCPKG_ROOT/install.native"
|
||||||
PACKAGES_DIR="$CHOCPKG_ROOT/packages"
|
|
||||||
BUILD_DIR="$CHOCPKG_ROOT/build"
|
BUILD_DIR="$CHOCPKG_ROOT/build"
|
||||||
|
NATIVE_BUILD_DIR="$CHOCPKG_ROOT/build.native"
|
||||||
|
|
||||||
mkdir -p "$INSTALL_DIR" "$NATIVE_INSTALL_DIR" "$PACKAGES_DIR" "$BUILD_DIR"
|
mkdir -p "$PACKAGES_DIR" \
|
||||||
|
"$INSTALL_DIR" "$NATIVE_INSTALL_DIR" \
|
||||||
|
"$BUILD_DIR" "$NATIVE_BUILD_DIR"
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_setup
|
basic_setup
|
||||||
|
@ -58,33 +61,55 @@ dependencies() {
|
||||||
DEPENDENCIES+=" $*"
|
DEPENDENCIES+=" $*"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dependencies_for_native() {
|
||||||
|
for dep in $DEPENDENCIES; do
|
||||||
|
if [[ "$PACKAGE_TYPE" = native ]] && ! [[ "$dep" =~ native: ]]; then
|
||||||
|
echo "native:$dep"
|
||||||
|
else
|
||||||
|
echo "$dep"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# Given a package name, find the pkgdef file associated with it, source
|
# Given a package name, find the pkgdef file associated with it, source
|
||||||
# the contents of the file and set various variables.
|
# the contents of the file and set various variables.
|
||||||
configure_for_package() {
|
configure_for_package() {
|
||||||
local package=$1
|
local package=$1
|
||||||
|
PACKAGE_NAME=$package
|
||||||
|
|
||||||
|
# Detect native: prefix and set package type.
|
||||||
|
if [[ "$package" =~ ^native: ]]; then
|
||||||
|
PACKAGE_TYPE=native
|
||||||
|
package=${package/#native:/}
|
||||||
|
else
|
||||||
|
PACKAGE_TYPE=target
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Defaults before loading package file.
|
||||||
|
PACKAGE_DESCRIPTION="Package $package"
|
||||||
|
DEPENDENCIES=""
|
||||||
|
PACKAGE_DIR_NAME=$package
|
||||||
|
|
||||||
local pkg_file="$CHOCPKG_ROOT/pkgdef/$package.sh"
|
local pkg_file="$CHOCPKG_ROOT/pkgdef/$package.sh"
|
||||||
if [ ! -e "$pkg_file" ]; then
|
if [ ! -e "$pkg_file" ]; then
|
||||||
error_exit "Package file $package.sh not found."
|
error_exit "Package file $package.sh not found."
|
||||||
fi
|
fi
|
||||||
# Defaults for package unless overridden:
|
|
||||||
PACKAGE_NAME=$package
|
|
||||||
PACKAGE_DIR_NAME=$package
|
|
||||||
PACKAGE_TYPE=target
|
|
||||||
PACKAGE_DESCRIPTION="Package $PACKAGE_NAME"
|
|
||||||
DEPENDENCIES=""
|
|
||||||
. "$pkg_file"
|
. "$pkg_file"
|
||||||
|
|
||||||
PACKAGE_BUILD_DIR="$BUILD_DIR/$PACKAGE_DIR_NAME"
|
|
||||||
|
|
||||||
# We set up build differently depending on the package type: some packages
|
# We set up build differently depending on the package type: some packages
|
||||||
# are for the target we're building for; others are native tools to run on
|
# are for the target we're building for; others are native tools to run on
|
||||||
# the build machine as part of the build process.
|
# the build machine as part of the build process.
|
||||||
case "$PACKAGE_TYPE" in
|
case "$PACKAGE_TYPE" in
|
||||||
target)
|
target)
|
||||||
PACKAGE_INSTALL_DIR="$INSTALL_DIR"
|
PACKAGE_INSTALL_DIR="$INSTALL_DIR"
|
||||||
|
PACKAGE_BUILD_DIR="$BUILD_DIR/$PACKAGE_DIR_NAME"
|
||||||
;;
|
;;
|
||||||
native)
|
native)
|
||||||
PACKAGE_INSTALL_DIR="$NATIVE_INSTALL_DIR"
|
PACKAGE_INSTALL_DIR="$NATIVE_INSTALL_DIR"
|
||||||
|
PACKAGE_BUILD_DIR="$NATIVE_BUILD_DIR/$PACKAGE_DIR_NAME"
|
||||||
|
# When installing a native package, all its dependencies are
|
||||||
|
# necessarily native as well.
|
||||||
|
DEPENDENCIES=$(dependencies_for_native)
|
||||||
;;
|
;;
|
||||||
package-group)
|
package-group)
|
||||||
;;
|
;;
|
||||||
|
@ -197,7 +222,6 @@ cmd_packages() {
|
||||||
package_info() {
|
package_info() {
|
||||||
printf "package: %s\n" "$PACKAGE_NAME"
|
printf "package: %s\n" "$PACKAGE_NAME"
|
||||||
printf "description: %s\n" "$PACKAGE_DESCRIPTION"
|
printf "description: %s\n" "$PACKAGE_DESCRIPTION"
|
||||||
printf "type: %s\n" "$PACKAGE_TYPE"
|
|
||||||
|
|
||||||
printf "installed: "
|
printf "installed: "
|
||||||
if chocpkg installed "$PACKAGE_NAME"; then
|
if chocpkg installed "$PACKAGE_NAME"; then
|
||||||
|
|
|
@ -4,7 +4,7 @@ check_pkgconfig::init() {
|
||||||
|
|
||||||
# If we're using pkg-config to check, we need to install pkg-config
|
# If we're using pkg-config to check, we need to install pkg-config
|
||||||
# first.
|
# first.
|
||||||
dependencies pkg-config
|
dependencies native:pkg-config
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function that returns true if the package is installed.
|
# Function that returns true if the package is installed.
|
||||||
|
|
|
@ -26,7 +26,9 @@ extract_package_file() {
|
||||||
mkdir -p "$PACKAGE_BUILD_DIR"
|
mkdir -p "$PACKAGE_BUILD_DIR"
|
||||||
cd "$PACKAGE_BUILD_DIR"
|
cd "$PACKAGE_BUILD_DIR"
|
||||||
else
|
else
|
||||||
cd "$BUILD_DIR"
|
local parent_dir=$(dirname "$PACKAGE_BUILD_DIR")
|
||||||
|
echo "cd to $parent_dir">/dev/stderr
|
||||||
|
cd "$parent_dir"
|
||||||
fi
|
fi
|
||||||
(gunzip < "$dlfile" | tar -x) || (
|
(gunzip < "$dlfile" | tar -x) || (
|
||||||
mv "$dlfile" "$dlfile.bad"
|
mv "$dlfile" "$dlfile.bad"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
package_group::init() {
|
package_group::init() {
|
||||||
PACKAGE_TYPE=package-group
|
PACKAGE_TYPE=package-group
|
||||||
PKGGRP_PACKAGES="$*"
|
dependencies "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
do_fetch() {
|
do_fetch() {
|
||||||
|
@ -18,20 +18,20 @@ do_build() {
|
||||||
# Installing a package group means installing all its packages; we don't
|
# Installing a package group means installing all its packages; we don't
|
||||||
# trigger the build step like 'install' usually does (we don't have one).
|
# trigger the build step like 'install' usually does (we don't have one).
|
||||||
cmd_install() {
|
cmd_install() {
|
||||||
for package in $PKGGRP_PACKAGES; do
|
for package in $DEPENDENCIES; do
|
||||||
chocpkg install "$package"
|
chocpkg install "$package"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Reinstalling a package group means reinstalling *all* its packages.
|
# Reinstalling a package group means reinstalling *all* its packages.
|
||||||
cmd_reinstall() {
|
cmd_reinstall() {
|
||||||
for package in $PKGGRP_PACKAGES; do
|
for package in $DEPENDENCIES; do
|
||||||
chocpkg reinstall "$package"
|
chocpkg reinstall "$package"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_dependencies() {
|
cmd_dependencies() {
|
||||||
for package in $PKGGRP_PACKAGES; do
|
for package in $DEPENDENCIES; do
|
||||||
echo "$package"
|
echo "$package"
|
||||||
chocpkg dependencies "$package"
|
chocpkg dependencies "$package"
|
||||||
done | sort | uniq
|
done | sort | uniq
|
||||||
|
@ -39,7 +39,7 @@ cmd_dependencies() {
|
||||||
|
|
||||||
# Package group is installed if all its packages are installed.
|
# Package group is installed if all its packages are installed.
|
||||||
cmd_installed() {
|
cmd_installed() {
|
||||||
for package in $PKGGRP_PACKAGES; do
|
for package in $DEPENDENCIES; do
|
||||||
chocpkg installed "$package"
|
chocpkg installed "$package"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,15 +95,6 @@ dependencies other-package neato-lib
|
||||||
package_group neato-lib dumbo-lib
|
package_group neato-lib dumbo-lib
|
||||||
```
|
```
|
||||||
|
|
||||||
## Variables
|
|
||||||
|
|
||||||
* `PACKAGE_TYPE`: has a value of either `native` or `target`. The
|
|
||||||
default is `target`. The variable controls whether the package is
|
|
||||||
built for the target system when doing cross-compiles, or whether it
|
|
||||||
is part of the build (native) system and just used to build tools as
|
|
||||||
part of the build process. The package type determines whether the
|
|
||||||
result is installed into `install` or `install.native`.
|
|
||||||
|
|
||||||
## Advanced builds
|
## Advanced builds
|
||||||
|
|
||||||
Complicated packages can require custom build steps. The following functions
|
Complicated packages can require custom build steps. The following functions
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
PACKAGE_TYPE=native
|
|
||||||
description "Development tool for locating installed packages and libraries"
|
description "Development tool for locating installed packages and libraries"
|
||||||
check_tool pkg-config
|
check_tool pkg-config
|
||||||
fetch_download https://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz
|
fetch_download https://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz
|
||||||
|
|
Loading…
Reference in a new issue