diff --git a/.github/workflows/compilation.yml b/.github/workflows/compilation.yml index b0064c1..4fabbb5 100644 --- a/.github/workflows/compilation.yml +++ b/.github/workflows/compilation.yml @@ -8,77 +8,118 @@ on: jobs: build: - runs-on: ${{ matrix.os }} - name: ${{ matrix.os }} (${{ matrix.arch }}) + runs-on: ${{ matrix.os[0] }} strategy: matrix: - include: - - { os: ubuntu-latest, arch: x64 } - - { os: ubuntu-latest, arch: x86 } - - { os: macos-latest, arch: x64 } + os: [[macos-latest, bash], [macos-11, bash], [ubuntu-latest, bash], [windows-latest, msys2]] fail-fast: false + defaults: + run: + shell: ${{ matrix.os[1] }} {0} steps: - uses: actions/checkout@v2 - - name: Install on Ubuntu and Configure - if: matrix.os == 'ubuntu-latest' + - name: Install Ubuntu texinfo bison flex libucl-dev + if: matrix.os[0] == 'ubuntu-latest' run: | - pkg="autoconf automake bison bzip2 cmake doxygen flex gettext \ - git gzip libtool-bin m4 make patch pkg-config python3 python3-venv \ - subversion tar tcl texinfo unzip wget xz-utils" - if [ "${{matrix.arch}}" == "x86" ]; then - pkg="$pkg g++-multilib gcc-multilib libarchive-dev:i386 \ - libcurl4-openssl-dev:i386 libelf-dev:i386 libgpgme-dev:i386 \ - libncurses5-dev:i386 libreadline-dev:i386 libsdl1.2-dev:i386 \ - libssl-dev:i386 libusb-dev:i386" - sudo dpkg --add-architecture i386 - echo "CC=gcc -m32" >> $GITHUB_ENV - echo "CXX=g++ -m32" >> $GITHUB_ENV - echo "PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig" >> $GITHUB_ENV - else - pkg="$pkg g++ gcc libarchive-dev libcurl4-openssl-dev libelf-dev \ - libgpgme-dev libncurses5-dev libreadline-dev libsdl1.2-dev \ - libssl-dev libusb-dev" - fi sudo apt-get update - sudo apt-get -y install $pkg + sudo apt-get -y install texinfo bison flex gettext libgmp3-dev libmpfr-dev libmpc-dev libusb-dev libreadline-dev libcurl4 libcurl4-openssl-dev libssl-dev libarchive-dev libgpgme-dev + echo "MSYSTEM=x64" >> $GITHUB_ENV - - name: Install on Mac - if: matrix.os == 'macos-latest' - run: brew bundle + - name: Install Mac texinfo bison flex ucl + if: startsWith( matrix.os[0], 'macos' ) + run: | + brew update + brew install gettext texinfo bison flex gnu-sed ncurses gsl gmp mpfr autoconf automake cmake libusb-compat libarchive gpgme bash openssl libtool + echo "MSYSTEM=x64" >> $GITHUB_ENV + + - name: Install in MSYS2 + if: matrix.os[0] == 'windows-latest' + uses: msys2/setup-msys2@v2 + with: + msystem: MINGW32 + install: | + base-devel git make texinfo flex bison patch binutils mingw-w64-i686-gcc mingw-w64-i686-dlfcn mingw-w64-i686-mpc + mingw-w64-i686-cmake + update: true + shell: msys2 {0} - - name: Runs all stages + - name: Runs all the stages in the shell run: | + export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH" + export PATH="/usr/local/opt/libtool/libexec/gnubin:$PATH" + export PKG_CONFIG_PATH="/usr/local/opt/libarchive/lib/pkgconfig:/usr/local/opt/openssl@3/lib/pkgconfig" export PSPDEV=$PWD/pspdev export PATH=$PATH:$PSPDEV/bin - ./pspdev.sh + ./build-all.sh - name: Get short SHA id: slug - run: echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)" + run: echo "::set-output name=sha8::${MSYSTEM}-sha[$(echo ${GITHUB_SHA} | cut -c1-8)]" - - name: Compress pspdev folder + - name: Prepare pspdev folder run: | - tar -zcvf pspdev.tar.gz pspdev + tar -zcvf pspdev-${{matrix.os[0]}}.tar.gz pspdev - uses: actions/upload-artifact@v2 with: - name: pspdev-${{ steps.slug.outputs.sha8 }}-${{ matrix.os }}-${{ matrix.arch }} - path: pspdev.tar.gz + name: pspdev-${{matrix.os[0]}}-${{ steps.slug.outputs.sha8 }} + path: pspdev-${{matrix.os[0]}}.tar.gz - - name: Rename pspdev.tar.gz file - run: | - if [ "${{matrix.os}}" == "macos-latest" ]; then - mv pspdev.tar.gz pspdev-macOS.tar.gz - elif [ "${{matrix.os}}" == "ubuntu-latest" ]; then - mv pspdev.tar.gz pspdev-linux-${{ matrix.arch }}.tar.gz - fi + - name: Extract tag name + if: startsWith(github.ref, 'refs/tags/') + id: tag + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + + - name: Create pre-release + if: github.ref == 'refs/heads/master' + uses: softprops/action-gh-release@v1 + with: + files: pspdev-${{matrix.os[0]}}.tar.gz + prerelease: true + name: "Development build" + tag_name: "latest" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Release if: startsWith(github.ref, 'refs/tags/') uses: softprops/action-gh-release@v1 with: - files: pspdev-*.tar.gz + files: pspdev-${{matrix.os[0]}}.tar.gz + tag_name: ${{ steps.tag.outputs.VERSION }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + build-Dockers: + runs-on: ubuntu-latest + container: ${{ matrix.os }}:latest + strategy: + matrix: + os: [ubuntu, fedora] + + steps: + - uses: actions/checkout@v2 + + - name: Install Ubuntu texinfo bison flex libucl-dev + if: matrix.os == 'ubuntu' + run: | + apt-get -y update + DEBIAN_FRONTEND="noninteractive" TZ="Europe/London" apt-get -y install autoconf automake bison bzip2 cmake doxygen flex g++ gcc \ + git gzip libarchive-dev libcurl4 libcurl4-openssl-dev libelf-dev libgpgme-dev libncurses5-dev libreadline-dev libssl-dev \ + libtool-bin libusb-dev m4 make patch pkg-config python3 python3-venv subversion tar tcl texinfo unzip wget xz-utils \ + sudo fakeroot libarchive-tools curl libgmp3-dev libmpfr-dev libmpc-dev python3-pip + + - name: Install dependencies Fedora + if: matrix.os == 'fedora' + run: | + dnf -y install @development-tools gcc gcc-c++ g++ wget git autoconf automake python3 python3-pip make cmake pkgconf \ + libarchive-devel openssl-devel gpgme-devel libtool gettext texinfo bison flex gmp-devel mpfr-devel libmpc-devel ncurses-devel diffutils \ + libusb-devel readline-devel + + - name: Runs all the stages in the shell + run: | + export PSPDEV=$PWD/pspdev + export PATH=$PATH:$PSPDEV/bin + ./build-all.sh diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index cda8729..bed32ed 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -16,38 +16,31 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Prepare - id: prep + - name: Extract DOCKER_TAG using tag name + if: startsWith(github.ref, 'refs/tags/') run: | - DOCKER_IMAGE=pspdev/pspdev - VERSION=latest - if [[ $GITHUB_REF == refs/tags/* ]]; then - VERSION=${GITHUB_REF#refs/tags/} - elif [[ $GITHUB_REF == refs/pull/* ]]; then - VERSION=pr-${{ github.event.number }} - fi - TAGS="${DOCKER_IMAGE}:${VERSION}" - if [ "${{ github.event_name }}" = "push" ]; then - TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}" - fi - echo ::set-output name=version::${VERSION} - echo ::set-output name=tags::${TAGS} - echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') - - - uses: docker/setup-buildx-action@v1 - - - uses: docker/login-action@v1 - if: github.event_name != 'pull_request' + echo "DOCKER_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV + + - name: Use default DOCKER_TAG + if: startsWith(github.ref, 'refs/tags/') != true + run: | + echo "DOCKER_TAG=latest" >> $GITHUB_ENV + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - uses: docker/build-push-action@v2 with: - context: . - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.prep.outputs.tags }} - labels: | - org.opencontainers.image.source=${{ github.event.repository.html_url }} - org.opencontainers.image.created=${{ steps.prep.outputs.created }} - org.opencontainers.image.revision=${{ github.sha }} + push: true + tags: ${{ github.repository }}:${{ env.DOCKER_TAG }} + build-args: | + BASE_DOCKER_IMAGE=ghcr.io/${{ github.repository_owner }}/psp-packages:${{ env.DOCKER_TAG }} \ No newline at end of file diff --git a/Brewfile b/Brewfile deleted file mode 100644 index a43fc4e..0000000 --- a/Brewfile +++ /dev/null @@ -1,24 +0,0 @@ -# Homebrew -brew "autoconf" -brew "automake" -brew "bash" -brew "coreutils" -brew "cmake" -brew "curl" -brew "doxygen" -brew "gettext" -brew "gnu-sed" -brew "gpgme" -brew "intltool" -brew "libarchive" -brew "libelf" -brew "libtool" -brew "libusb" -brew "libusb-compat" -brew "meson" -brew "ninja" -brew "openssl" -brew "pkg-config" -brew "sdl" -brew "wget" -brew "xz" diff --git a/Dockerfile b/Dockerfile index 757a509..7cc87d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,13 @@ -# First stage -FROM pspdev/pspsdk +ARG BASE_DOCKER_IMAGE + +FROM $BASE_DOCKER_IMAGE COPY . /src -RUN apk add build-base autoconf automake bash bison cmake curl-dev doxygen \ - flex git gpgme-dev libarchive-dev libtool libusb-compat-dev \ - openssl-dev patch python3 readline-dev sdl-dev subversion tcl \ - texinfo wget zlib-dev xz -RUN cd /src && ./pspdev.sh 3 4 5 6 7 +# There are some dependencies needed because it is checked by "depends" scripts +RUN apk add build-base git bash patch wget zlib-dev ucl-dev readline-dev libusb-compat-dev \ + autoconf automake bison flex python3 py3-pip cmake pkgconfig libarchive-dev openssl-dev gpgme-dev libtool +RUN cd /src && ./build-extra.sh # Second stage of Dockerfile FROM alpine:latest diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..31322bb --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 PSP Homebrew Development + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 302f06b..e8f8798 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,81 @@ # pspdev -pspdev master repository -This is a repository for auto-builds of the whole psp toolchain using -GitHub actions. +[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/pspdev/pspdev/CI?label=CI&logo=github&style=for-the-badge)](https://github.com/pspdev/pspdev/actions?query=workflow%3ACI)[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/pspdev/pspdev/CI-Docker?label=CI-Docker&logo=github&style=for-the-badge)](https://github.com/pspdev/pspdev/actions?query=workflow%3ACI-Docker)[![Docker Pulls](https://img.shields.io/docker/pulls/pspdev/pspdev?style=for-the-badge)](https://hub.docker.com/r/pspdev/pspdev/tags) -## Building +Main PSP Repo for building the whole `PSP Development` environment in your local machine. -### Prequisites: +This program will automatically build and install the whole compiler and other tools used in the creation of homebrew software for the Sony PlayStation Portable® videogame system. -#### Linux distributions +## What these scripts do -```console -$ ./depends/check-dependencies.sh +These scripts download (`git clone`) and install: +- [psptoolchain](https://github.com/pspdev/psptoolchain "psptoolchain") +- [pspsdk](https://github.com/pspdev/pspsdk "pspsdk") +- [psp-packages](https://github.com/pspdev/psp-packages "psp-packages") +- [psplinkusb](https://github.com/pspdev/psplinkusb "psplinkusb") +- [ebootsigner](https://github.com/pspdev/ebootsigner "ebootsigner") + +## Requirements + +1. Install gcc/clang, make, cmake, patch, git, texinfo, flex, bison, gettext, wget, gsl, gmp, mpfr, mpc, libusb, readline, libarchive, gpgme, bash, openssl and libtool if you don't have those. +We offer a script to help you for installing dependencies: + +### Ubuntu/Debian +```bash +sudo ./prepare-debian-ubuntu.sh ``` -#### macOS: +### Fedora +```bash +sudo ./prepare-fedora.sh +``` -```console -$ brew bundle +### OSX +```bash +sudo ./prepare-mac-os.sh ``` -### Building the Toolchain +2. _Optional._ If you are upgrading from the previous version of the PSPDEV environment, it is highly recommended to remove the content of the PSPDEV folder before upgrade. This is a necessary step after the major toolchain upgrade. +```bash +sudo rm -rf $PSPDEV +``` -```console -export PSPDEV=/path/to/pspdev +3. Ensure that you have enough permissions for managing PSPDEV location (default to `/usr/local/pspdev`, but you can use a different path). PSPDEV location MUST NOT have spaces or special characters in its path! PSPDEV should be an absolute path. On Unix systems, if the command `mkdir -p $PSPDEV` fails for you, you can set access for the current user by running commands: +```bash +export PSPDEV=/usr/local/pspdev +sudo mkdir -p $PSPDEV +sudo chown -R $USER: $PSPDEV +``` + +4. Add this to your login script (example: `~/.bash_profile`) + **Note:** Ensure that you have full access to the PSPDEV path. You can change the PSPDEV path with the following requirements: only use absolute paths, don't use spaces, only use Latin characters. +```bash +export PSPDEV=/usr/local/pspdev export PATH=$PATH:$PSPDEV/bin -./pspdev.sh ``` -There are specific scripts to aid building in some circumstances: - - `pspdev-local.sh` - - `pspdev-sudo.sh` +5. Run build-all.sh +```bash +./build-all.sh +``` + +## Docker generation + +This repo also uses CI/CD to create a docker image called `pspdev/pspdev:latest` per change. This is useful if you're a developer that wants to create/port an application to the PSP. You can compile your project using this docker image. + +## Extra steps + +If you want, you can _JUST_ install the extra dependencies as `psplinkusb and ebootsigner`. To achieve this execute +```bash +./build-extra.sh +``` + +### macOS + +If you download the pre-built macOS binaries and get a security error such as _`"pspsh" cannot be opened because the developer cannot be verified.`_, you can remove the quarantine attribute by running: +```bash +xattr -dr com.apple.quarantine path/to/prebuilt/pspdev +``` + +## Thanks diff --git a/build-all.sh b/build-all.sh new file mode 100755 index 0000000..aaab6b4 --- /dev/null +++ b/build-all.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# toolchain.sh by fjtrujy + +## Enter the pspdev directory. +cd "$(dirname "$0")" || { echo "ERROR: Could not enter the pspdev directory."; exit 1; } + +## Create the build directory. +mkdir -p build || { echo "ERROR: Could not create the build directory."; exit 1; } + +## Enter the build directory. +cd build || { echo "ERROR: Could not enter the build directory."; exit 1; } + +## 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 + +## Check if repo is in a tag, to install this specfic PSP Dev environment +if git describe --exact-match --tags $(git log -n1 --pretty='%h') >/dev/null 2>&1; then + TAG=$(git describe --exact-match --tags $(git log -n1 --pretty='%h')) + if [ "$TAG" = "latest" ]; then + ## Ignore latest tag, as this tag is for service purposes only + echo "Installing latest environment status" + TAG=""; + else + echo "Instaling specific version $TAG"; + fi +else + echo "Installing latest environment status" + TAG="" +fi + +## Fetch the build scripts. +BUILD_SCRIPTS=($(ls ../scripts/*.sh | sort)) + +## If specific steps were requested... +if [ "$1" ]; then + + ## Run the requested build scripts. + for STEP in "$@"; do "${BUILD_SCRIPTS[$STEP-1]}" "$TAG" || { echo "${BUILD_SCRIPTS[$STEP-1]}: Failed."; exit 1; } done + +else + + ## Run the all build scripts. + for SCRIPT in ${BUILD_SCRIPTS[@]}; do "$SCRIPT" "$TAG" || { echo "$SCRIPT: Failed."; exit 1; } done + +fi diff --git a/build-extra.sh b/build-extra.sh new file mode 100755 index 0000000..8404837 --- /dev/null +++ b/build-extra.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# toolchain.sh by fjtrujy + +## Enter the pspdev directory. +cd "$(dirname "$0")" || { echo "ERROR: Could not enter the pspdev directory."; exit 1; } + +## Create the build directory. +mkdir -p build || { echo "ERROR: Could not create the build directory."; exit 1; } + +## Enter the build directory. +cd build || { echo "ERROR: Could not enter the build directory."; exit 1; } + +## 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 + +## Check if repo is in a tag, to install this specfic PSP Dev environment +if git describe --exact-match --tags $(git log -n1 --pretty='%h') >/dev/null 2>&1; then + TAG=$(git describe --exact-match --tags $(git log -n1 --pretty='%h')) + if [ "$TAG" = "latest" ]; then + ## Ignore latest tag, as this tag is for service purposes only + echo "Installing latest environment status" + TAG=""; + else + echo "Instaling specific version $TAG"; + fi +else + echo "Installing latest environment status" + TAG="" +fi + +## Fetch the build scripts. +BUILD_SCRIPTS=($(ls ../scripts/*extra.sh | sort)) + +## If specific steps were requested... +if [ "$1" ]; then + + ## Run the requested build scripts. + for STEP in "$@"; do "${BUILD_SCRIPTS[$STEP-1]}" "$TAG" || { echo "${BUILD_SCRIPTS[$STEP-1]}: Failed."; exit 1; } done + +else + + ## Run the all build scripts. + for SCRIPT in ${BUILD_SCRIPTS[@]}; do "$SCRIPT" "$TAG" || { echo "$SCRIPT: Failed."; exit 1; } done + +fi diff --git a/common.sh b/common.sh deleted file mode 100644 index b58a643..0000000 --- a/common.sh +++ /dev/null @@ -1,79 +0,0 @@ -# Returns the number of processor cores available -# Usage: num_cpus -function num_cpus -{ - # This *should* be available on literally everything, including OSX - cpus=`getconf _NPROCESSORS_ONLN 2>/dev/null` - # fallback, dual core is a sane default - [ -z "$cpus" ] && cpus="2" - echo $cpus -} - -# Extracts a file based on its extension -# Usage: extract -function auto_extract -{ - path=$1 - name=`echo $path|sed -e "s/.*\///"` - ext=`echo $name|sed -e "s/.*\.//"` - - echo "Extracting $name..." - - case $ext in - "tar") tar --no-same-owner -xf $path ;; - "gz"|"tgz") tar --no-same-owner -xzf $path ;; - "bz2"|"tbz2") tar --no-same-owner -xjf $path ;; - "xz"|"txz") tar --no-same-owner -xJf $path ;; - "zip") unzip $path ;; - *) echo "I don't know how to extract $ext archives!"; return 1 ;; - esac - - return $? -} - -# Downloads and extracts a file, with some extra checks. -# Usage: download_and_extract -function download_and_extract -{ - url=$1 - name=`echo $url|sed -e "s/.*\///"` - outdir=$2 - - # If there are already an extracted directory, delete it, otherwise - # reapplying patches gets messy. - [ -d $outdir ] && echo "Deleting old version of $outdir" && rm -rf $outdir - - # First, if the archive already exists, attempt to extract it. Failing - # that, attempt to continue an interrupted download. If that also fails, - # remove the presumably corrupted file. - [ -f $name ] && auto_extract $name || { wget --continue $url -O $name || rm -f $name; } - - # If the file does not exist at this point, it means it was either never - # downloaded, or it was deleted for being corrupted. Just go ahead and - # download it. - # Using wget --continue here would make buggy servers flip out for nothing. - [ -f $name ] || wget $url -O $name && auto_extract $name -} - -# Clones or updates a Git repository. -# Usage: clone_git_repo -function clone_git_repo -{ - host=$1 - user=$2 - repo=$3 - branch=${4:-master} - - OLDPWD=$PWD - - # Try to update an existing repository at the target path. - # Nuke it if it's corrupted and the pull fails. - [ -d $repo/.git ] && { cd $repo && git pull; } || rm -rf $OLDPWD/$repo - - # The above command may leave us standing in the existing repo. - cd $OLDPWD - - # If it does not exist at this point, it was never there in the first place - # or it was nuked due to being corrupted. Clone and track $branch, please. - [ -d $repo ] || git clone --recursive --depth 1 -b $branch https://$host/$user/$repo.git $repo || return 1 -} diff --git a/depends/check-dependencies.sh b/depends/check-dependencies.sh index 140033e..765dff6 100755 --- a/depends/check-dependencies.sh +++ b/depends/check-dependencies.sh @@ -3,12 +3,14 @@ header_paths=( "/usr/include" \ "/usr/local/include" \ + "/usr/local/opt/" \ "/opt/include" \ "/opt/local/include" \ "/usr/include/$(uname -m)-linux-gnu" \ "/usr/local/include/$(uname -m)-linux-gnu" \ "/usr/include/i386-linux-gnu" \ - "/usr/local/include/i386-linux-gnu" + "/usr/local/include/i386-linux-gnu" \ + "/mingw32/include/" # -- Add more locations here -- ) @@ -48,72 +50,35 @@ function check_program missing_depends+=($1); return 1 } +OSVER=$(uname) + # macOS catalina does not ship headers in default directory anymore if [ "$(uname)" == "Darwin" ]; then header_paths+=("`xcrun --show-sdk-path`/usr/include") fi -check_header libelf elf.h libelf.h libelf/libelf.h gelf.h libelf/gelf.h -check_header libusb usb.h -check_header ncurses ncurses.h ncurses/ncurses.h -check_header zlib zlib.h -check_header libcurl curl/curl.h -check_header gpgme gpgme.h - check_program git -check_program svn -check_program wget check_program patch -check_program tar -check_program unzip -check_program bzip2 -check_program xz - check_program autoconf check_program automake -check_program cmake + +# Disabled pacman for windows +if [ "${OSVER:0:5}" != MINGW ]; then +check_program python3 +check_program pip3 +check_program gpgme-config +check_header openssl openssl/crypto.h openssl/include/openssl/crypto.h +check_header libarchive archive.h libarchive/include/archive.h +fi + check_program make +check_program cmake check_program gcc check_program g++ -check_program m4 check_program bison check_program flex -check_program tclsh -check_program diff -check_program which - -check_program makeinfo -check_program doxygen - -check_program sdl-config - -check_program python3 - -# Sometimes things will be a little different on Mac OS X... -if [ "$(uname)" == "Darwin" ]; then - # readline should be checked carefully on OS X to save us from being - # fooled by BSD libedit. - # libarchive and openssl are keg-only - if brew --version 1>/dev/null 2>&1; then - header_paths+=("`brew --prefix`/opt/readline/include") - header_paths+=("`brew --prefix`/opt/libarchive/include") - header_paths+=("`brew --prefix`/opt/openssl/include") - fi - check_header_nosys libarchive archive.h - check_header_nosys libssl openssl/ssl.h - - check_header_nosys readline readline.h readline/readline.h - - # GNU libtool will be prepended with letter 'g' to prevent conflicts with - # the one comes along with OS X. - check_program glibtoolize -else - check_header libarchive archive.h - check_header libssl openssl/ssl.h - check_header readline readline.h readline/readline.h - check_program libtoolize -fi +check_program libtoolize if [ ${#missing_depends[@]} -ne 0 ]; then echo "Couldn't find dependencies:" diff --git a/depends/check-pspdev.sh b/depends/check-pspdev.sh index 7891813..8a21d44 100755 --- a/depends/check-pspdev.sh +++ b/depends/check-pspdev.sh @@ -1,17 +1,15 @@ #!/bin/sh # check-pspdev.sh by Naomi Peori (naomi@peori.ca) -# Check if $PSPDEV is set. -if test ! $PSPDEV; then - echo "ERROR: Set \$PSPDEV before continuing." - exit 1 -fi +## Check if $PSPDEV is set. +if test ! $PSPDEV; then { echo "ERROR: Set \$PSPDEV before continuing."; exit 1; } fi -# Check for the $PSPDEV directory. +## Check for the $PSPDEV directory. ls -ld $PSPDEV > /dev/null 2>&1 || mkdir -p $PSPDEV > /dev/null 2>&1 || { echo "ERROR: Create $PSPDEV before continuing."; exit 1; } -# Check for write permission. +## Check for write permission. touch $PSPDEV/test.tmp > /dev/null 2>&1 || { echo "ERROR: Grant write permissions for $PSPDEV before continuing."; exit 1; } -# Check for $PSPDEV/bin in the path. +## Check for $PSPDEV/bin in the path. echo $PATH | grep $PSPDEV/bin > /dev/null 2>&1 || { echo "ERROR: Add $PSPDEV/bin to your path before continuing."; exit 1; } + diff --git a/depends/check-sh-is-not-dash.sh b/depends/check-sh-is-not-dash.sh new file mode 100755 index 0000000..99945e5 --- /dev/null +++ b/depends/check-sh-is-not-dash.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +SH_PATH=$(which sh) +if ls -l $SH_PATH|grep dash >/dev/null 2>&1; then + echo "--------------------------------------------------------------------------------" + echo "ERROR: $SH_PATH is a symlink to dash!" + echo "" + echo "This does not go well with libtool, and will make compilation of some packages" + echo "from psplibraries fail to compile." + echo "" + echo "On Debian-derived distros (including Ubuntu), the following will disable dash," + echo "and make $SH_PATH fall back to bash:" + echo "" + echo '$ echo "dash dash/sh boolean false"|sudo debconf-set-selections' + echo '$ sudo dpkg-reconfigure --frontend=noninteractive dash' + echo "" + echo "Replace 'boolean false' with 'boolean true' if you want to go back to dash." + echo "" + echo "The reason why dash is the default on some systems is that letting bash provide" + echo "$SH_PATH makes all shell scripts start up slightly slower." + echo "--------------------------------------------------------------------------------" +fi diff --git a/prepare-debian-ubuntu.sh b/prepare-debian-ubuntu.sh new file mode 100755 index 0000000..38e61da --- /dev/null +++ b/prepare-debian-ubuntu.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Install build dependencies +sudo apt-get install $@ \ + @development-tools gcc gcc-c++ g++ wget git autoconf automake python3 python3-pip make cmake pkgconf \ + libarchive-devel openssl-devel gpgme-devel libtool gettext texinfo bison flex gmp-devel mpfr-devel libmpc-devel ncurses-devel diffutils \ + libusb-devel \ No newline at end of file diff --git a/prepare-fedora.sh b/prepare-fedora.sh new file mode 100755 index 0000000..6ae9ac1 --- /dev/null +++ b/prepare-fedora.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Install build dependencies +sudo dnf install $@ \ + @development-tools gcc gcc-c++ g++ wget git autoconf automake python3 python3-pip make cmake pkgconf \ + libarchive-devel openssl-devel gpgme-devel libtool gettext texinfo bison flex gmp-devel mpfr-devel libmpc-devel ncurses-devel diffutils \ + libusb-devel readline-devel \ No newline at end of file diff --git a/prepare-mac-os.sh b/prepare-mac-os.sh new file mode 100755 index 0000000..41b300f --- /dev/null +++ b/prepare-mac-os.sh @@ -0,0 +1,56 @@ +#!/bin/sh + +show_help() { + echo "Use '-b' or '--brew' to install packages with Homebrew, or use '-p' or '--port' to install with MacPorts." + echo "If left unspecified, tries Homebrew first, then MacPorts." + exit 1 +} + +if [ $# -gt 1 ]; then + echo "Invalid number of command line options." + show_help +fi + +# default is autodetection +try_brew=1 +try_port=1 +if [ $# -eq 1 ]; then + case "$1" in + -b|--brew) + try_port=0 ;; + -p|--port) + try_brew=0 ;; + *) + show_help ;; + esac +fi + +if ! [ -e "/usr/local/bin/brew" -o -e "/opt/local/bin/port" ]; then + echo "Go install Homebrew from http://brew.sh/ or MacPorts from http://www.macports.org/ first, then we can talk!" + exit 1 +fi + +# sanity checks +if [ $try_brew -eq 1 -a ! -e "/usr/local/bin/brew" ]; then + echo "Not trying Homebrew, because it is not installed." + try_brew=0 +fi +if [ $try_port -eq 1 -a ! -e "/opt/local/bin/port" ]; then + echo "Not trying MacPorts, because it is not installed." + try_port=0 +fi +if [ $try_brew -eq 0 -a $try_port -eq 0 ]; then + echo "Invalid package manager specified. Maybe use autodetection." + exit 1 +fi + +# actual installation +if [ $try_brew -eq 1 ]; then + CURRENT_USER=$(stat -f '%Su' /dev/console) + sudo -u $CURRENT_USER brew install autoconf automake cmake gnu-sed bash openssl libtool libarchive gettext texinfo bison flex gsl gmp mpfr + exit +fi +if [ $try_port -eq 1 ]; then + sudo port install autoconf automake cmake doxygen gsed libelf libtool pkgconfig + exit +fi \ No newline at end of file diff --git a/pspdev-local.sh b/pspdev-local.sh deleted file mode 100755 index 4dd72d5..0000000 --- a/pspdev-local.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -# pspdev-local.sh - -export PSPDEV=$(pwd)/pspdev -export PATH=$PATH:$PSPDEV/bin - -./pspdev.sh $@ || { echo "ERROR: Could not run the pspdev script."; exit 1; } diff --git a/pspdev-sudo.sh b/pspdev-sudo.sh deleted file mode 100755 index a49778e..0000000 --- a/pspdev-sudo.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -# pspdev-sudo.sh - -INSTALLDIR=/usr/local/pspdev - -# Enter the pspdev directory -cd "`dirname $0`" || { echo "ERROR: Could not enter the pspdev directory."; exit 1; } - -# Set up the environment -export PSPDEV=$INSTALLDIR -export PATH=$PATH:$PSPDEV/bin - -# Run the pspdev script -./pspdev.sh $@ || { echo "ERROR: Could not run the pspdev script."; exit 1; } diff --git a/pspdev.sh b/pspdev.sh deleted file mode 100755 index fa22f63..0000000 --- a/pspdev.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# pspdev.sh - -# Load and export shared functions -source common.sh -export -f auto_extract -export -f download_and_extract -export -f clone_git_repo - -# Parallelize build -export MAKEFLAGS="-j`num_cpus`" - -# Enter the pspdev directory. -cd "`dirname $0`" || { echo "ERROR: Could not enter the pspdev directory."; exit 1; } - -# Create the build directory. -mkdir -p build || { echo "ERROR: Could not create the build directory."; exit 1; } - -# Enter the build directory. -cd build || { echo "ERROR: Could not enter the build directory."; exit 1; } - -# 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 - -# Fetch the build scripts. -BUILD_SCRIPTS=(`ls ../scripts/*.sh | sort`) - -# If specific steps were requested... -if [ $1 ]; then - # Sort and run the requested build scripts. - ARGS=(`printf "%.2d\n" $* | sort -n`) - - for ARG in ${ARGS[@]}; do - found=0 - for SCRIPT in ${BUILD_SCRIPTS[@]}; do - if [ `basename $SCRIPT | cut -c -2` -eq $ARG ]; then - found=1 - "$SCRIPT" || { echo "$SCRIPT: Failed."; exit 1; } - fi - done - [ $found -eq 1 ] || { echo "$ARG: Script not found."; exit 1; } - done -else - # Run all the existing build scripts. - for SCRIPT in ${BUILD_SCRIPTS[@]}; do - "$SCRIPT" || { echo "$SCRIPT: Failed."; exit 1; } - done -fi diff --git a/scripts/001-psptoolchain.sh b/scripts/001-psptoolchain.sh new file mode 100755 index 0000000..a165ad8 --- /dev/null +++ b/scripts/001-psptoolchain.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# psptoolchain.sh by fjtrujy + +## Download the source code. +REPO_URL="https://github.com/fjtrujy/psptoolchain" +REPO_FOLDER="psptoolchain" +BRANCH_NAME="master" +if test ! -d "$REPO_FOLDER"; then + git clone --depth 1 -b $BRANCH_NAME $REPO_URL && cd $REPO_FOLDER || { exit 1; } +else + cd $REPO_FOLDER && git fetch origin && git reset --hard origin/${BRANCH_NAME} || { exit 1; } +fi + +## Build and install. +./toolchain.sh || { exit 1; } diff --git a/scripts/002-pspsdk.sh b/scripts/002-pspsdk.sh new file mode 100755 index 0000000..562e4c5 --- /dev/null +++ b/scripts/002-pspsdk.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# pspsdk.sh by fjtrujy + +## Download the source code. +REPO_URL="https://github.com/fjtrujy/pspsdk" +REPO_FOLDER="pspsdk" +BRANCH_NAME="master" +if test ! -d "$REPO_FOLDER"; then + git clone --depth 1 -b $BRANCH_NAME $REPO_URL && cd $REPO_FOLDER || { exit 1; } +else + cd $REPO_FOLDER && git fetch origin && git reset --hard origin/${BRANCH_NAME} || { exit 1; } +fi + +## Determine the maximum number of processes that Make can work with. +PROC_NR=$(getconf _NPROCESSORS_ONLN) + +## Boostrap and config +./bootstrap || { exit 1; } +./configure --quiet || { exit 1; } + +## Compile and install. +make --quiet -j $PROC_NR clean || { exit 1; } +make --quiet -j $PROC_NR all || { exit 1; } +make --quiet -j $PROC_NR install || { exit 1; } +make --quiet -j $PROC_NR clean || { exit 1; } + +## gcc needs to include libcglue libpsputility libpsprtc libpspnet_inet libpspnet_resolver libpspuser libpspkernel +## from pspsdk to be able to build executables, because they are part of the standard libraries +ln -sf "$PSPDEV/psp/sdk/lib/libcglue.a" "$PSPDEV/psp/lib/libcglue.a" || { exit 1; } +ln -sf "$PSPDEV/psp/sdk/lib/libpsputility.a" "$PSPDEV/psp/lib/libpsputility.a" || { exit 1; } +ln -sf "$PSPDEV/psp/sdk/lib/libpsprtc.a" "$PSPDEV/psp/lib/libpsprtc.a" || { exit 1; } +ln -sf "$PSPDEV/psp/sdk/lib/libpspnet_inet.a" "$PSPDEV/psp/lib/libpspnet_inet.a" || { exit 1; } +ln -sf "$PSPDEV/psp/sdk/lib/libpspnet_resolver.a" "$PSPDEV/psp/lib/libpspnet_resolver.a" || { exit 1; } +ln -sf "$PSPDEV/psp/sdk/lib/libpspuser.a" "$PSPDEV/psp/lib/libpspuser.a" || { exit 1; } +ln -sf "$PSPDEV/psp/sdk/lib/libpspkernel.a" "$PSPDEV/psp/lib/libpspkernel.a" || { exit 1; } \ No newline at end of file diff --git a/scripts/003-psp-packages.sh b/scripts/003-psp-packages.sh new file mode 100755 index 0000000..bf730fe --- /dev/null +++ b/scripts/003-psp-packages.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# psp-packages by fjtrujy + +## Download the source code. +REPO_URL="https://github.com/fjtrujy/psp-packages" +REPO_FOLDER="psp-packages" +BRANCH_NAME="master" +if test ! -d "$REPO_FOLDER"; then + git clone --depth 1 -b $BRANCH_NAME $REPO_URL && cd $REPO_FOLDER || { exit 1; } +else + cd $REPO_FOLDER && git fetch origin && git reset --hard origin/${BRANCH_NAME} || { exit 1; } +fi + + +# WIndows currently doesn't have pacman, so packages needs to be installed manually +OSVER=$(uname) +install_method="pacman" +if [ "${OSVER:0:5}" == MINGW ]; then + install_method="manually" +fi + +# Install all packages +./install-latest.sh "fjtrujy/psp-packages" $install_method || { exit 1; } \ No newline at end of file diff --git a/scripts/004-psplinkusb-extra.sh b/scripts/004-psplinkusb-extra.sh new file mode 100755 index 0000000..ccdfe34 --- /dev/null +++ b/scripts/004-psplinkusb-extra.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# psplinkusb by fjtrujy + +## Download the source code. +REPO_URL="https://github.com/fjtrujy/psplinkusb" +REPO_FOLDER="psplinkusb" +BRANCH_NAME="master" +if test ! -d "$REPO_FOLDER"; then + git clone --depth 1 -b $BRANCH_NAME $REPO_URL && cd $REPO_FOLDER || { exit 1; } +else + cd $REPO_FOLDER && git fetch origin && git reset --hard origin/${BRANCH_NAME} || { exit 1; } +fi + +## Determine the maximum number of processes that Make can work with. +PROC_NR=$(getconf _NPROCESSORS_ONLN) +OSVER=$(uname) + +## Compile and install. +make --quiet -j $PROC_NR clean || { exit 1; } +make --quiet -j $PROC_NR all || { exit 1; } +# WIndows currently can't compile pspsh, usbhostfs_pc +if [ "${OSVER:0:5}" != MINGW ]; then + make --quiet -j $PROC_NR -C pspsh install || { exit 1; } + make --quiet -j $PROC_NR -C usbhostfs_pc install || { exit 1; } +fi diff --git a/scripts/005-ebootsigner-extra.sh b/scripts/005-ebootsigner-extra.sh new file mode 100755 index 0000000..c6aff68 --- /dev/null +++ b/scripts/005-ebootsigner-extra.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# ebootsigner by fjtrujy + +## Download the source code. +REPO_URL="https://github.com/pspdev/ebootsigner" +REPO_FOLDER="ebootsigner" +BRANCH_NAME="master" +if test ! -d "$REPO_FOLDER"; then + git clone --depth 1 -b $BRANCH_NAME $REPO_URL && cd $REPO_FOLDER || { exit 1; } +else + cd $REPO_FOLDER && git fetch origin && git reset --hard origin/${BRANCH_NAME} || { exit 1; } +fi + +## Determine the maximum number of processes that Make can work with. +PROC_NR=$(getconf _NPROCESSORS_ONLN) + +## Compile and install. +make --quiet -j $PROC_NR clean || { exit 1; } +make --quiet -j $PROC_NR all || { exit 1; } +make --quiet -j $PROC_NR install || { exit 1; } +make --quiet -j $PROC_NR clean || { exit 1; } diff --git a/scripts/01-psptoolchain.sh b/scripts/01-psptoolchain.sh deleted file mode 100755 index c72f25a..0000000 --- a/scripts/01-psptoolchain.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -# psptoolchain.sh - -# Exit on errors -set -e - -# Download the source code. -clone_git_repo github.com pspdev psptoolchain toolchain-only - -# Enter the source directory. -cd psptoolchain - -# Configure the build. -./toolchain.sh diff --git a/scripts/02-pspsdk-stage2.sh b/scripts/02-pspsdk-stage2.sh deleted file mode 100755 index f21d63c..0000000 --- a/scripts/02-pspsdk-stage2.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -# pspsdk-stage2.sh - -# Exit on errors -set -e - -# Download the source code if it does not already exist. -clone_git_repo github.com pspdev pspsdk - -# Enter the source directory. -cd pspsdk - -# Bootstrap the source. -./bootstrap - -# Mac OS X fix -if [ "$(uname)" == "Darwin" ]; then - export CFLAGS="$CFLAGS -I/opt/local/include" - export CPPFLAGS="$CPPFLAGS -I/opt/local/include" - export LDFLAGS="$LDFLAGS -L/opt/local/lib" -fi - -# Configure the build. -./configure --with-pspdev="$PSPDEV" - -# Build and install. -make clean -make -make install diff --git a/scripts/03-psplinkusb.sh b/scripts/03-psplinkusb.sh deleted file mode 100755 index 594f7ec..0000000 --- a/scripts/03-psplinkusb.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -# psplinkusb.sh - -# Exit on errors -set -e - -# Download the source code if it does not already exist -clone_git_repo github.com pspdev psplinkusb - -# Enter the source directory -cd psplinkusb - -# Mac OS X fix -if [ "$(uname)" == "Darwin" ]; then - if [ -d /opt/local/include ] && [ -d /opt/local/lib ]; then # MacPorts - export C_INCLUDE_PATH="/opt/local/include" - export CPLUS_INCLUDE_PATH="/opt/local/include" - export LIBRARY_PATH="/opt/local/lib" - elif brew --version 1>/dev/null 2>&1; then # Homebrew - HOMEBREW_PREFIX=$(brew --prefix) - export C_INCLUDE_PATH="$HOMEBREW_PREFIX/include:$HOMEBREW_PREFIX/opt/readline/include" - export CPLUS_INCLUDE_PATH="$C_INCLUDE_PATH" - export LIBRARY_PATH="$HOMEBREW_PREFIX/lib:$HOMEBREW_PREFIX/opt/readline/lib" - else - # Additional package manager/well-known locations? Add them here... - echo "WARNING: using libreadline from OS X, this may lead to compilation issues" - fi -fi - -## Build and install. -make -f Makefile.clients clean -make -f Makefile.clients -make -f Makefile.clients install diff --git a/scripts/04-ebootsigner.sh b/scripts/04-ebootsigner.sh deleted file mode 100755 index 50b210e..0000000 --- a/scripts/04-ebootsigner.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -# ebootsigner.sh - -# Exit on errors -set -e - -# Download the source code if it does not already exist. -clone_git_repo github.com pspdev ebootsigner - -# Enter the source directory. -cd ebootsigner - -# Build and install -make clean -make -make install diff --git a/scripts/05-psp-pkg-config.sh b/scripts/05-psp-pkg-config.sh deleted file mode 100755 index 02b8505..0000000 --- a/scripts/05-psp-pkg-config.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -# psp-pkg-config.sh - -# Exit on errors -set -e - -# Download the source code. -clone_git_repo github.com pspdev psp-pkgconf - -# Enter the source directory. -cd psp-pkgconf - -# Build and install. -make clean -make -make install diff --git a/scripts/06-psp-pacman.sh b/scripts/06-psp-pacman.sh deleted file mode 100755 index 3e3d2f9..0000000 --- a/scripts/06-psp-pacman.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -# psp-pacman.sh - -# Exit on errors -set -e - -# Download the source code. -clone_git_repo github.com pspdev psp-pacman ci - -# Enter the source directory. -cd psp-pacman - -# Build and install -./pacman.sh diff --git a/scripts/07-psplibraries.sh b/scripts/07-psplibraries.sh deleted file mode 100755 index 233d5b9..0000000 --- a/scripts/07-psplibraries.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -# psplibraries.sh - -# Exit on errors -set -e - -# Download the source code. -clone_git_repo github.com pspdev psplibraries - -# Enter the source directory. -cd psplibraries - -# Configure the build. -./libraries.sh diff --git a/scripts/10-profile.sh b/scripts/10-profile.sh deleted file mode 100755 index cffd969..0000000 --- a/scripts/10-profile.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -echo "Remember to add $PSPDEV/bin to your path. Add the following to e.g. .bashrc:" - -echo "export PSPDEV=$PSPDEV" -echo "export PATH=\$PATH:\$PSPDEV/bin"