Currently each foreign package is adorned with a small program "spkg-install" that automates the compilation/installation of the package by calling the parts of the packages build system accordingly.
most implementations of this program (for the various packages) are purely monolithic, sequential and stateless. these programs need to be extended to allow
- direct call of subroutines
- basic dependency support (dont configure before patch etc.)
- states, for example for patching, dont build twice etc.
- support for FILELIST (record installed files) and DESTDIR (GNU standard)
- uninstall, clean etc.
- simple default subprograms for source or binary package creation (for other distributions)
a simple straigtforward replacement ("common practice") would be an executable makefile which has "install:" as its default target. such a makefile could look like very much like this
\#!/whatever/make include /some/common/rules PACKAGE_NAME=bla configure: cd src; configure --prefix=... --something install: $(MAKE) -Csrc install DESTDIR=$(DESTDIR) INSTALL=$(SAGE_INSTALL) -F $(FILELIST)
theoretically it can be implemented in any other language, we have interpreters for,
but this looks much more involved (example?)