Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
24bd6b2
Initial commit
sharkwouter May 8, 2020
2fc60f5
Added dependencies to README
sharkwouter May 8, 2020
333f275
Initial working version
sharkwouter May 8, 2020
acd6a51
Use sudo if needed
sharkwouter May 8, 2020
a01f4b6
Update README
sharkwouter May 8, 2020
6772357
Add usage info to README
sharkwouter May 8, 2020
5706f24
Fix wording and formatting in usage part of README
sharkwouter May 8, 2020
7e426de
Added how to install to building part of README as well
sharkwouter May 8, 2020
44b5264
Use different root and dbpath on systems with their own pacman
sharkwouter May 8, 2020
70e721c
Fix syntax error in psp-pacman script
sharkwouter May 8, 2020
4155ba4
Fix makepkg.conf path
sharkwouter May 8, 2020
6910bd8
Don't use sudo for the T and Q options of pacman
sharkwouter May 8, 2020
7306cea
Update README to include info on changed root directory
sharkwouter May 8, 2020
8e05d0f
Add architecture to README
sharkwouter May 8, 2020
99ce595
Add Arch dependencies
sharkwouter May 8, 2020
a6458d1
Only create build dir if needed
sharkwouter May 8, 2020
a684fc2
Use psp-strip in makepkg
sharkwouter May 8, 2020
29af82f
Use $PSPDEV as root-path for pacman
sharkwouter May 9, 2020
92a21a9
Merge branch 'master' of github.com:sharkwouter/psp-pacman
sharkwouter May 9, 2020
922da0e
Update README to reflect new root-path for pacman
sharkwouter May 9, 2020
49274d2
Merge branch 'sharkwouter/psp-pacman/master' into upstream-pr
sharkwouter May 9, 2020
3499483
Don't ask for a password for -V and -h either
sharkwouter May 10, 2020
494c866
Don't use sudo for some long options either
sharkwouter May 10, 2020
d314247
Add pacman binary dir to path in wrappers
sharkwouter May 11, 2020
f304499
Install in $PSPDEV and don't require patch
sharkwouter May 11, 2020
aa5c9ac
Replace patch with upstream WIP patch
sharkwouter May 11, 2020
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.swp
*~
build/
24 changes: 24 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

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 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.

For more information, please refer to <http://unlicense.org/>
61 changes: 59 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,59 @@
# psp-pacman
Package manager for ported libraries
# PSP Pacman

This respository contains all the files needed to build and install the pacman package managed for the PSP toolchain. Pacman can be used to build and manage packages with libraries for the PSP.

This package provides the following commands:
- **psp-pacman** - Allows users to install and manage PSP library packages.
- **psp-makepkg** - Allows users to build packages from PSPBUILD files.

## Dependencies

On Ubuntu/Debian, the following packages need to be installed:
- libarchive-dev
- libcurl4-openssl-dev
- libssl-dev
- pkg-config
- python3
- python3-venv

On Arch/Manjaro, the following packages need to be installed:
- base-devel

Besides that, the [PSP toolchain](https://github.com/pspdev/psptoolchain) will need to be installed before installing this.

## Installation
1. Install the dependencies.
2. Make sure the environment variable ``$PSPDEV`` is set in your shell. Use ``echo $PSPDEV`` to confirm this.
3. If ``$PSPDEV`` is set to ``/usr/local/pspdev``, install with the following command:
```
sudo ./pacman-sudo.sh
```
If you've installed the PSP toolchain in a user writable location use:
```
./pacman.sh
```

## Usage

Here is how to use ``psp-pacman`` and ``psp-makepkg``.

### Installing a package

Installing a ``*.pkg.tar.gz`` package with a PSP library can be done with:
```
psp-pacman -U package-name-1.0.2.pkg.tar.gz
```

### Building a package

Building a package requires a ``PSPBUILD`` script. Here is [an example](https://git.archlinux.org/pacman.git/plain/proto/PKGBUILD.proto) and [some documentation on which options are available](https://wiki.archlinux.org/index.php/PKGBUILD). Do **not** call it ``PKGBUILD``, though, use ``PSPBUILD`` instead. Also make sure to install libraries in ``$pkgdir/psp/lib`` in your build script, since this will translate to ``$PSPDEV/psp/lib`` when installing. The architecure expected is mips.

Packages can be build by running the following command in a directory with a PSPBUILD file in it:
```
psp-makepkg
```

This will create a file called something like ``package-name-1.0.2.pkg.tar.gz``. This file can be shared or installed. Installing would be done using the following command:
```
psp-pacman -U package-name-1.0.2.pkg.tar.gz
```
56 changes: 56 additions & 0 deletions common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Usage: extract <archive>
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 ;;
"zip") unzip $path ;;
*) echo "I don't know how to extract $ext archives!"; return 1 ;;
esac

