diff --git a/.github/workflows/build_push.yaml b/.github/workflows/build_push.yaml new file mode 100644 index 000000000..3a0eed830 --- /dev/null +++ b/.github/workflows/build_push.yaml @@ -0,0 +1,102 @@ +name: CI + +on: + push: + branches: + - 'master' + pull_request: + branches: + - '*' + workflow_dispatch: + +jobs: + ShellCheck: + name: Shellcheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: ShellCheck Depends + uses: ludeeus/action-shellcheck@master + Docker: + name: Docker + runs-on: ubuntu-latest + needs: ShellCheck + steps: + - name: Make Space + run: | + sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android + sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET + - name: Checkout + if: success() + id: checkout + uses: actions/checkout@v2 + - name: Set up QEMU + if: success() + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + if: success() + id: buildx + uses: docker/setup-buildx-action@v1 + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + - name: Prepare + if: success() + id: prepare + run: | + echo ::set-output name=docker_platforms::linux/amd64,linux/386 + VERSION_TAG=${GITHUB_REF#refs/*/} + echo ::set-output name=version::${VERSION_TAG%/merge} +# - name: Login to DockerHub +# if: success() +# id: login_docker +# uses: docker/login-action@v1 +# with: +# username: ${{ secrets.DOCKER_USERNAME }} +# password: ${{ secrets.DOCKER_PASSWORD }} + - name: Login to GitHub Container Registry + if: success() + id: login_github + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push (master) + if: success() && steps.prepare.outputs.version == 'master' && github.event_name != 'pull_request' + id: build_push_master + uses: docker/build-push-action@v2 + with: + context: . + platforms: ${{ steps.prepare.outputs.docker_platforms }} + push: true + tags: | + ghcr.io/ps3dev/ps3dev:master + ghcr.io/ps3dev/ps3dev:latest +# ps3dev/ps3dev:master +# ps3dev/ps3dev:latest + - name: Build and push (development) + if: success() && steps.prepare.outputs.version != 'master' + id: build_push_development + uses: docker/build-push-action@v2 + with: + context: . + platforms: ${{ steps.prepare.outputs.docker_platforms }} + push: true + tags: | + ghcr.io/ps3dev/ps3dev:${{ steps.prepare.outputs.version }} +# ps3dev/ps3dev:${{ steps.prepare.outputs.version }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + - name: Move cache + if: success() + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache diff --git a/.github/workflows/delete_old.yaml b/.github/workflows/delete_old.yaml new file mode 100644 index 000000000..b75bf9296 --- /dev/null +++ b/.github/workflows/delete_old.yaml @@ -0,0 +1,19 @@ +name: Delete old workflow runs +on: + workflow_dispatch: + inputs: + days: + description: 'Number of days.' + required: true + default: 90 + +jobs: + del_runs: + runs-on: ubuntu-latest + steps: + - name: Delete workflow runs + uses: Mattraks/delete-workflow-runs@main + with: + token: ${{ secrets.GITHUB_TOKEN }} + repository: ${{ github.repository }} + retain_days: ${{ github.event.inputs.days }} diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml deleted file mode 100644 index 42302dcda..000000000 --- a/.github/workflows/deploy.yaml +++ /dev/null @@ -1,68 +0,0 @@ -name: Build toolchain docker image - -on: - push: - branches: - - '*' - pull_request: - branches: - - '*' - -jobs: - Docker: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 1 - persist-credentials: false - - name: Set up Docker Buildx - if: success() - id: buildx - uses: crazy-max/ghaction-docker-buildx@v3 - with: - buildx-version: latest - qemu-version: latest - - name: Prepare - if: success() - id: prepare - run: | - echo ::set-output name=docker_platforms::linux/amd64,linux/386 - echo ::set-output name=docker_username::miigotu - echo ::set-output name=github_image::docker.pkg.github.com/${GITHUB_REPOSITORY,,}/ps3dev - VERSION_TAG=${GITHUB_REF#refs/*/} - echo ::set-output name=version::${VERSION_TAG%/merge} - - name: Available platforms - if: success() - run: echo ${{ steps.buildx.outputs.platforms }} - - name: Docker Login and set build command - if: success() - id: login - env: - GITHUB_PASSWORD: ${{ secrets.GITHUB_TOKEN }} - run: | - echo "${GITHUB_PASSWORD}" | docker login --username "${{ steps.prepare.outputs.docker_username }}" --password-stdin docker.pkg.github.com - echo ::set-output name=buildx::$(echo docker buildx build --output type=image,name=${{ steps.prepare.outputs.github_image }},push=true \ - --platform ${{ steps.prepare.outputs.docker_platforms }} --cache-from "type=local,src=/tmp/.buildx-cache" --cache-to "type=local,dest=/tmp/.buildx-cache" \ - --tag "${{ steps.prepare.outputs.github_image }}:${{ steps.prepare.outputs.version }}") - - name: Cache Docker layers - uses: actions/cache@v2 - id: cache - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ steps.prepare.outputs.version }} - restore-keys: | - ${{ runner.os }}-buildx- - - name: Run Buildx (master) - if: success() && steps.prepare.outputs.version == 'master' && github.event_name != 'pull_request' - run: | - ${{ steps.login.outputs.buildx }} --tag "${{ steps.prepare.outputs.github_image }}:latest" --file Dockerfile . - - name: Run Buildx (non-master) - if: success() && steps.prepare.outputs.version != 'master' && github.event_name != 'pull_request' - run: | - ${{ steps.login.outputs.buildx }} --file Dockerfile . - - name: Clear - if: always() - run: | - rm -rf ${HOME}/.docker/config.json diff --git a/Dockerfile b/Dockerfile index 4052d3d62..fa17fa2a1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:xenial +FROM debian:buster-slim LABEL maintainer="miigotu@gmail.com" ENV PS3DEV /usr/local/ps3dev @@ -9,9 +9,9 @@ ENV DEBIAN_FRONTEND=noninteractive RUN \ apt-get -y update && \ - 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 \ + apt-get -y install libgmp-dev \ + autoconf bison build-essential ca-certificates flex git libelf-dev \ + libncurses5-dev libssl-dev libtool-bin pkg-config python-dev \ texinfo wget zlib1g-dev && \ apt-get -y clean autoclean autoremove && \ rm -rf /var/lib/{apt,dpkg,cache,log}/ diff --git a/depends/check-autoconf.sh b/depends/check-autoconf.sh index 2b42e340e..4312b56d1 100755 --- a/depends/check-autoconf.sh +++ b/depends/check-autoconf.sh @@ -2,4 +2,6 @@ # check-autoconf.sh by Naomi Peori (naomi@peori.ca) ## Check for autoconf. -autoconf --version 1>/dev/null 2>&1|| { echo "ERROR: Install autoconf before continuing."; exit 1; } +autoconf --version 1>/dev/null 2>&1 || +{ echo "ERROR: Install autoconf before continuing."; exit 1; } +# sudo apt-get install autoconf \ No newline at end of file diff --git a/depends/check-automake.sh b/depends/check-automake.sh index ad0fcaf76..934b9ca41 100755 --- a/depends/check-automake.sh +++ b/depends/check-automake.sh @@ -2,4 +2,6 @@ # check-automake.sh by Naomi Peori (naomi@peori.ca) ## Check for automake. -automake --version 1>/dev/null 2>&1 || { echo "ERROR: Install automake before continuing."; exit 1; } +automake --version 1>/dev/null 2>&1 || +{ echo "ERROR: Install automake before continuing."; exit 1; } +# sudo apt-get install automake \ No newline at end of file diff --git a/depends/check-bison.sh b/depends/check-bison.sh index b13a4a2df..4c6415d47 100755 --- a/depends/check-bison.sh +++ b/depends/check-bison.sh @@ -1,4 +1,6 @@ #!/bin/sh # check-bison.sh by Naomi Peori (naomi@peori.ca) -( bison -V || yacc -V ) 1>/dev/null 2>&1 || { echo "ERROR: Install bison before continuing."; exit 1; } +( bison -V || yacc -V ) 1>/dev/null 2>&1 || +{ echo "ERROR: Install bison before continuing."; exit 1; } +# sudo apt-get install bison \ No newline at end of file diff --git a/depends/check-flex.sh b/depends/check-flex.sh index 42ff2283d..f2ecbf34b 100755 --- a/depends/check-flex.sh +++ b/depends/check-flex.sh @@ -2,4 +2,6 @@ # check-flex.sh by Naomi Peori (naomi@peori.ca) ## Check for flex. -flex --version 1>/dev/null 2>&1 || { echo "ERROR: Install flex before continuing."; exit 1; } +flex --version 1>/dev/null 2>&1 || +{ echo "ERROR: Install flex before continuing."; exit 1; } +# sudo apt-get install flex \ No newline at end of file diff --git a/depends/check-gcc.sh b/depends/check-gcc.sh index 01a911670..8688041f7 100755 --- a/depends/check-gcc.sh +++ b/depends/check-gcc.sh @@ -2,4 +2,6 @@ # check-gcc.sh by Naomi Peori (naomi@peori.ca) ## Check for gcc. -gcc --version 1>/dev/null 2>&1 || { echo "ERROR: Install gcc before continuing."; exit 1; } +gcc --version 1>/dev/null 2>&1 || +{ echo "ERROR: Install gcc before continuing."; exit 1; } +# sudo apt-get install gcc \ No newline at end of file diff --git a/depends/check-gmp.sh b/depends/check-gmp.sh index a7ae9cfb9..2c4b6c260 100755 --- a/depends/check-gmp.sh +++ b/depends/check-gmp.sh @@ -1,4 +1,12 @@ #!/bin/sh # check-gmp.sh by Timothy Redaelli (timothy@redaelli.eu) -[ -f /usr/include/$(gcc -dumpmachine)/gmp.h -o -f /usr/include/gmp.h -o -f /opt/local/include/gmp.h -o -f /usr/local/include/gmp.h -o -f /opt/csw/include/gmp.h ] || { echo "ERROR: Install gmp before continuing."; exit 1; } +# i386 dumpmachine returns i686-linux-gnu +[ -f /usr/include/"$(gcc -dumpmachine)"/gmp.h ] || +[ -f /usr/include/i386-linux-gnu/gmp.h ] || +[ -f /usr/include/gmp.h ] || +[ -f /opt/local/include/gmp.h ] || +[ -f /usr/local/include/gmp.h ] || +[ -f /opt/csw/include/gmp.h ] || +{ echo "ERROR: Install gmp before continuing."; exit 1; } +# sudo apt-get install libgmp-dev diff --git a/depends/check-libelf.sh b/depends/check-libelf.sh index b1049965c..f5c5a52a6 100755 --- a/depends/check-libelf.sh +++ b/depends/check-libelf.sh @@ -1,4 +1,10 @@ #!/bin/sh # check-libelf.sh by Naomi Peori (naomi@peori.ca) -( ls /usr/include/libelf.h || ls /usr/local/include/libelf.h || ls /opt/local/include/libelf.h || ls /opt/local/include/libelf/libelf.h || ls /usr/local/include/libelf/libelf.h ) 1>/dev/null 2>&1 || { echo "ERROR: Install libelf before continuing."; exit 1; } +[ -f /usr/include/libelf.h ] || +[ -f /usr/local/include/libelf.h ] || +[ -f /opt/local/include/libelf.h ] || +[ -f /opt/local/include/libelf/libelf.h ] || +[ -f /usr/local/include/libelf/libelf.h ] || +{ echo "ERROR: Install libelf before continuing."; exit 1; } +# sudo apt-get install libelf-dev \ No newline at end of file diff --git a/depends/check-libtool.sh b/depends/check-libtool.sh index f7ab75ca9..ac47efc03 100755 --- a/depends/check-libtool.sh +++ b/depends/check-libtool.sh @@ -2,4 +2,6 @@ # check-libtool.sh by Naomi Peori (naomi@peori.ca) ## Check for libtool. -{ libtool --version || libtool -V; } 1>/dev/null 2>&1 || { echo "ERROR: Install libtool before continuing."; exit 1; } +{ libtool --version || libtool -V; } 1>/dev/null 2>&1 || +{ echo "ERROR: Install libtool before continuing."; exit 1; } +# sudo apt-get install libtool-bin \ No newline at end of file diff --git a/depends/check-make.sh b/depends/check-make.sh index 0a6039e15..b0866ac07 100755 --- a/depends/check-make.sh +++ b/depends/check-make.sh @@ -2,4 +2,6 @@ # check-make.sh by Naomi Peori (naomi@peori.ca) ## Check for make. -${MAKE:-make} -v 1>/dev/null 2>&1 || { echo "ERROR: Install make before continuing."; exit 1; } +${MAKE:-make} -v 1>/dev/null 2>&1 || +{ echo "ERROR: Install make before continuing."; exit 1; } +# sudo apt-get install make \ No newline at end of file diff --git a/depends/check-makeinfo.sh b/depends/check-makeinfo.sh index 38963ec4f..3fe72a60d 100755 --- a/depends/check-makeinfo.sh +++ b/depends/check-makeinfo.sh @@ -2,4 +2,6 @@ # check-makeinfo.sh by Naomi Peori (naomi@peori.ca) ## Check for makeinfo. -makeinfo --version 1>/dev/null 2>&1 || { echo "ERROR: Install makeinfo before continuing."; exit 1; } +makeinfo --version 1>/dev/null 2>&1 || +{ echo "ERROR: Install makeinfo before continuing."; exit 1; } +# sudo apt-get install texinfo diff --git a/depends/check-ncurses.sh b/depends/check-ncurses.sh index c247c6040..df37d6933 100755 --- a/depends/check-ncurses.sh +++ b/depends/check-ncurses.sh @@ -1,4 +1,11 @@ #!/bin/sh # check-ncurses.sh by Naomi Peori (naomi@peori.ca) -( ls /usr/include/ncurses.h || ls /usr/include/ncurses/ncurses.h || ls /opt/local/include/ncurses.h || ls /usr/include/curses.h || ls /mingw/include/curses.h || ls /usr/local/opt/ncurses/include/ncurses.h ) 1>/dev/null 2>&1 || { echo "ERROR: Install ncurses before continuing."; exit 1; } +[ -f /usr/include/ncurses.h ] || +[ -f /usr/include/ncurses/ncurses.h ] || +[ -f /opt/local/include/ncurses.h ] || +[ -f /usr/include/curses.h ] || +[ -f /mingw/include/curses.h ] || +[ -f /usr/local/opt/ncurses/include/ncurses.h ] || +{ echo "ERROR: Install ncurses before continuing."; exit 1; } +# sudo apt-get install libncurses5-dev \ No newline at end of file diff --git a/depends/check-patch.sh b/depends/check-patch.sh index b40f6cf3a..ae57aace6 100755 --- a/depends/check-patch.sh +++ b/depends/check-patch.sh @@ -2,4 +2,6 @@ # check-patch.sh by Naomi Peori (naomi@peori.ca) ## Check for patch. -patch -v 1>/dev/null 2>&1 || { echo "ERROR: Install patch before continuing."; exit 1; } +patch -v 1>/dev/null 2>&1 || +{ echo "ERROR: Install patch before continuing."; exit 1; } +# sudo apt-get install patch \ No newline at end of file diff --git a/depends/check-pkg-config.sh b/depends/check-pkg-config.sh index 4666e501b..222698d32 100755 --- a/depends/check-pkg-config.sh +++ b/depends/check-pkg-config.sh @@ -2,4 +2,6 @@ # check-pkg-config.sh by Naomi Peori (naomi@peori.ca) ## Check for pkg-config. -pkg-config --version 1>/dev/null 2>&1 || { echo "ERROR: Install pkg-config before continuing."; exit 1; } +pkg-config --version 1>/dev/null 2>&1 || +{ echo "ERROR: Install pkg-config before continuing."; exit 1; } +# sudo apt-get install pkg-config \ No newline at end of file diff --git a/depends/check-ps3dev.sh b/depends/check-ps3dev.sh index b8f1a1d9f..b97d5a0b0 100755 --- a/depends/check-ps3dev.sh +++ b/depends/check-ps3dev.sh @@ -2,19 +2,25 @@ # check-ps3dev.sh by Naomi Peori (naomi@peori.ca) ## Check if $PS3DEV is set. -if test ! $PS3DEV; then { echo "ERROR: Set \$PS3DEV before continuing."; exit 1; } fi +[ -z "$PS3DEV" ] && +{ echo "ERROR: Set \$PS3DEV before continuing."; exit 1; } ## Check for the $PS3DEV directory. -( ls -ld $PS3DEV || mkdir -p $PS3DEV ) 1>/dev/null 2>&1 || { echo "ERROR: Create $PS3DEV before continuing."; exit 1; } +[ -d "$PS3DEV" ] || mkdir -p "$PS3DEV" 1>/dev/null 2>&1 || +{ echo "ERROR: Create \"$PS3DEV\" before continuing."; exit 1; } ## Check for write permission. -touch $PS3DEV/test.tmp 1>/dev/null 2>&1 || { echo "ERROR: Grant write permissions for $PS3DEV before continuing."; exit 1; } +[ -w "$PS3DEV" ] || +{ echo "ERROR: Grant write permissions for \"$PS3DEV\" to $USER before continuing."; exit 1; } ## Check for $PS3DEV/bin in the path. -echo $PATH | grep $PS3DEV/bin 1>/dev/null 2>&1 || { echo "ERROR: Add $PS3DEV/bin to your path before continuing."; exit 1; } +echo ":$PATH:" | grep ":$PS3DEV/bin:" 1>/dev/null 2>&1 || +{ echo "ERROR: Add \"$PS3DEV/bin\" to your path before continuing."; exit 1; } ## Check for $PS3DEV/ppu/bin in the path. -echo $PATH | grep $PS3DEV/ppu/bin 1>/dev/null 2>&1 || { echo "ERROR: Add $PS3DEV/ppu/bin to your path before continuing."; exit 1; } +echo ":$PATH:" | grep ":$PS3DEV/ppu/bin:" 1>/dev/null 2>&1 || +{ echo "ERROR: Add \"$PS3DEV/ppu/bin\" to your path before continuing."; exit 1; } ## Check for $PS3DEV/spu/bin in the path. -echo $PATH | grep $PS3DEV/spu/bin 1>/dev/null 2>&1 || { echo "ERROR: Add $PS3DEV/spu/bin to your path before continuing."; exit 1; } +echo ":$PATH:" | grep ":$PS3DEV/spu/bin:" 1>/dev/null 2>&1 || +{ echo "ERROR: Add \"$PS3DEV/spu/bin\" to your path before continuing."; exit 1; } diff --git a/depends/check-psl1ght.sh b/depends/check-psl1ght.sh index 38f913f3c..d6e762085 100755 --- a/depends/check-psl1ght.sh +++ b/depends/check-psl1ght.sh @@ -2,10 +2,13 @@ # check-psl1ght.sh by Naomi Peori (naomi@peori.ca) ## Check if $PSL1GHT is set. -if test ! $PSL1GHT; then { echo "ERROR: Set \$PSL1GHT before continuing."; exit 1; } fi +[ -z "$PSL1GHT" ] && +{ echo "ERROR: Set \$PSL1GHT before continuing."; exit 1; } ## Check for the $PSL1GHT directory. -( ls -ld $PSL1GHT || mkdir -p $PSL1GHT ) 1>/dev/null 2>&1 || { echo "ERROR: Create $PSL1GHT before continuing."; exit 1; } +[ -d "$PSL1GHT" ] || mkdir -p "$PSL1GHT" 1>/dev/null 2>&1 || +{ echo "ERROR: Create \"$PSL1GHT\" before continuing."; exit 1; } ## Check for write permission. -touch $PSL1GHT/test.tmp 1>/dev/null 2>&1 || { echo "ERROR: Grant write permissions for $PSL1GHT before continuing."; exit 1; } +[ -w "$PSL1GHT" ] || +{ echo "ERROR: Grant write permissions for $PSL1GHT before continuing."; exit 1; } diff --git a/depends/check-python.sh b/depends/check-python.sh index c7ca7df0e..19ed7d0d3 100755 --- a/depends/check-python.sh +++ b/depends/check-python.sh @@ -1,12 +1,20 @@ #!/bin/sh # check-python.sh by Naomi Peori (naomi@peori.ca) +#TODO: Do we need to differentiate python2 and 3? Python2 is EOL ## Check for python. -( python --version || python -V ) 1>/dev/null 2>&1 || { echo "ERROR: Install python before continuing."; exit 1; } +( python --version || python -V ) 1>/dev/null 2>&1 || +{ echo "ERROR: Install python before continuing."; exit 1; } +# sudo apt-get install python2.7 ## Check for python-config -pyprefix=$(python-config --prefix) -[ $? -eq 0 ] || { echo "ERROR: Install python-dev before continuing."; exit 1; } +PYPREFIX=$(python-config --prefix) +[ -z "$PYPREFIX" ] && { echo "ERROR: Install python-dev before continuing."; exit 1; } +# sudo apt-get install python2-config ## Check for python header files -( ls -1d "${pyprefix}"/include/python2.*/Python.h || ls -1d /opt/local/include/python2.*/Python.h ) 1>/dev/null 2>&1 || [ -f "$PYINSTALLDIR/include/Python.h" ] || { echo "ERROR: Install python-dev before continuing."; exit 1; } +ls -1d "${PYPREFIX}"/include/python2.*/Python.h 1>/dev/null 2>&1 || +ls -1d /opt/local/include/python2.*/Python.h 1>/dev/null 2>&1 || +[ -f "$PYINSTALLDIR/include/Python.h" ] || +{ echo "ERROR: Install python-dev before continuing."; exit 1; } +# sudo apt-get install python2.7-dev \ No newline at end of file diff --git a/depends/check-wget.sh b/depends/check-wget.sh index f777887a4..604fd8e4b 100755 --- a/depends/check-wget.sh +++ b/depends/check-wget.sh @@ -2,4 +2,6 @@ # check-wget.sh by Naomi Peori (naomi@peori.ca) ## Check for wget. -wget -V 1>/dev/null 2>&1 || { echo "ERROR: Install wget before continuing."; exit 1; } +wget -V 1>/dev/null 2>&1 || +{ echo "ERROR: Install wget before continuing."; exit 1; } +# sudo apt-get install wget diff --git a/depends/check-zlib.sh b/depends/check-zlib.sh index 21032e832..e6e7c6d52 100755 --- a/depends/check-zlib.sh +++ b/depends/check-zlib.sh @@ -1,4 +1,8 @@ #!/bin/sh # check-zlib.sh by Naomi Peori (naomi@peori.ca) -( ls /usr/include/zlib.h || ls /opt/local/include/zlib.h || ls /usr/local/opt/zlib/include/zlib.h ) 1>/dev/null 2>&1 || { echo "ERROR: Install zlib before continuing."; exit 1; } +[ -f /usr/include/zlib.h ] || +[ -f /opt/local/include/zlib.h ] || +[ -f /usr/local/opt/zlib/include/zlib.h ] || +{ echo "ERROR: Install zlib before continuing."; exit 1; } +# sudo apt-get install zlib1g-dev \ No newline at end of file diff --git a/scripts/001-binutils-PPU.sh b/scripts/001-binutils-PPU.sh index 14e295cff..0f6236ba4 100755 --- a/scripts/001-binutils-PPU.sh +++ b/scripts/001-binutils-PPU.sh @@ -16,7 +16,7 @@ if [ ! -d ${BINUTILS} ]; then tar xfvj ${BINUTILS}.tar.bz2 ## Patch the source code. - cat ../patches/${BINUTILS}-PS3.patch | patch -p1 -d ${BINUTILS} + patch -p1 -d ${BINUTILS} < ../patches/${BINUTILS}-PS3.patch ## Replace config.guess and config.sub cp config.guess config.sub ${BINUTILS} @@ -46,6 +46,6 @@ cd ${BINUTILS}/build-ppu --with-gnu-ld ## Compile and install. -PROCS="$(nproc --all 2>&1)" || ret=$? -if [ ! -z $ret ]; then PROCS=4; fi -${MAKE:-make} -j $PROCS && ${MAKE:-make} libdir=host-libs/lib install +PROCESSORS="$(nproc --all 2>&1)" +[ -n "$PROCESSORS" ] && [ "$PROCESSORS" -gt 0 ] || PROCESSORS=4 +${MAKE:-make} -j $PROCESSORS && ${MAKE:-make} libdir=host-libs/lib install diff --git a/scripts/002-gcc-newlib-PPU.sh b/scripts/002-gcc-newlib-PPU.sh index b63da30d2..2b9623ac5 100755 --- a/scripts/002-gcc-newlib-PPU.sh +++ b/scripts/002-gcc-newlib-PPU.sh @@ -15,15 +15,15 @@ if [ ! -d ${GCC} ]; then rm -Rf ${NEWLIB} && tar xfvz ${NEWLIB}.tar.gz ## Patch the source code. - cat ../patches/${GCC}-PS3.patch | patch -p1 -d ${GCC} - cat ../patches/${NEWLIB}-PS3.patch | patch -p1 -d ${NEWLIB} + patch -p1 -d ${GCC} < ../patches/${GCC}-PS3.patch + patch -p1 -d ${NEWLIB} < ../patches/${NEWLIB}-PS3.patch ## Enter the source code directory. - cd ${GCC} + cd "${GCC}" ## Create the newlib symlinks. - ln -s ../${NEWLIB}/newlib newlib - ln -s ../${NEWLIB}/libgloss libgloss + ln -s "../${NEWLIB}/newlib" newlib + ln -s "../${NEWLIB}/libgloss" libgloss ## Download the prerequisites. ./contrib/download_prerequisites @@ -63,6 +63,6 @@ cd ${GCC}/build-ppu --with-system-zlib ## Compile and install. -PROCS="$(nproc --all 2>&1)" || ret=$? -if [ ! -z $ret ]; then PROCS=4; fi -${MAKE:-make} -j $PROCS all && ${MAKE:-make} install +PROCESSORS="$(nproc --all 2>&1)" +[ -n "$PROCESSORS" ] && [ "$PROCESSORS" -gt 0 ] || PROCESSORS=4 +${MAKE:-make} -j $PROCESSORS all && ${MAKE:-make} install diff --git a/scripts/003-gdb-PPU.sh b/scripts/003-gdb-PPU.sh index ad4b17b1b..f7130434e 100755 --- a/scripts/003-gdb-PPU.sh +++ b/scripts/003-gdb-PPU.sh @@ -16,7 +16,7 @@ if [ ! -d ${GDB} ]; then tar xfvj ${GDB}.tar.bz2 ## Patch the source code. - cat ../patches/${GDB}-PS3.patch | patch -p1 -d ${GDB} + patch -p1 -d ${GDB} < ../patches/${GDB}-PS3.patch ## Replace config.guess and config.sub cp config.guess config.sub ${GDB} @@ -41,6 +41,6 @@ cd ${GDB}/build-ppu --disable-werror ## Compile and install. -PROCS="$(nproc --all 2>&1)" || ret=$? -if [ ! -z $ret ]; then PROCS=4; fi -${MAKE:-make} -j $PROCS && ${MAKE:-make} libdir=host-libs/lib install +PROCESSORS="$(nproc --all 2>&1)" +[ -n "$PROCESSORS" ] && [ "$PROCESSORS" -gt 0 ] || PROCESSORS=4 +${MAKE:-make} -j $PROCESSORS && ${MAKE:-make} libdir=host-libs/lib install diff --git a/scripts/004-symlinks-PPU.sh b/scripts/004-symlinks-PPU.sh index 582c244b3..c657e8cbd 100755 --- a/scripts/004-symlinks-PPU.sh +++ b/scripts/004-symlinks-PPU.sh @@ -2,20 +2,20 @@ # symlinks-PPU.sh by Naomi Peori (naomi@peori.ca) ## Enter the PPU directory. -cd ${PS3DEV}/ppu +cd "${PS3DEV}/ppu" ## Create the directory symlinks. -if [ ! -d ppu -a ! -f ppu -a ! -h ppu -a -d powerpc64-ps3-elf ]; then +if [ ! -d ppu ] && [ ! -f ppu ] && [ ! -h ppu ] && [ -d powerpc64-ps3-elf ]; then ln -s powerpc64-ps3-elf ppu fi ## Enter the bin directory. -cd ${PS3DEV}/ppu/bin +cd "${PS3DEV}/ppu/bin" ## Create the bin symlinks. -for i in `ls powerpc64-ps3-elf-* | cut -c19-`; do - if [ ! -f ppu-${i} -a ! -h ppu-${i} -a -f powerpc64-ps3-elf-${i} ]; then - ln -s powerpc64-ps3-elf-${i} ppu-${i} +for i in $(find . -maxdepth 1 -name "powerpc64-ps3-elf-*" | cut -c21-); do + if [ ! -f "ppu-${i}" ] && [ ! -h "ppu-${i}" ] && [ -f "powerpc64-ps3-elf-${i}" ]; then + ln -s "powerpc64-ps3-elf-${i}" "ppu-${i}" fi done diff --git a/scripts/005-binutils-SPU.sh b/scripts/005-binutils-SPU.sh index 0c993d411..cbe1e6379 100755 --- a/scripts/005-binutils-SPU.sh +++ b/scripts/005-binutils-SPU.sh @@ -16,7 +16,7 @@ if [ ! -d ${BINUTILS} ]; then tar xfvj ${BINUTILS}.tar.bz2 ## Patch the source code. - cat ../patches/${BINUTILS}-PS3.patch | patch -p1 -d ${BINUTILS} + patch -p1 -d ${BINUTILS} < ../patches/${BINUTILS}-PS3.patch ## Replace config.guess and config.sub cp config.guess config.sub ${BINUTILS} @@ -45,6 +45,6 @@ cd ${BINUTILS}/build-spu --with-gnu-ld ## Compile and install. -PROCS="$(nproc --all 2>&1)" || ret=$? -if [ ! -z $ret ]; then PROCS=4; fi -${MAKE:-make} -j $PROCS && ${MAKE:-make} libdir=host-libs/lib install +PROCESSORS="$(nproc --all 2>&1)" +[ -n "$PROCESSORS" ] && [ "$PROCESSORS" -gt 0 ] || PROCESSORS=4 +${MAKE:-make} -j $PROCESSORS && ${MAKE:-make} libdir=host-libs/lib install diff --git a/scripts/006-gcc-newlib-SPU.sh b/scripts/006-gcc-newlib-SPU.sh index c51f73786..df899af5d 100755 --- a/scripts/006-gcc-newlib-SPU.sh +++ b/scripts/006-gcc-newlib-SPU.sh @@ -15,8 +15,8 @@ if [ ! -d ${GCC} ]; then rm -Rf ${NEWLIB} && tar xfvz ${NEWLIB}.tar.gz ## Patch the source code. - cat ../patches/${GCC}-PS3.patch | patch -p1 -d ${GCC} - cat ../patches/${NEWLIB}-PS3.patch | patch -p1 -d ${NEWLIB} + patch -p1 -d ${GCC} < ../patches/${GCC}-PS3.patch + patch -p1 -d ${NEWLIB} < ../patches/${NEWLIB}-PS3.patch ## Enter the source code directory. cd ${GCC} @@ -62,6 +62,6 @@ CFLAGS_FOR_TARGET="-Os -fpic -ffast-math -ftree-vectorize -funroll-loops -fsched --with-pic ## Compile and install. -PROCS="$(nproc --all 2>&1)" || ret=$? -if [ ! -z $ret ]; then PROCS=4; fi -${MAKE:-make} -j $PROCS all && ${MAKE:-make} install +PROCESSORS="$(nproc --all 2>&1)" +[ -n "$PROCESSORS" ] && [ "$PROCESSORS" -gt 0 ] || PROCESSORS=4 +${MAKE:-make} -j $PROCESSORS all && ${MAKE:-make} install diff --git a/scripts/007-gdb-SPU.sh b/scripts/007-gdb-SPU.sh index 73cd17d9c..6a1ff77bd 100755 --- a/scripts/007-gdb-SPU.sh +++ b/scripts/007-gdb-SPU.sh @@ -16,7 +16,7 @@ if [ ! -d ${GDB} ]; then tar xfvj ${GDB}.tar.bz2 ## Patch the source code. - cat ../patches/${GDB}-PS3.patch | patch -p1 -d ${GDB} + patch -p1 -d ${GDB} < ../patches/${GDB}-PS3.patch ## Replace config.guess and config.sub cp config.guess config.sub ${GDB} @@ -40,6 +40,6 @@ cd ${GDB}/build-spu --disable-werror ## Compile and install. -PROCS="$(nproc --all 2>&1)" || ret=$? -if [ ! -z $ret ]; then PROCS=4; fi -${MAKE:-make} -j $PROCS && ${MAKE:-make} libdir=host-libs/lib install +PROCESSORS="$(nproc --all 2>&1)" +[ -n "$PROCESSORS" ] && [ "$PROCESSORS" -gt 0 ] || PROCESSORS=4 +${MAKE:-make} -j $PROCESSORS && ${MAKE:-make} libdir=host-libs/lib install diff --git a/toolchain-mingw.sh b/toolchain-mingw.sh index cf9fa4ec0..64ee4f217 100755 --- a/toolchain-mingw.sh +++ b/toolchain-mingw.sh @@ -1,6 +1,7 @@ #!/bin/bash -# toolchain-mingw.sh by Miigotu (miigotu@hotmail.com) +# toolchain-mingw.sh by Miigotu (miigotu@gmail.com) +# shellcheck disable=SC2016 MINGW32EXPORTS=\ ('export GITINSTALLDIR=/c/msysgit' \ 'export PATH="$PATH:$GITINSTALLDIR/bin"' \ @@ -21,167 +22,168 @@ RESTART=0 ask_permission() { - if [ $DO_SET_EXPORTS -ne 0 ]; then - if [ $HAS_ANSWERED -ne 1 ]; then - echo -e "\E[1;31mWARNING:\E[0m\E[1m If you continue, his script will modify your global profile!\E[0m" - echo - echo The purpose of this change is to add export paths to your profile. - echo To undo this, edit /etc/profile and removing these lines from the bottom: - echo -e '(\E[4mNote:\E[0m These are also the exports that will be added, take note.)' - echo - echo -e '\E[0;32m export GITINSTALLDIR=/c/msysgit' - echo ' export PATH="$PATH:$GITINSTALLDIR/bin"' - echo ' export PATH="$PATH:$GITINSTALLDIR/mingw/bin"' - echo ' export PYINSTALLDIR=/c/python27' - echo ' export PATH="$PATH:$PYINSTALLDIR"' - echo ' export PS3DEV=/usr/local/ps3dev' - echo ' export PATH="$PATH:$PS3DEV/bin"' - echo ' export PATH="$PATH:$PS3DEV/host/ppu/bin"' - echo ' export PATH="$PATH:$PS3DEV/host/spu/bin"' - echo ' export PSL1GHT=$PS3DEV/psl1ght' - echo -e ' export PATH="$PATH:$PSL1GHT/host/bin"\E[0m' - echo - echo It is highly recommended that you do this, to have the same build that most - echo others have, so that it is easier for others to help you when you have issues. - echo Also, the buildscripts will fail if certain paths and variables are not set. - echo - echo -e '\E[1mDo you want to set these exports?\E[0m' - echo - - PS3="Enter 1, 2, or 3: " - options=("Yes, change my profile for me." "No, I have set them myself, but continue." "Quit, I will set them myself.") - select opt in "${options[@]}" - do - case $opt in - "Yes, change my profile for me.") - DO_SET_EXPORTS=1 - HAS_ANSWERED=1 - break - ;; - "No, I have set them myself, but continue.") - DO_SET_EXPORTS=0 - HAS_ANSWERED=1 - break - ;; - "Quit, I will set them myself.") - echo - echo -e "\E[1mExitting, Run this script again when you are ready.\E[0m" - exit 0 - ;; - *) echo Invalid option, please try again. - ;; - esac - done - fi - fi + if [ $DO_SET_EXPORTS -ne 0 ]; then + # shellcheck disable=SC2016 + if [ $HAS_ANSWERED -ne 1 ]; then + env echo -e "\E[1;31mWARNING:\E[0m\E[1m If you continue, his script will modify your global profile!\E[0m" + env echo + env echo The purpose of this change is to add export paths to your profile. + env echo To undo this, edit /etc/profile and removing these lines from the bottom: + env echo -e '(\E[4mNote:\E[0m These are also the exports that will be added, take note.)' + env echo + env echo -e '\E[0;32m export GITINSTALLDIR=/c/msysgit' + env echo ' export PATH="$PATH:$GITINSTALLDIR/bin"' + env echo ' export PATH="$PATH:$GITINSTALLDIR/mingw/bin"' + env echo ' export PYINSTALLDIR=/c/python27' + env echo ' export PATH="$PATH:$PYINSTALLDIR"' + env echo ' export PS3DEV=/usr/local/ps3dev' + env echo ' export PATH="$PATH:$PS3DEV/bin"' + env echo ' export PATH="$PATH:$PS3DEV/host/ppu/bin"' + env echo ' export PATH="$PATH:$PS3DEV/host/spu/bin"' + env echo ' export PSL1GHT=$PS3DEV/psl1ght' + env echo -e ' export PATH="$PATH:$PSL1GHT/host/bin"\E[0m' + env echo + env echo 'It is highly recommended that you do this, to have the same build that most' + env echo 'others have, so that it is easier for others to help you when you have issues.' + env echo 'Also, the build scripts will fail if certain paths and variables are not set.' + env echo + env echo -e '\E[1mDo you want to set these exports?\E[0m' + env echo + + PS3="Enter 1, 2, or 3: " + options=("Yes, change my profile for me." "No, I have set them myself, but continue." "Quit, I will set them myself.") + select opt in "${options[@]}" + do + case $opt in + "Yes, change my profile for me.") + DO_SET_EXPORTS=1 + HAS_ANSWERED=1 + break + ;; + "No, I have set them myself, but continue.") + DO_SET_EXPORTS=0 + HAS_ANSWERED=1 + break + ;; + "Quit, I will set them myself.") + env echo + env echo -e "\E[1mExiting, Run this script again when you are ready.\E[0m" + exit 0 + ;; + *) env echo Invalid option, please try again. + ;; + esac + done + fi + fi } -if [ $MSYSTEM == MINGW32 ]; then - for((i = 0; i < ${#MINGW32EXPORTS[*]}; i++)); do - if ! grep -q "${MINGW32EXPORTS[${i}]}" /etc/profile; then - ask_permission - if [ $DO_SET_EXPORTS -ne 0 ]; then - if [ $NEWLINE -ne 1 ]; then - echo >> /etc/profile ##In cases where no new line is at EOF. - NEWLINE=1 - fi - echo ${MINGW32EXPORTS[${i}]} >> /etc/profile - RESTART=1 - fi - fi - done - if [ $RESTART -eq 1 ]; then - echo -e "Please restart mingw, or type \E[1m'. /etc/profile'\E[0m (without quotes)" - echo "and then run this script again." - exit 1 - fi - -INSTALL_PACKAGES= - - ## Install Dependancy packages - if [ ! -f /usr//include/gmp.h ]; then - INSTALL_PACKAGES+="msys-libgmp-dev gmp gmp-dev " - fi - if [ ! -f /usr//include/crypt.h ]; then - INSTALL_PACKAGES+="msys-libcrypt " - fi - if [ ! -f /usr/include/zlib.h ]; then - INSTALL_PACKAGES+="msys-zlib " - fi - if [ ! -f /mingw/include/zlib.h ]; then - INSTALL_PACKAGES+="libz " - fi - if [ ! -f /mingw/include/curses.h ]; then - INSTALL_PACKAGES+="libpdcurses " - fi - if [ ! -f /mingw/bin/pexports ]; then - INSTALL_PACKAGES+="pexports " - fi - if [ ! -f /usr/bin/wget ]; then - INSTALL_PACKAGES+="msys-wget " - fi - if [ ! -f /usr/bin/patch ]; then - INSTALL_PACKAGES+="msys-patch " - fi - if [ ! -f /usr/bin/unzip ]; then - INSTALL_PACKAGES+="msys-unzip " - fi - if [ ! -f /usr/include/openssl/sha.h ]; then - INSTALL_PACKAGES+="msys-libopenssl " - fi - - if [ ${INSTALL_PACKAGES} ]; then - mingw-get install $INSTALL_PACKAGES - fi - - ## Create the build directory. - mkdir -p build && cd build || { echo "ERROR: Could not create the build directory."; exit 1; } - - ## Install libelf - if [ ! -f /mingw/include/libelf.h ]; then - wget http://www.mr511.de/software/libelf-0.8.13.tar.gz - tar -zxvf libelf-0.8.13.tar.gz - cd libelf-0.8.13 - ./configure --prefix="/mingw" - make -j4 && make install - cd .. - fi - - - ## Install pkg-config and dependancy dll's - if [ ! -f /usr/bin/pkg-config ]; then - wget https://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/pkg-config_0.25-1_win32.zip - unzip -o pkg-config_0.25-1_win32.zip bin/*.exe -d /usr > NUL - fi - if [ ! -f /usr/bin/intl.dll ]; then - wget https://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/gettext-runtime_0.18.1.1-2_win32.zip - unzip -o gettext-runtime_0.18.1.1-2_win32.zip bin/*.dll -d /usr > NUL - fi - if [ ! -f /usr/bin/libglib-2.0-0.dll ]; then - wget https://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.26/glib_2.26.1-1_win32.zip - unzip -o glib_2.26.1-1_win32.zip bin/*.dll -d /usr > NUL - fi - - rm -Rf pkg-config_0.25-1_win32.zip glib_2.26.1-1_win32.zip gettext-runtime_0.18.1.1-2_win32.zip libelf-0.8.13.tar.gz libelf-0.8.13 - - ## Convert python.dll to a shared library - if [ ! -f $PYINSTALLDIR/libs/libpython27.a ]; then - PYDLL="$WINDIR\SysWOW64\python27.dll" - pexports "$PYDLL" > python27.def - if [ $? != 0 ]; then - PYDLL="$WINDIR\System32\python27.dll" - pexports "$PYDLL" > python27.def - fi - dlltool --dllname "$PYDLL" --def python27.def --output-lib libpython27.a - mv libpython27.a $PYINSTALLDIR/libs - rm -Rf python27.def - fi - - ## Enter the ps3toolchain directory. - cd .. - - ## Run the toolchain script. - ./toolchain.sh $@ || { echo "ERROR: Could not run the toolchain script."; exit 1; } +if [ "$MSYSTEM" == MINGW32 ]; then + for((i = 0; i < ${#MINGW32EXPORTS[*]}; i++)); do + if ! grep -q "${MINGW32EXPORTS[${i}]}" /etc/profile; then + ask_permission + if [ $DO_SET_EXPORTS -ne 0 ]; then + if [ $NEWLINE -ne 1 ]; then + env echo >> /etc/profile ##In cases where no new line is at EOF. + NEWLINE=1 + fi + env echo "${MINGW32EXPORTS[${i}]}" >> /etc/profile + RESTART=1 + fi + fi + done + if [ $RESTART -eq 1 ]; then + env echo -e "Please restart mingw, or type \E[1m'. /etc/profile'\E[0m (without quotes)" + env echo "and then run this script again." + exit 1 + fi + + INSTALL_PACKAGES= + + ## Install Dependency packages + if [ ! -f /usr//include/gmp.h ]; then + INSTALL_PACKAGES+="msys-libgmp-dev gmp gmp-dev " + fi + if [ ! -f /usr//include/crypt.h ]; then + INSTALL_PACKAGES+="msys-libcrypt " + fi + if [ ! -f /usr/include/zlib.h ]; then + INSTALL_PACKAGES+="msys-zlib " + fi + if [ ! -f /mingw/include/zlib.h ]; then + INSTALL_PACKAGES+="libz " + fi + if [ ! -f /mingw/include/curses.h ]; then + INSTALL_PACKAGES+="libpdcurses " + fi + if [ ! -f /mingw/bin/pexports ]; then + INSTALL_PACKAGES+="pexports " + fi + if [ ! -f /usr/bin/wget ]; then + INSTALL_PACKAGES+="msys-wget " + fi + if [ ! -f /usr/bin/patch ]; then + INSTALL_PACKAGES+="msys-patch " + fi + if [ ! -f /usr/bin/unzip ]; then + INSTALL_PACKAGES+="msys-unzip " + fi + if [ ! -f /usr/include/openssl/sha.h ]; then + INSTALL_PACKAGES+="msys-libopenssl " + fi + + if [ "${INSTALL_PACKAGES}" ]; then + mingw-get install "$INSTALL_PACKAGES" + fi + + ## Create the build directory. + { mkdir -p build && cd build; } || + { env echo "ERROR: Could not create the build directory."; exit 1; } + + ## Install libelf + if [ ! -f /mingw/include/libelf.h ]; then + wget http://www.mr511.de/software/libelf-0.8.13.tar.gz + tar -zxvf libelf-0.8.13.tar.gz + cd libelf-0.8.13 || { env echo "ERROR: Extracting libelf failed."; exit 1; } + ./configure --prefix="/mingw" + make -j4 && make install + cd .. + fi + + + ## Install pkg-config and dependency dll's + if [ ! -f /usr/bin/pkg-config ]; then + wget https://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/pkg-config_0.25-1_win32.zip + unzip -o pkg-config_0.25-1_win32.zip bin/*.exe -d /usr > NUL + fi + if [ ! -f /usr/bin/intl.dll ]; then + wget https://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/gettext-runtime_0.18.1.1-2_win32.zip + unzip -o gettext-runtime_0.18.1.1-2_win32.zip bin/*.dll -d /usr > NUL + fi + if [ ! -f /usr/bin/libglib-2.0-0.dll ]; then + wget https://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.26/glib_2.26.1-1_win32.zip + unzip -o glib_2.26.1-1_win32.zip bin/*.dll -d /usr > NUL + fi + + rm -Rf pkg-config_0.25-1_win32.zip glib_2.26.1-1_win32.zip gettext-runtime_0.18.1.1-2_win32.zip libelf-0.8.13.tar.gz libelf-0.8.13 + + ## Convert python.dll to a shared library + if [ ! -f "$PYINSTALLDIR"/libs/libpython27.a ]; then + PYDLL="$WINDIR\SysWOW64\python27.dll" + if ! pexports "$PYDLL" > python27.def; then + PYDLL="$WINDIR\System32\python27.dll" + pexports "$PYDLL" > python27.def + fi + dlltool --dllname "$PYDLL" --def python27.def --output-lib libpython27.a + mv libpython27.a "$PYINSTALLDIR"/libs + rm -Rf python27.def + fi + + ## Enter the ps3toolchain directory. + cd .. + + ## Run the toolchain script. + ./toolchain.sh "$@" || { env echo "ERROR: Could not run the toolchain script."; exit 1; } else - echo "MinGW was not detected as your kernel, exitting." + env echo "MinGW was not detected as your kernel, exiting." fi \ No newline at end of file diff --git a/toolchain-sudo.sh b/toolchain-sudo.sh index e49485852..b9e891447 100755 --- a/toolchain-sudo.sh +++ b/toolchain-sudo.sh @@ -2,7 +2,8 @@ # toolchain-sudo.sh by Naomi Peori (naomi@peori.ca) ## Enter the ps3toolchain directory. -cd "`dirname $0`" || { echo "ERROR: Could not enter the ps3toolchain directory."; exit 1; } +cd "$(dirname "$0")" || +{ echo "ERROR: Could not enter the ps3toolchain directory."; exit 1; } ## Set up the environment. export PS3DEV=/usr/local/ps3dev @@ -14,4 +15,5 @@ export PATH=$PATH:$PS3DEV/ppu/bin export PATH=$PATH:$PS3DEV/spu/bin ## Run the toolchain script. -./toolchain.sh $@ || { echo "ERROR: Could not run the toolchain script."; exit 1; } +./toolchain.sh "$@" || +{ echo "ERROR: Could not run the toolchain script."; exit 1; } diff --git a/toolchain.sh b/toolchain.sh index 4a341ef34..094caa310 100755 --- a/toolchain.sh +++ b/toolchain.sh @@ -2,39 +2,43 @@ # toolchain.sh by Naomi Peori (naomi@peori.ca) ## Enter the ps3toolchain directory. -cd "`dirname $0`" || { echo "ERROR: Could not enter the ps3toolchain directory."; exit 1; } +cd "$(dirname "$0")" || +{ echo "ERROR: Could not enter the ps3toolchain directory."; exit 1; } ## Create the build directory. -mkdir -p build && cd build || { echo "ERROR: Could not create the build directory."; exit 1; } +{ mkdir -p build && cd build;} || +{ echo "ERROR: Could not create the build directory."; exit 1; } ## Use gmake if available -which gmake 1>/dev/null 2>&1 && export MAKE=gmake +command -v gmake && export MAKE=gmake ## Fetch the depend scripts. -DEPEND_SCRIPTS=`ls ../depends/*.sh | sort` +DEPEND_SCRIPTS=$(find ../depends -name "*.sh" | sort) ## Run all the depend scripts. -for SCRIPT in $DEPEND_SCRIPTS; do "$SCRIPT" || { echo "$SCRIPT: Failed."; exit 1; } done +for SCRIPT in $DEPEND_SCRIPTS; do + "$SCRIPT" || { echo "$SCRIPT: Failed."; exit 1; } +done ## Fetch the build scripts. -BUILD_SCRIPTS=`ls ../scripts/*.sh | sort` +BUILD_SCRIPTS=$(find ../scripts -name "*.sh" | sort) ## If specific steps were requested... -if [ $1 ]; then +if [ "$1" ]; then ## Find the requested build scripts. REQUESTS="" - for STEP in $@; do + for STEP in "$@"; do SCRIPT="" for i in $BUILD_SCRIPTS; do - if [ `basename $i | cut -d'-' -f1` -eq $STEP ]; then + if [ "$(basename "$i" | cut -d'-' -f1)" -eq "$STEP" ]; then SCRIPT=$i break fi done - [ -z $SCRIPT ] && { echo "ERROR: unknown step $STEP"; exit 1; } + [ -z "$SCRIPT" ] && { echo "ERROR: unknown step \"$STEP\""; exit 1; } REQUESTS="$REQUESTS $SCRIPT" done