221 lines
9.8 KiB
Bash
Executable file
221 lines
9.8 KiB
Bash
Executable file
#!/bin/sh
|
|
set -e
|
|
# TODO: Source code line counting.
|
|
mirrordir="$HOME/sortix/mirror"
|
|
portsdir="$HOME/sortix/ports"
|
|
porttixdir="$HOME/src/porttix"
|
|
srctixdir="$HOME/src/srctix"
|
|
mkdir -p "$mirrordir"
|
|
mkdir -p "$portsdir"
|
|
cd "$portsdir"
|
|
ports=$(ls "$porttixdir" | grep -E '\.porttix\.tar\.xz$' | grep -Eo '^[^.]*')
|
|
for port in $ports; do
|
|
cd "$portsdir"
|
|
# TODO: Retain non-free ports somewhere.
|
|
case "$port" in quake|quake-shareware) continue;; esac
|
|
# TODO: Publish imported OpenBSD stuff as Sortix provided tarballs.
|
|
case "$port" in
|
|
cut|ed|video-player|xargs) no_upstream=true;;
|
|
*) no_upstream=false;;
|
|
esac
|
|
if [ -e "$portsdir/$port/$port.info" ]; then
|
|
continue
|
|
:
|
|
fi
|
|
tar -xf "$porttixdir/$port.porttix.tar.xz"
|
|
tar -xf "$srctixdir/$port.srctix.tar.xz" "$port/tixbuildinfo"
|
|
cd "$portsdir/$port"
|
|
nolib=$(echo "$port" | sed -E 's/^lib//')
|
|
build_libraries=$(grep -E '^pkg\.build-libraries=' tixbuildinfo | sed -E 's/^[^=]*=//')
|
|
source_package=$(grep -E '^pkg\.source-package=' tixbuildinfo | sed -E 's/^[^=]*=//')
|
|
rm -f "$port.info.new"
|
|
echo "NAME='$port'" >> "$port.info.new"
|
|
if [ -n "$source_package" ]; then
|
|
rm -f "$port.tar.xz"
|
|
files=
|
|
echo "SOURCE_PACKAGE='$source_package'" >> "$port.info.new"
|
|
else
|
|
files=$(grep -E '^tar_extract ' porttixinfo | sed -E 's/^tar_extract //')
|
|
echo "BUILD_LIBRARIES='$build_libraries'" >> "$port.info.new"
|
|
fi
|
|
if [ "$files" = SDL-1.2.15.tar.gz ]; then
|
|
rm SDL-1.2.15.tar.gz
|
|
wget https://pub.sortix.org/fork/libSDL/sortix-libSDL-1.2.15.tar.xz -O sortix-libSDL-1.2.15.tar.xz
|
|
tar -xf sortix-libSDL-1.2.15.tar.xz
|
|
mv sortix-libSDL-1.2.15 "$port.normalized"
|
|
(cd $srctixdir && git checkout staging)
|
|
tar -xf "$srctixdir/$port.srctix.tar.xz"
|
|
(cd $srctixdir && git checkout -)
|
|
mv "$port" "$port.srctix"
|
|
diff --no-dereference -Naur "$port.normalized" "$port.srctix" > "patch.patch" || true
|
|
tix-execdiff "$port.normalized" "$port.srctix" > "patch.execpatch"
|
|
true > "patch.normalize"
|
|
rm -rf "$port.normalized"
|
|
rm -rf "$port.srctix"
|
|
files="sortix-libSDL-1.2.15.tar.xz"
|
|
fi
|
|
case "$port" in
|
|
bison|grep|tar|wget)
|
|
echo "rm -rf -- 'doc/stamp-vti'" >> "patch.normalize"
|
|
;;
|
|
emacs)
|
|
echo "rm -rf -- 'admin/charsets/charsets.stamp'" >> "patch.normalize"
|
|
echo "rm -rf -- 'etc/charsets/JISX2131.map'" >> "patch.normalize"
|
|
;;
|
|
grub)
|
|
echo "rm -rf -- 'docs/stamp-1'" >> "patch.normalize"
|
|
echo "rm -rf -- 'docs/stamp-vti'" >> "patch.normalize"
|
|
;;
|
|
libidn)
|
|
# TODO: Which of these were actually a problem?
|
|
echo "rm -rf -- 'doc/Makefile.gdoc'" >> "patch.normalize"
|
|
echo "rm -rf -- 'doc/stamp-vti'" >> "patch.normalize"
|
|
;;
|
|
texinfo)
|
|
echo "rm -rf -- 'doc/Makefile.gdoc'" >> "patch.normalize"
|
|
echo "rm -rf -- 'doc/stamp-1'" >> "patch.normalize"
|
|
echo "rm -rf -- 'doc/stamp-vti'" >> "patch.normalize"
|
|
;;
|
|
libglib)
|
|
echo "rm -rf -- 'tests/gobject/testmarshal.h'" >> "patch.normalize"
|
|
echo "rm -rf -- 'tests/gobject/testmarshal.c'" >> "patch.normalize"
|
|
;;
|
|
python)
|
|
echo "rm -rf -- 'Python/graminit.c'" >> "patch.normalize"
|
|
# TODO: This file has to exist and be writeable. Sigh.
|
|
#echo "rm -rf -- 'Include/graminit.h'" >> "patch.normalize"
|
|
echo "rm -rf -- 'Python/importlib_external.h'" >> "patch.normalize"
|
|
echo "rm -rf -- 'Python/importlib.h'" >> "patch.normalize"
|
|
;;
|
|
nyancat)
|
|
sed -Ei 's,^(\+include )(\.\./\.\./build-aux/),\1../\2,' "patch.patch"
|
|
;;
|
|
esac
|
|
if $no_upstream; then
|
|
mkdir "$port.normalized"
|
|
mkdir "$port.srctix"
|
|
for file in $files; do
|
|
tar -C "$port.srctix" --strip-components=1 -xf "$file"
|
|
rm -f "$file"
|
|
done
|
|
files=
|
|
sed -Ei 's,^(include )(\.\./\.\./build-aux/),\1../\2,' "$port.srctix/Makefile"
|
|
diff --no-dereference -Naur "$port.normalized" "$port.srctix" > "patch.patch" || true
|
|
true > "patch.execpatch"
|
|
true > "patch.normalize"
|
|
rmdir "$port.normalized"
|
|
rm -rf "$port.srctix"
|
|
fi
|
|
file_number=0
|
|
for file in $files; do
|
|
file_number=$(expr $file_number + 1)
|
|
if [ $file_number = 1 ]; then
|
|
file_number_suffix=
|
|
else
|
|
file_number_suffix=_$file_number
|
|
fi
|
|
mirror_file="$file"
|
|
distname=$(echo "$file" | sed -E 's,\.tar.*,,')
|
|
if [ "$port" = vim -a "$file" = vim-8.0.tar.bz2 -a "$(sha256sum -- "$file")" = "acab24b07d9e87a1c1581cf5ecfe0439562ff7e111d0d2dbd274260490cb64e8 $file" ]; then
|
|
version=vim-8.0.002
|
|
mirror_file="$version.tar.bz2"
|
|
fi
|
|
version=$(echo "$distname" | sed -E 's/.*-([0-9]+\..*)/\1/')
|
|
version_major=$(echo "$version" | sed -E 's/([^.]+).*/\1/')
|
|
version_minor=$(echo "$version" | sed -E 's/([^.]+\.){1}([^.]+).*/\2/')
|
|
version_patch=$(echo "$version" | sed -E 's/([^.]+\.){2}([^.]+).*/\2/')
|
|
case "$port" in
|
|
ag) mirrors="https://geoff.greer.fm/ag/releases";;
|
|
binutils|gcc|libstdc++|grub) mirrors="https://pub.sortix.org/sortix/toolchain";;
|
|
bochs) mirrors="https://sourceforge.net/projects/bochs/files/bochs/$version";;
|
|
bzip2) mirrors="https://sourceware.org/pub/bzip2";;
|
|
dash) mirrors="http://gondor.apana.org.au/~herbert/dash/files";;
|
|
e2fsprogs) mirrors="https://kernel.org/pub/linux/kernel/people/tytso/e2fsprogs/v$version";;
|
|
ffmpeg) mirrors="https://ffmpeg.org/releases";;
|
|
flex) mirrors="https://sourceforge.net/projects/flex/files https://github.com/westes/flex/releases/download/v$version";;
|
|
git) mirrors="https://www.kernel.org/pub/software/scm/git";;
|
|
libcairo|libpixman) mirrors="https://www.cairographics.org/releases";;
|
|
libcurl) mirrors="https://curl.se/download";;
|
|
libcurses) mirrors="https://github.com/sabotage-linux/netbsd-curses/releases/download/v$version";;
|
|
libdbus) mirrors="https://dbus.freedesktop.org/releases/dbus";;
|
|
libevent) mirrors="https://github.com/libevent/libevent/releases/download/release-$version";;
|
|
libexpat) mirrors="https://github.com/libexpat/libexpat/releases/download/R_${version_major}_${version_minor}_${version_patch}";;
|
|
libffi) mirrors="https://github.com/libffi/libffi/releases/download/v$version https://sourceware.org/pub/libffi";;
|
|
libfontconfig) mirrors="https://www.freedesktop.org/software/fontconfig/release";;
|
|
libfreetype) mirrors="https://download.savannah.gnu.org/releases/freetype";;
|
|
libglib) mirrors="https://download.gnome.org/sources/glib/$version_major.$version_minor";;
|
|
# TODO: Checksum issues because the upstream file changed.
|
|
# libjpeg) mirrors="https://ijg.org/files";;
|
|
libjpeg) mirrors="https://pub.sortix.org/mirror/libjpeg";;
|
|
libogg|libtheora|libvorbis) mirrors="https://ftp.osuosl.org/pub/xiph/releases/$nolib";;
|
|
libpcre) mirrors="https://sourceforge.net/projects/pcre/files/pcre/$version";;
|
|
libpng) mirrors="https://sourceforge.net/projects/libpng/files/libpng${version_major}${version_minor}/older-releases/$version";;
|
|
#libSDL) mirrors="https://www.libsdl.org/release";;
|
|
libSDL) mirrors="https://pub.sortix.org/fork/libSDL";;
|
|
libssl) mirrors="https://ftp.openbsd.org/pub/OpenBSD/LibreSSL";;
|
|
libxkbcommon) mirrors="https://xkbcommon.org/download";;
|
|
libxml2) mirrors="ftp://xmlsoft.org/libxml2";;
|
|
libz) mirrors="https://pub.sortix.org/libz/release";;
|
|
lua) mirrors="https://www.lua.org/ftp";;
|
|
mdocml) mirrors="https://mandoc.bsd.lv/snapshots";;
|
|
nasm) mirrors="https://www.nasm.us/pub/nasm/releasebuilds/$version";;
|
|
nyancat) mirrors="https://github.com/klange/nyancat/archive/refs/tags"; mirror_file="$version.tar.gz";;
|
|
perl)
|
|
case "$file" in
|
|
perl-cross-*) mirrors="https://github.com/arsv/perl-cross/releases/download/$version";;
|
|
*) mirrors="https://www.cpan.org/src/5.0";;
|
|
esac;;
|
|
pkg-config) mirrors="https://pkgconfig.freedesktop.org/releases";;
|
|
python) mirrors="https://www.python.org/ftp/python/$version";;
|
|
qemu) mirrors="https://download.qemu.org";;
|
|
vim) mirrors="ftp://ftp.vim.org/pub/vim/unix";;
|
|
xz) mirrors="https://tukaani.org/xz";;
|
|
*) mirrors="https://ftp.gnu.org/gnu/$port https://ftp.gnu.org/gnu/$nolib";;
|
|
esac
|
|
mirrors="$(echo "$mirrors" | tr ' ' '\n' | uniq)"
|
|
found_mirror=
|
|
for mirror in $mirrors; do
|
|
echo trying "$mirror/$mirror_file"
|
|
if wget -q "$mirror/$mirror_file" -O $file.dl; then
|
|
cmp "$file" "$file.dl"
|
|
rm "$file.dl"
|
|
found_mirror="$mirror"
|
|
break
|
|
fi
|
|
done
|
|
if [ -z "$found_mirror" ]; then
|
|
echo "$port failed to find $file"
|
|
exit 1
|
|
else
|
|
sha256sum=$(sha256sum "$file" | grep -Eo '^[^ ]*')
|
|
echo "VERSION${file_number_suffix}='$version'" >> "$port.info.new"
|
|
echo "DISTNAME${file_number_suffix}='$distname'" >> "$port.info.new"
|
|
echo "ARCHIVE${file_number_suffix}='$file'" >> "$port.info.new"
|
|
echo "SHA256SUM${file_number_suffix}='$sha256sum'" >> "$port.info.new"
|
|
echo "UPSTREAM_SITE${file_number_suffix}='$found_mirror'" >> "$port.info.new"
|
|
echo "UPSTREAM_ARCHIVE${file_number_suffix}='$mirror_file'" >> "$port.info.new"
|
|
mkdir -p "$mirrordir/$port"
|
|
mv "$file" "$mirrordir/$port/$file"
|
|
echo "$found_mirror/$mirror_file" > "$mirrordir/$port/$file.url"
|
|
touch -r "$mirrordir/$port/$file" "$mirrordir/$port/$file.url"
|
|
echo "$sha256sum $file" > "$mirrordir/$port/$file.sha256sum"
|
|
touch -r "$mirrordir/$port/$file" "$mirrordir/$port/$file.sha256sum"
|
|
touch -r "$mirrordir/$port/$file" "$mirrordir/$port"
|
|
fi
|
|
done
|
|
rm -f "$portsdir/$port/porttixinfo"
|
|
rm -f "$portsdir/$port/tixbuildinfo"
|
|
if [ "$port" != patch ]; then
|
|
mv "$portsdir/$port/patch.patch" "$portsdir/$port/$port.patch"
|
|
mv "$portsdir/$port/patch.execpatch" "$portsdir/$port/$port.execpatch"
|
|
mv "$portsdir/$port/patch.normalize" "$portsdir/$port/$port.normalize"
|
|
fi
|
|
if [ ! -s "$portsdir/$port/$port.execpatch" ]; then
|
|
rm -f "$portsdir/$port/$port.execpatch"
|
|
fi
|
|
if [ ! -s "$portsdir/$port/$port.normalize" ]; then
|
|
rm -f "$portsdir/$port/$port.normalize"
|
|
fi
|
|
mv "$port.info.new" "$port.info"
|
|
done
|