return $?
}

# Usage: download_and_extract URL DIRECTORY
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. I tried.
[ -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 --no-check-certificate $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 --no-check-certificate $url -O $name && auto_extract $name

# Switch to the newly created directory
cd $outdir || return 1
}

function apply_patch {
patch -p1 < "${BASE_PATH}/patches/$1.patch"
}

## Install meson and ninja in the current directory using a venv
function setup_build_system {
python3 -m venv venv
. venv/bin/activate
pip install meson ninja
}
148 changes: 148 additions & 0 deletions config/makepkg.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
#!/hint/bash
#
# ${PSPDEV}/pacman/share/etc/makepkg.conf
#
#########################################################################
# SOURCE ACQUISITION
#########################################################################
#
#-- The download utilities that makepkg should use to acquire sources
# Format: 'protocol::agent'
DLAGENTS=('file::/usr/bin/curl -gqC - -o %o %u'
'ftp::/usr/bin/curl -gqfC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
'http::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
'https::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
'rsync::/usr/bin/rsync --no-motd -z %u %o'
'scp::/usr/bin/scp -C %u %o')

# Other common tools:
# /usr/bin/snarf
# /usr/bin/lftpget -c
# /usr/bin/wget

#-- The package required by makepkg to download VCS sources
# Format: 'protocol::package'
VCSCLIENTS=('bzr::bzr'
'git::git'
'hg::mercurial'
'svn::subversion')

#########################################################################
# ARCHITECTURE, COMPILE FLAGS
#########################################################################
#
AR="psp-ar"
RANLIB="psp-ranlib"
CC="psp-gcc"
CXX="psp-g++"
CARCH="mips"
CHOST="psp"

#-- Compiler and Linker Flags
#CPPFLAGS=""
#CFLAGS="-O2 -pipe"
#CXXFLAGS="-O2 -pipe"
#LDFLAGS=""
#-- Make Flags: change this for DistCC/SMP systems
MAKEFLAGS="-j$(nproc --all)"
#-- Debugging flags
#DEBUG_CFLAGS="-g"
#DEBUG_CXXFLAGS="-g"

#########################################################################
# BUILD ENVIRONMENT
#########################################################################
#
# Defaults: BUILDENV=(!distcc !color !ccache check !sign)
# A negated environment option will do the opposite of the comments below.
#
#-- distcc: Use the Distributed C/C++/ObjC compiler
#-- color: Colorize output messages
#-- ccache: Use ccache to cache compilation
#-- check: Run the check() function if present in the PKGBUILD
#-- sign: Generate PGP signature file
#
BUILDENV=(!distcc color !ccache check !sign)
#
#-- If using DistCC, your MAKEFLAGS will also need modification. In addition,
#-- specify a space-delimited list of hosts running in the DistCC cluster.
#DISTCC_HOSTS=""
#
#-- Specify a directory for package building.
#BUILDDIR=/tmp/makepkg

#########################################################################
# GLOBAL PACKAGE OPTIONS
# These are default values for the options=() settings
#########################################################################
#
# Default: OPTIONS=(!strip docs libtool staticlibs emptydirs !zipman !purge !debug)
# A negated option will do the opposite of the comments below.
#
#-- strip: Strip symbols from binaries/libraries
#-- docs: Save doc directories specified by DOC_DIRS
#-- libtool: Leave libtool (.la) files in packages
#-- staticlibs: Leave static library (.a) files in packages
#-- emptydirs: Leave empty directories in packages
#-- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip
#-- purge: Remove files specified by PURGE_TARGETS
#-- debug: Add debugging flags as specified in DEBUG_* variables
#
OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !debug)

#-- File integrity checks to use. Valid: ck, md5, sha1, sha224, sha256, sha384, sha512, b2
INTEGRITY_CHECK=(ck)
#-- Options to be used when stripping binaries. See `man strip' for details.
STRIP_BINARIES="--strip-all"
#-- Options to be used when stripping shared libraries. See `man strip' for details.
STRIP_SHARED="--strip-unneeded"
#-- Options to be used when stripping static libraries. See `man strip' for details.
STRIP_STATIC="--strip-debug"
#-- Manual (man and info) directories to compress (if zipman is specified)
MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info})
#-- Doc directories to remove (if !docs is specified)
DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc})
#-- Files to be removed from all packages (if purge is specified)
PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod)
#-- Directory to store source code in for debug packages
DBGSRCDIR="/usr/src/debug"

