Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 22 additions & 25 deletions pacman.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,28 @@ PACMAN_VERSION="5.2.1"
INSTALL_DIR="${PSPDEV}/share/pacman"
BASE_PATH="${PWD}"

## Only install if pacman is not available
if ! which "pacman" >/dev/null 2>&1; then
mkdir -p "${BASE_PATH}/build"
cd "${BASE_PATH}/build"
download_and_extract https://sources.archlinux.org/other/pacman/pacman-${PACMAN_VERSION}.tar.gz pacman-${PACMAN_VERSION}

## Apply temporary patch
## Will probably not be needed for the next version of pacman
apply_patch pacman-${PACMAN_VERSION}

## Install meson and ninja in the current directory
setup_build_system

## Build pacman
meson build
meson configure build -Dprefix="${PSPDEV}" --buildtype=release \
-Ddefault_library=static -Dbuildscript=PSPBUILD \
-Droot-dir="${PSPDEV}" -Dbindir="${PSPDEV}/share/pacman/bin" \
-Ddoc=disabled -Di18n=false
cd build
ninja

## Install
ninja install
fi
## Prepare the build environment
mkdir -p "${BASE_PATH}/build"
cd "${BASE_PATH}/build"
download_and_extract https://sources.archlinux.org/other/pacman/pacman-${PACMAN_VERSION}.tar.gz pacman-${PACMAN_VERSION}

## Apply patch
apply_patch pacman-${PACMAN_VERSION}

## Install meson and ninja in the current directory
setup_build_system

## Build pacman
meson build
meson configure build -Dprefix="${PSPDEV}" --buildtype=release \
-Ddefault_library=static -Dbuildscript=PSPBUILD \
-Droot-dir="${PSPDEV}" -Dbindir="${PSPDEV}/share/pacman/bin" \
-Ddoc=disabled -Di18n=false
cd build
ninja

## Install
ninja install

## Install configuration files and wrapper script
cd "${BASE_PATH}"
Expand Down
16 changes: 10 additions & 6 deletions scripts/psp-makepkg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

## Make sure PSPDEV is set
if [ -z "${PSPDEV}" ]; then
export PSPDEV=/usr/local/pspdev
echo "The PSPDEV environment variable has not been set"
exit 1
fi

if [ ! -d "${PSPDEV}" ]; then
echo "${PSPDEV} does not exist"
exit 2
fi

## Export makepkg variables
Expand All @@ -15,10 +21,8 @@ function strip {
}
export -f strip

## Use makepkg in $PSPDEV if needed
if ! which "makepkg" >/dev/null 2>&1; then
export PATH="${PSPDEV}/share/pacman/bin:${PATH}"
fi
## Add the directory with pacman's binaries to the start of the PATH
export PATH="${PSPDEV}/share/pacman/bin:${PATH}"

## Run makepkg
makepkg -p PSPBUILD "$@"
makepkg "$@"
31 changes: 17 additions & 14 deletions scripts/psp-pacman
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,32 @@

## Make sure PSPDEV is set
if [ -z "${PSPDEV}" ]; then
export PSPDEV=/usr/local/pspdev
echo "The PSPDEV environment variable has not been set"
exit 1
fi

if [ ! -d "${PSPDEV}" ]; then
echo "${PSPDEV} does not exist"
exit 1
exit 2
fi

## Use sudo if the current user doesn't own $PSPDEV
if ! touch "${PSPDEV}" >/dev/null 2>&1; then
## And only when not using the T or Q option
if ! [[ $1 = -@(T|Q|V|h)*([[:alpha:]]) ]] && ! [[ $1 = --@(deptest|query|help|version)*([[:alpha:]]) ]]; then
sudo "$0" "$@"
exit $?
fi
sudo PSPDEV="${PSPDEV}" "$0" "$@"
exit $?
fi

## Use pacman in $PSPDEV if needed
if ! which "pacman" >/dev/null 2>&1; then
export PATH="${PSPDEV}/share/pacman/bin:${PATH}"
fi
## Add the directory with pacman's binaries to the start of the PATH
export PATH="${PSPDEV}/share/pacman/bin:${PATH}"

## Run pacman
pacman --root "${PSPDEV}" \
## Run pacman and make sure to use the current PSPDEV
pacman \
--root "${PSPDEV}" \
--dbpath "${PSPDEV}/var/lib/pacman" \
--config "${PSPDEV}/etc/pacman.conf" "$@"
--config "${PSPDEV}/etc/pacman.conf" \
--cachedir "${PSPDEV}/var/cache/pacman/pkg" \
--gpgdir "${PSPDEV}/etc/pacman.d/gnupg/" \
--logfile "${PSPDEV}/var/log/pacman.log" \
--hookdir "${PSPDEV}/share/libalpm/hooks" \
--hookdir "${PSPDEV}/etc/pacman.d/hooks" \
"$@"