Reorganize the tree for easier and better handling.

- Template helpers have been moved to templates/helpers.
- Documentation to docs/.
- Common scripts have been moved to utils/sh.
- Fixed install-destdir when executed via chroot.
- Added a build-pkg target that builds a binary package.
  The package must be installed into destdir before using.
- Misc tweaks and fixes.

--HG--
extra : convert_revision : 0896e8f24bb7592116aaf77ae9c776033818a3d8
This commit is contained in:
Juan RP 2008-12-13 03:01:24 +01:00
parent 8373117030
commit 23fa45a18b
20 changed files with 65 additions and 79 deletions

View file

@ -62,14 +62,15 @@ To avoid problems with libtool and configure scripts finding stuff that is
available in the host system, almost all packages must be built inside of a
chroot. So the first thing would be to create the binary packages with:
$ xbps.sh build-chroot
$ xbps.sh install xbps-base-chroot
This will build all required binary packages via fakeroot, therefore you
This will build all required packages via fakeroot in masterdir, therefore you
can run it as normal user. Next commands will require super-user privileges
and all package handling will be done within the chroot. I believe it's the
most easier and faster way to handle clean dependencies; another reason would
be that xbps packages are meant to be used in a system and not just for
ordinary users. So once all packages are built, you can create the chroot with:
ordinary users. So once all packages are built, you can create and enter
to the chroot with:
$ sudo xbps.sh chroot
@ -81,7 +82,7 @@ to be done in the chroot:
Now let's explain some more about the targets that you can use. To start
installing packages you should use the install target:
$ xbps.sh install glib
$ sudo xbps.sh install glib
If the package is properly installed, it will be "stowned" automatically.
``stowned´´ means that this package is available in the master directory,
@ -89,18 +90,18 @@ on which xpbs has copied all files from DESTDIR/<pkgname>.
To remove a currently installed (and stowned) package, you can use:
$ xbps.sh remove glib
$ sudo xbps.sh remove glib
Please note that when you remove it, the package will also be removed
from XBPS_DESTDIR and previously "unstowned".
To stow an already installed package (from XBPS_DESTDIR/<pkgname>):
$ xbps.sh stow glib
$ sudo xbps.sh stow glib
and to unstow an already installed (stowned) package:
$ xbps.sh unstow glib
$ sudo xbps.sh unstow glib
You can also print some stuff about any template build file, e.g:
@ -116,7 +117,7 @@ To only extract the distfiles, without configuring/building/installing:
To not remove the build directory after successful installation:
$ xbps.sh -C install blah
$ sudo xbps.sh -C install blah
To only fetch the distfile:
@ -124,7 +125,7 @@ To only fetch the distfile:
To only install the package, _without_ stowning it into the master directory:
$ xbps.sh install-destdir blob
$ sudo xbps.sh install-destdir blob
To list files installed by a package, note that package must be installed
into destination directory first:

View file

60
binpkg/create.sh → utils/sh/binpkg.sh Executable file → Normal file
View file