#########################################################################
# PACKAGE OUTPUT
#########################################################################
#
# Default: put built package and cached source in build directory
#
#-- Destination: specify a fixed directory where all packages will be placed
#PKGDEST=/home/packages
#-- Source cache: specify a fixed directory where source files will be cached
#SRCDEST=/home/sources
#-- Source packages: specify a fixed directory where all src packages will be placed
#SRCPKGDEST=/home/srcpackages
#-- Log files: specify a fixed directory where all log files will be placed
#LOGDEST=/home/makepkglogs
#-- Packager: name/email of the person or organization building packages
#PACKAGER="John Doe <john@doe.com>"
#-- Specify a key to use for package signing
#GPGKEY=""

#########################################################################
# COMPRESSION DEFAULTS
#########################################################################
#
COMPRESSGZ=(gzip -c -f -n)
COMPRESSBZ2=(bzip2 -c -f)
COMPRESSXZ=(xz -c -z -)
COMPRESSZST=(zstd -c -z -q -)
COMPRESSLRZ=(lrzip -q)
COMPRESSLZO=(lzop -q)
COMPRESSZ=(compress -c -f)
COMPRESSLZ4=(lz4 -q)
COMPRESSLZ=(lzip -c -f)

#########################################################################
# EXTENSION DEFAULTS
#########################################################################
#
PKGEXT='.pkg.tar.gz'
SRCEXT='.src.tar.gz'
77 changes: 77 additions & 0 deletions config/pacman.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#
# # ${PSPDEV}/pacman/share/etc/pacman.conf
#
# See the pacman.conf(5) manpage for option and repository directives

#
# GENERAL OPTIONS
#
[options]
# The following paths are commented out with their default values listed.
# If you wish to use different paths, uncomment and update the paths.
#RootDir = /usr/local/pspdev/psp
#DBPath = /usr/local/pspdev/var/lib/pacman/
#CacheDir = /usr/local/pspdev/var/cache/pacman/pkg/
#LogFile = /usr/local/pspdev/var/log/pacman.log
#GPGDir = /usr/local/pspdev/etc/pacman.d/gnupg/
#HookDir = /usr/local/pspdev/etc/pacman.d/hooks/
#HoldPkg = pacman glibc
#XferCommand = /usr/bin/curl -L -C - -f -o %o %u
#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u
#CleanMethod = KeepInstalled
Architecture = mips

# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup
#IgnorePkg =
#IgnoreGroup =

#NoUpgrade =
#NoExtract =

# Misc options
#UseSyslog
#Color
#NoProgressBar
#TotalDownload
CheckSpace
#VerbosePkgLists

# PGP signature checking
#SigLevel = Optional
#LocalFileSigLevel = Optional
#RemoteFileSigLevel = Optional

#
# REPOSITORIES
# - can be defined here or included from another file
# - pacman will search repositories in the order defined here
# - local/custom mirrors can be added here or in separate files
# - repositories listed first will take precedence when packages
# have identical names, regardless of version number
# - URLs will have $repo replaced by the name of the current repo
# - URLs will have $arch replaced by the name of the architecture
#
# Repository entries are of the format:
# [repo-name]
# Server = ServerName
# Include = IncludePath
#
# The header [repo-name] is crucial - it must be present and
# uncommented to enable the repo.
#

# An example of a disabled remote package repository with multiple servers
# available. To enable, uncomment the following lines. You can add preferred
# servers immediately after the header and they will be used before the
# default mirrors.
#[core]
#SigLevel = Required
#Server = ftp://ftp.example.com/foobar/$repo/os/$arch/
# The file referenced here should contain a list of 'Server = ' lines.
#Include = /usr/local/pspdev/etc/pacman.d/mirrorlist

# An example of a custom package repository. See the pacman manpage for
# tips on creating your own repositories.
#[custom]
#SigLevel = Optional TrustAll
#Server = file:///home/custompkgs
11 changes: 11 additions & 0 deletions pacman-sudo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
# pacman-sudo.sh by Wouter Wijsman (wwijsman@live.nl)

## Enter the psp-pacman directory.
cd "$(dirname "$0")" || { echo "ERROR: Could not enter the psp-pacman directory."; exit 1; }

export PSPDEV=/usr/local/pspdev
export PATH=$PATH:$PSPDEV/bin

## Run the pacman script.
./pacman.sh $@ || { echo "ERROR: Could not run the pacman script."; exit 1; }
Loading