1#!/bin/bash
2# Convert _bootstrap packages to non-bootstrap version.
3# THIS IS A HACK. The _bootstrap packages are cross-compiled on a pseudo-haiku
4# environment running on a different host system. Expect binary
5# incompatibilities when trying to use them. However, the development files
6# should still be valid, allowing us to build a non-bootstrap Haiku against
7# these package before we can get the bootstrap image to run reliably enough
8# to actually bootstrap the packages.
9
10mkdir -p work
11cd work
12
13for package in ../packages/*.hpkg
14do
15	echo --- Processing $package ---
16	echo Cleaning work directory...
17	rm -rf *
18	echo Extracting package...
19	package extract $package
20	echo Converting .PackageInfo...
21	sed -i .PackageInfo -e s/_bootstrap//g
22	name=`basename $package|sed -e s/_bootstrap//g`
23	# If this is a source package, we need to correct the source directory.
24	if [[ $name = *"-source.hpkg" ]]; then
25		oldpkgname=$(basename $package | sed -e s/-source.hpkg//g | sed -e s/_source//g)
26		newpkgname=$(echo $name | sed -e s/-source.hpkg//g | sed -e s/_source//g)
27		if [[ -d develop/sources/$oldpkgname ]]; then
28			echo "Fixing source directory..."
29			mv develop/sources/$oldpkgname develop/sources/$newpkgname;
30		else
31			echo "WARN: Want to fix source directory, but develop/sources/$oldpkgname missing!"
32		fi
33	fi
34	echo Regenerating package...
35	package create ../$name
36done
37