@ -1,13 +1,9 @@
#!/bin/sh
#
# Builds a binary package from an installed xbps package in the
# destination directory. This binary package is just a simple tar(1)
# archive with gzip, bzip2 or lzma compression (all compression
# modes that libarchive supports).
# This function writes the metadata files into package's destdir,
# these will be used for binary packages.
#
# Passed argument: pkgname.
write_metadata()
xbps_write_metadata_pkg()
{
local destdir=$XBPS_DESTDIR/$pkgname-$version
@ -16,10 +12,19 @@ write_metadata()
exit 1
fi
if [ ! -d $destdir/xbps-metadata ]; then
mkdir -p $destdir/xbps-metadata >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "ERROR: you don't have enough perms for this."
exit 1
fi
fi
# Write the files list.
local TMPFLIST=$(mktemp -t flist.XXXXXXXXXX) || exit 1
find $destdir | sort -ur | \
sed -e "s|$destdir||g;s|^\/$||g;/^$/d" > $TMPFLIST
sed -e "s|$destdir||g;s|^\/$||g;s|/xbps-metadata||g;/^$/d" \
> $TMPFLIST
# Write the property list file.
local TMPFPROPS=$(mktemp -t fprops.XXXXXXXXXX) || exit 1
@ -58,17 +63,18 @@ _EOF
printf "</dict>\n</plist>\n" >> $TMPFPROPS
# Write metadata files into destdir and cleanup.
if [ ! -d $destdir/xbps-metadata ]; then
mkdir -p $destdir/xbps-metadata
fi
cp -f $TMPFLIST $destdir/xbps-metadata/flist
cp -f $TMPFPROPS $destdir/xbps-metadata/props.plist
chmod 644 $destdir/xbps-metadata/*
rm -f $TMPFLIST $TMPFPROPS
}
make_archive()
#
# This functions builds a binary package from an installed xbps
# package in destdir.
#
xbps_make_binpkg()
{
local destdir=$XBPS_DESTDIR/$pkgname-$version
local pkgsdir=$XBPS_DISTRIBUTIONDIR/packages
@ -81,31 +87,3 @@ make_archive()
echo "=> Built package: $pkgname-$version-xbps.tbz2."
}
pkg=$1
if [ -z "$pkg" ]; then
echo "ERROR: missing package name as argument."
exit 1
fi
if [ -z "$XBPS_DISTRIBUTIONDIR" ]; then
echo "ERROR: XBPS_DISTRIBUTIONDIR not set."
exit 1
fi
if [ -z "$XBPS_DESTDIR" ]; then
echo "ERROR: XBPS_DESTDIR not set."
exit 1
fi
if [ ! -f $XBPS_DISTRIBUTIONDIR/templates/$pkg.tmpl ]; then
echo "ERROR: missing package template file."
exit 1
fi
. $XBPS_DISTRIBUTIONDIR/templates/$pkg.tmpl
write_metadata
make_archive
return 0

View file

@ -1,5 +1,5 @@
#
# Helper to install packages into a sandbox in masterdir.
# Script to install packages into a sandbox in masterdir.
# Actually this needs the xbps-base-chroot package installed.
#
@ -25,6 +25,7 @@ fi
if [ ! -f $XBPS_MASTERDIR/.xbps_perms_done ]; then
echo -n "==> Preparing chroot on $XBPS_MASTERDIR... "
chown -R root:root $XBPS_MASTERDIR
cp -af /etc/passwd /etc/shadow /etc/group /etc/hosts \
/etc/resolv.conf $XBPS_MASTERDIR/etc
touch $XBPS_MASTERDIR/.xbps_perms_done
@ -64,10 +65,11 @@ rebuild_ldso_cache()
echo " done."
}
chroot_pkg_handler()
xbps_chroot_handler()
{
local action="$1"
local pkg="$2"
local only_destdir="$3"
[ -z "$action" -o -z "$pkg" ] && return 1
@ -79,7 +81,9 @@ chroot_pkg_handler()
if [ "$action" = "chroot" ]; then
env in_chroot=yes chroot $XBPS_MASTERDIR /bin/bash
else
env in_chroot=yes chroot $XBPS_MASTERDIR \
[ -n "$only_destdir" ] && \
local lenv="install_destdir_target=yes"
env in_chroot=yes ${lenv} chroot $XBPS_MASTERDIR \
/xbps/xbps.sh $action $pkg
fi
msg_normal "Exiting from the chroot on $XBPS_MASTERDIR."

55
xbps.sh
View file

@ -41,7 +41,6 @@ $progname: [-C] [-c <config_file>] <target> <pkg>
Targets:
build <pkg> Build a package (fetch + extract + configure + build).
build-chroot Build binary packages required for chroot.
build-pkg <pkg> Build a binary package from <pkg>.
Package must be installed into destdir before it.
chroot Enter to the chroot in masterdir.
@ -50,7 +49,7 @@ Targets:
fetch <pkg> Download distribution file(s).
info <pkg> Show information about <pkg>.
install-destdir <pkg> build + install into destdir.
install <pkg> install-destdir + stow + build-pkg.
install <pkg> install-destdir + stow.
list List installed packages in masterdir.
listfiles <pkg> List installed files from <pkg>.
remove <pkg> Remove package completely (destdir + masterdir).
@ -72,16 +71,18 @@ set_defvars()
local i=
: ${XBPS_TEMPLATESDIR:=$XBPS_DISTRIBUTIONDIR/templates}
: ${XBPS_HELPERSDIR:=$XBPS_DISTRIBUTIONDIR/helpers}
: ${XBPS_HELPERSDIR:=$XBPS_TEMPLATESDIR/helpers}
: ${XBPS_CACHEDIR:=$XBPS_MASTERDIR/var/cache/xbps}
: ${XBPS_PKGDB_FPATH:=$XBPS_CACHEDIR/pkgdb.plist}
: ${XBPS_PKGMETADIR:=$XBPS_CACHEDIR/metadata}
: ${XBPS_UTILSDIR:=$XBPS_DISTRIBUTIONDIR/utils}
: ${XBPS_SHUTILSDIR:=$XBPS_UTILSDIR/sh}
: ${XBPS_DIGEST_CMD:=$XBPS_UTILSDIR/xbps-digest}
: ${XBPS_PKGDB_CMD:=$XBPS_UTILSDIR/xbps-pkgdb}
: ${XBPS_CMPVER_CMD:=$XBPS_UTILSDIR/xbps-cmpver}
local DDIRS="XBPS_TEMPLATESDIR XBPS_HELPERSDIR XBPS_UTILSDIR"
local DDIRS="XBPS_TEMPLATESDIR XBPS_HELPERSDIR XBPS_UTILSDIR \
XBPS_SHUTILSDIR"
for i in ${DDIRS}; do
eval val="\$$i"
[ ! -d "$val" ] && msg_error "cannot find $i, aborting."
@ -898,7 +899,7 @@ install_src_phase()
cd $wrksrc || exit 1
msg_normal "Running install phase for: $pkgname-$version."
msg_normal "Running install phase for $pkgname-$version."
# cross compilation vars.
if [ -n "$cross_compiler" ]; then
@ -1188,10 +1189,6 @@ build_binpkg()
[ -z $pkg ] && return 1
cd $XBPS_BUILDDIR || exit 1
if [ "$(whoami)" != "root" ]; then
echo "==> Building binary package via fakeroot."
fi
rootcmd_run $XBPS_DISTRIBUTIONDIR/binpkg/create.sh $pkg
}
@ -1202,8 +1199,9 @@ install_pkg()
{
local pkg=
local curpkgn="$1"
local cdestdir=
local cur_tmpl="$XBPS_TEMPLATESDIR/$curpkgn.tmpl"
if [ -z $cur_tmpl -o ! -f $cur_tmpl ]; then
msg_error "cannot find $cur_tmpl template build file."
fi
@ -1228,9 +1226,9 @@ install_pkg()
[ -z "$origin_tmpl" ] && origin_tmpl=$pkgname
if [ -z "$base_chroot" -a -z "$in_chroot" ]; then
. $XBPS_HELPERSDIR/chroot.sh
chroot_pkg_handler install $curpkgn
build_binpkg $curpkgn
. $XBPS_SHUTILSDIR/chroot.sh
[ -n "$install_destdir_target" ] && cdestdir=yes
xbps_chroot_handler install $curpkgn $cdestdir
return $?
fi
@ -1285,8 +1283,6 @@ install_pkg()
fi
fi
[ -z "$in_chroot" ] && build_binpkg $curpkgn
#
# Do not stow package if it wasn't requested.
#
@ -1342,7 +1338,9 @@ remove_pkg()
fi
unstow_pkg $pkg
rm -rf $XBPS_DESTDIR/$pkg-$ver
if [ $? -eq 0 ]; then
rm -rf $XBPS_DESTDIR/$pkg-$ver
fi
return $?
}
@ -1370,7 +1368,11 @@ stow_pkg()
cd $XBPS_DESTDIR/$pkgname-$version || exit 1
# Copy metadata files.
# Write pkg metadata.
. $XBPS_SHUTILSDIR/binpkg.sh
xbps_write_metadata_pkg
# Copy metadata files into masterdir.
if [ -f xbps-metadata/flist -a -f xbps-metadata/props.plist ]; then
local metadir=$XBPS_PKGMETADIR/$pkgname-$version
mkdir -p $metadir
@ -1489,11 +1491,11 @@ case "$target" in
build|configure)
setup_tmpl $2
if [ -z "$base_chroot" -a -z "$in_chroot" ]; then
. $XBPS_HELPERSDIR/chroot.sh
. $XBPS_SHUTILSDIR/chroot.sh
if [ "$target" = "build" ]; then
chroot_pkg_handler build $2
xbps_chroot_handler build $2
else
chroot_pkg_handler configure $2
xbps_chroot_handler configure $2
fi
else
fetch_distfiles $2
@ -1510,13 +1512,14 @@ build|configure)
fi
fi
;;
build-chroot)
. $XBPS_HELPERSDIR/build-chroot-binpkgs.sh
build_chroot_binpkgs
build-pkg)
. $XBPS_SHUTILSDIR/binpkg.sh
setup_tmpl $2
xbps_make_binpkg
;;
chroot)
. $XBPS_HELPERSDIR/chroot.sh
chroot_pkg_handler chroot dummy
. $XBPS_SHUTILSDIR/chroot.sh
xbps_chroot_handler chroot dummy
;;
extract|fetch|info)
setup_tmpl $2
@ -1553,4 +1556,4 @@ unstow)
esac
# Agur
exit 0
exit $?