Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get -y install autoconf automake bison flex gcc libelf-dev make texinfo libncurses5-dev patch python3 python-is-python3 subversion wget zlib1g-dev libtool-bin python3-dev bzip2 libgmp3-dev pkg-config
sudo apt-get -y install autoconf automake bison flex gcc libelf-dev make texinfo libncurses5-dev patch python3 python-is-python3 subversion wget zlib1g-dev libtool-bin python3-dev bzip2 libgmp3-dev pkg-config pv

- name: Runs all the stages in the shell
run: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
build/
.idea/**
downloads/
ps3dev/
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN \
apt-get -y install \
autoconf bison build-essential ca-certificates flex git libelf-dev\
libgmp-dev libncurses5-dev libssl-dev libtool-bin pkg-config python-dev-is-python3 \
texinfo wget zlib1g-dev && \
texinfo wget zlib1g-dev pv && \
apt-get -y clean autoclean autoremove && \
rm -rf /var/lib/{apt,dpkg,cache,log}/

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

autoconf, automake, bison, flex, gcc, libelf, make, makeinfo,
ncurses, patch, python, subversion, wget, zlib, libtool, python,
bzip2, gmp, pkg-config, g++, libssl-dev, clang
bzip2, gmp, pkg-config, g++, libssl-dev, clang, pv

### Linux

Expand Down
3 changes: 3 additions & 0 deletions depends/check-pv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

( pv -V ) 1>/dev/null 2>&1 || { echo "ERROR: Install pv before continuing."; exit 1; }
10 changes: 8 additions & 2 deletions depends/check-python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
( python --version || python -V ) 1>/dev/null 2>&1 || { echo "ERROR: Install python before continuing."; exit 1; }

## Check for python-config
pyprefix=$(python-config --prefix || python3-config --prefix)
[ $? -eq 0 ] || { echo "ERROR: Install python-dev before continuing."; exit 1; }
if command -v python-config >/dev/null 2>&1; then
pyprefix=$(python-config --prefix)
elif command -v python3-config >/dev/null 2>&1; then
pyprefix=$(python3-config --prefix)
else
echo "Neither python-config nor python3-config found" >&2
exit 1
fi

## Check for python header files
( ls -1d "${pyprefix}"/include/python[23].*/Python.h || ls -1d /opt/local/include/python[23].*/Python.h ) 1>/dev/null 2>&1 || [ -f "$PYINSTALLDIR/include/Python.h" ] || { echo "ERROR: Install python-dev before continuing."; exit 1; }
5 changes: 5 additions & 0 deletions download-manifest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
https://ftpmirror.gnu.org/binutils/binutils-2.22.tar.bz2 binutils-2.22.tar.bz2 6c7af8ed1c8cf9b4b9d6e6fe09a3e1d3d479fe63984ba8b9b26bf356b6313ca9
https://ftpmirror.gnu.org/gnu/gcc/gcc-7.2.0/gcc-7.2.0.tar.xz gcc-7.2.0.tar.xz 1cf7adf8ff4b5aa49041c8734bbcf1ad18cc4c94d0029aae0f4e48841088479a
https://sourceware.org/pub/newlib/newlib-1.20.0.tar.gz newlib-1.20.0.tar.gz c644b2847244278c57bec2ddda69d8fab5a7c767f3b9af69aa7aa3da823ff692
https://github.com/ps3dev/PSL1GHT/tarball/master psl1ght-master.tar.gz
https://github.com/ps3dev/ps3libraries/tarball/master ps3libraries-master.tar.gz
65 changes: 65 additions & 0 deletions scripts/000-download-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash
set -euo pipefail

MANIFEST="../download-manifest.txt"
DOWNLOAD_DIR="../downloads"

echo "Downloading files to ${DOWNLOAD_DIR}"

mkdir -p "$DOWNLOAD_DIR"

while IFS= read -r line || [[ -n "$line" ]]; do
# handle Windows line endings
line="${line%$'\r'}"

# skip blanks/comments
[[ -z "$line" || "$line" == \#* ]] && continue

url=$(awk '{print $1}' <<< "$line")
filename=$(awk '{print $2}' <<< "$line")
expected_sha=$(awk '{print $3}' <<< "$line")

filepath="$DOWNLOAD_DIR/$filename"
tmpfile="${filepath}.tmp"

# URL + filename only → always download
if [[ -z "${expected_sha:-}" ]]; then
echo "No SHA provided, force downloading: $filepath"
curl -L -o "$tmpfile" "$url"
mv "$tmpfile" "$filepath"
echo "Downloaded: $filepath"
continue
fi

# SHA mode → cache check
if [[ -f "$filepath" ]]; then
actual_sha=$(sha256sum "$filepath" | awk '{print $1}')

if [[ "$actual_sha" == "$expected_sha" ]]; then
echo "OK (cached): $filepath"
continue
else
echo "SHA mismatch, re-downloading: $filepath"
fi
else
echo "Missing file, downloading: $filepath"
fi

curl -L -o "$tmpfile" "$url"

actual_sha=$(sha256sum "$tmpfile" | awk '{print $1}')

if [[ "$actual_sha" == "$expected_sha" ]]; then
mv "$tmpfile" "$filepath"
echo "OK: $filepath"
else
echo "FAIL: $filepath"
echo "Expected: $expected_sha"
echo "Got: $actual_sha"
rm -f "$tmpfile"
exit 1
fi

done < "$MANIFEST"

echo "All files verified."
12 changes: 3 additions & 9 deletions scripts/001-binutils-PPU.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,15 @@ BINUTILS="binutils-2.22"

if [ ! -d ${BINUTILS} ]; then

## Download the source code.
if [ ! -f ${BINUTILS}.tar.bz2 ]; then wget --continue https://ftpmirror.gnu.org/binutils/${BINUTILS}.tar.bz2; fi

## Download an up-to-date config.guess and config.sub
if [ ! -f config.guess ]; then wget --continue https://git.savannah.gnu.org/cgit/config.git/plain/config.guess; fi
if [ ! -f config.sub ]; then wget --continue https://git.savannah.gnu.org/cgit/config.git/plain/config.sub; fi

## Unpack the source code.
tar xfvj ${BINUTILS}.tar.bz2
echo "Unpacking ${BINUTILS}"
pv -pterab ../downloads/${BINUTILS}.tar.bz2 | tar xjf -

## Patch the source code.
cat ../patches/${BINUTILS}-PS3.patch | patch -p1 -d ${BINUTILS}

## Replace config.guess and config.sub
cp config.guess config.sub ${BINUTILS}
cp "$(automake --print-libdir)"/config.guess "$(automake --print-libdir)"/config.sub ${BINUTILS}

fi

Expand Down
10 changes: 4 additions & 6 deletions scripts/002-gcc-newlib-PPU.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ NEWLIB="newlib-1.20.0"

if [ ! -d ${GCC} ]; then

## Download the source code.
if [ ! -f ${GCC}.tar.xz ]; then wget --continue https://ftpmirror.gnu.org/gnu/gcc/${GCC}/${GCC}.tar.xz; fi
if [ ! -f ${NEWLIB}.tar.gz ]; then wget --continue https://sourceware.org/pub/newlib/${NEWLIB}.tar.gz; fi

## Unpack the source code.
rm -Rf ${GCC} && tar xfvJ ${GCC}.tar.xz
rm -Rf ${NEWLIB} && tar xfvz ${NEWLIB}.tar.gz
echo "Unpacking ${GCC}"
pv -pterab ../downloads/${GCC}.tar.xz | tar xJf -
echo "Unpacking ${NEWLIB}"
pv -pterab ../downloads/${NEWLIB}.tar.gz | tar xzf -

## Patch the source code.
cat ../patches/${GCC}-PS3.patch | patch -p1 -d ${GCC}
Expand Down
12 changes: 3 additions & 9 deletions scripts/005-binutils-SPU.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,15 @@ BINUTILS="binutils-2.22"

if [ ! -d ${BINUTILS} ]; then

## Download the source code.
if [ ! -f ${BINUTILS}.tar.bz2 ]; then wget --continue https://ftpmirror.gnu.org/binutils/${BINUTILS}.tar.bz2; fi

## Download an up-to-date config.guess and config.sub
if [ ! -f config.guess ]; then wget --continue https://git.savannah.gnu.org/cgit/config.git/plain/config.guess; fi
if [ ! -f config.sub ]; then wget --continue https://git.savannah.gnu.org/cgit/config.git/plain/config.sub; fi

## Unpack the source code.
tar xfvj ${BINUTILS}.tar.bz2
echo "Unpacking ${BINUTILS}"
pv -pterab ../downloads/${BINUTILS}.tar.bz2 | tar xjf -

## Patch the source code.
cat ../patches/${BINUTILS}-PS3.patch | patch -p1 -d ${BINUTILS}

## Replace config.guess and config.sub
cp config.guess config.sub ${BINUTILS}
cp "$(automake --print-libdir)"/config.guess "$(automake --print-libdir)"/config.sub ${BINUTILS}

fi

Expand Down
10 changes: 4 additions & 6 deletions scripts/006-gcc-newlib-SPU.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ NEWLIB="newlib-1.20.0"

if [ ! -d ${GCC} ]; then

## Download the source code.
if [ ! -f ${GCC}.tar.xz ]; then wget --continue https://ftpmirror.gnu.org/gnu/gcc/${GCC}/${GCC}.tar.xz; fi
if [ ! -f ${NEWLIB}.tar.gz ]; then wget --continue https://sourceware.org/pub/newlib/${NEWLIB}.tar.gz; fi

## Unpack the source code.
rm -Rf ${GCC} && tar xfvJ ${GCC}.tar.xz
rm -Rf ${NEWLIB} && tar xfvz ${NEWLIB}.tar.gz
echo "Unpacking ${GCC}"
pv -pterab ../downloads/${GCC}.tar.xz | tar xJf -
echo "Unpacking ${NEWLIB}"
pv -pterab ../downloads/${NEWLIB}.tar.gz | tar xzf -

## Patch the source code.
cat ../patches/${GCC}-PS3.patch | patch -p1 -d ${GCC}
Expand Down
8 changes: 4 additions & 4 deletions scripts/008-psl1ght.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/sh -e
# psl1ght.sh by Naomi Peori (naomi@peori.ca)

## Download the source code.
wget --no-check-certificate https://github.com/ps3dev/PSL1GHT/tarball/master -O psl1ght.tar.gz

## Unpack the source code.
rm -Rf psl1ght && mkdir psl1ght && tar --strip-components=1 --directory=psl1ght -xvzf psl1ght.tar.gz
rm -Rf psl1ght
mkdir psl1ght
echo "Unpacking psl1ght"
pv -pterb ../downloads/psl1ght-master.tar.gz | tar --strip-components=1 --directory=psl1ght -xzf -

## Create the build directory.
cd psl1ght
Expand Down
22 changes: 19 additions & 3 deletions scripts/009-ps3libraries.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
#!/bin/sh -e
# ps3libraries.sh by Naomi Peori (naomi@peori.ca)

## Download the source code.
wget --no-check-certificate https://github.com/ps3dev/ps3libraries/tarball/master -O ps3libraries.tar.gz
CACHE_DIR="ps3libraries-temp-download-cache"
DOWNLOADS_DIR="ps3libraries/downloads"

## Preserve download cache
if [ -d "$DOWNLOADS_DIR" ]; then
cp -r "$DOWNLOADS_DIR" "$CACHE_DIR"
fi

## Unpack the source code.
rm -Rf ps3libraries && mkdir ps3libraries && tar --strip-components=1 --directory=ps3libraries -xvzf ps3libraries.tar.gz && cd ps3libraries
rm -Rf ps3libraries
mkdir ps3libraries
echo "Unpacking ps3libraries"
pv -pterb ../downloads/ps3libraries-master.tar.gz | tar --strip-components=1 --directory=ps3libraries -xzf -

## Restore download cache
if [ -d "$CACHE_DIR" ]; then
mkdir -p "$DOWNLOADS_DIR"
cp -r "$CACHE_DIR/." "$DOWNLOADS_DIR/"
fi

cd ps3libraries

## Compile and install.
./libraries.sh
18 changes: 13 additions & 5 deletions toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ mkdir -p build && cd build || { echo "ERROR: Could not create the build director
## Use gmake if available
which gmake 1>/dev/null 2>&1 && export MAKE=gmake

## Fetch the depend scripts.
DEPEND_SCRIPTS=`ls ../depends/*.sh | sort`

## Run all the depend scripts.
for SCRIPT in $DEPEND_SCRIPTS; do "$SCRIPT" || { echo "$SCRIPT: Failed."; exit 1; } done
failed=0
for SCRIPT in $(ls ../depends/*.sh | sort); do
"$SCRIPT" || {
echo "$SCRIPT: Failed."
failed=1
}
done
[ "$failed" -ne 0 ] && exit "$failed"

## Fetch the build scripts.
BUILD_SCRIPTS=`ls ../scripts/*.sh | sort`
Expand All @@ -28,6 +32,7 @@ if [ $1 ]; then
for STEP in $@; do
SCRIPT=""
for i in $BUILD_SCRIPTS; do
echo ">>> Running: $SCRIPT"
if [ `basename $i | cut -d'-' -f1` -eq $STEP ]; then
SCRIPT=$i
break
Expand All @@ -44,4 +49,7 @@ if [ $1 ]; then
fi

## Run the build scripts.
for SCRIPT in $BUILD_SCRIPTS; do "$SCRIPT" || { echo "$SCRIPT: Failed."; exit 1; } done
for SCRIPT in $BUILD_SCRIPTS; do
echo ">>> Running: $SCRIPT"
"$SCRIPT" || { echo "$SCRIPT: Failed."; exit 1; }
done