diff --git a/binpkg/BINPKG_INFO.txt b/doc/BINPKG_INFO.txt similarity index 100% rename from binpkg/BINPKG_INFO.txt rename to doc/BINPKG_INFO.txt diff --git a/README b/doc/README similarity index 93% rename from README rename to doc/README index 4dde474f5a5..dbac4411d9a 100644 --- a/README +++ b/doc/README @@ -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/. 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/): - $ 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: diff --git a/TODO b/doc/TODO similarity index 100% rename from TODO rename to doc/TODO diff --git a/helpers/automake.sh b/templates/helpers/automake.sh similarity index 100% rename from helpers/automake.sh rename to templates/helpers/automake.sh diff --git a/helpers/fontconfig-update.sh b/templates/helpers/fontconfig-update.sh similarity index 100% rename from helpers/fontconfig-update.sh rename to templates/helpers/fontconfig-update.sh diff --git a/helpers/gtk-update-gdkpixbufloaders.sh b/templates/helpers/gtk-update-gdkpixbufloaders.sh similarity index 100% rename from helpers/gtk-update-gdkpixbufloaders.sh rename to templates/helpers/gtk-update-gdkpixbufloaders.sh diff --git a/helpers/gtk-update-icon-cache.sh b/templates/helpers/gtk-update-icon-cache.sh similarity index 100% rename from helpers/gtk-update-icon-cache.sh rename to templates/helpers/gtk-update-icon-cache.sh diff --git a/helpers/gtk-update-immodules.sh b/templates/helpers/gtk-update-immodules.sh similarity index 100% rename from helpers/gtk-update-immodules.sh rename to templates/helpers/gtk-update-immodules.sh diff --git a/helpers/mkfontxx-rebuild.sh b/templates/helpers/mkfontxx-rebuild.sh similarity index 100% rename from helpers/mkfontxx-rebuild.sh rename to templates/helpers/mkfontxx-rebuild.sh diff --git a/helpers/pango-update-modules.sh b/templates/helpers/pango-update-modules.sh similarity index 100% rename from helpers/pango-update-modules.sh rename to templates/helpers/pango-update-modules.sh diff --git a/helpers/perl-module.sh b/templates/helpers/perl-module.sh similarity index 100% rename from helpers/perl-module.sh rename to templates/helpers/perl-module.sh diff --git a/helpers/replace-interpreter.sh b/templates/helpers/replace-interpreter.sh similarity index 100% rename from helpers/replace-interpreter.sh rename to templates/helpers/replace-interpreter.sh diff --git a/helpers/update-desktopdb.sh b/templates/helpers/update-desktopdb.sh similarity index 100% rename from helpers/update-desktopdb.sh rename to templates/helpers/update-desktopdb.sh diff --git a/helpers/update-mimedb.sh b/templates/helpers/update-mimedb.sh similarity index 100% rename from helpers/update-mimedb.sh rename to templates/helpers/update-mimedb.sh diff --git a/helpers/xml-catalogs.sh b/templates/helpers/xml-catalogs.sh similarity index 100% rename from helpers/xml-catalogs.sh rename to templates/helpers/xml-catalogs.sh diff --git a/binpkg/create.sh b/utils/sh/binpkg.sh old mode 100755 new mode 100644 similarity index 68% rename from binpkg/create.sh rename to utils/sh/binpkg.sh index 8ccc2af56fa..9f399aaff3e --- a/binpkg/create.sh +++ b/utils/sh/binpkg.sh @@ -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 "\n\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 diff --git a/helpers/chroot.sh b/utils/sh/chroot.sh similarity index 94% rename from helpers/chroot.sh rename to utils/sh/chroot.sh index 4032f2a2436..3346943dd93 100644 --- a/helpers/chroot.sh +++ b/utils/sh/chroot.sh @@ -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." diff --git a/helpers/cross-compilation.sh b/utils/sh/cross-compilation.sh similarity index 100% rename from helpers/cross-compilation.sh rename to utils/sh/cross-compilation.sh diff --git a/helpers/mktoolchain.sh b/utils/sh/mktoolchain.sh similarity index 100% rename from helpers/mktoolchain.sh rename to utils/sh/mktoolchain.sh diff --git a/xbps.sh b/xbps.sh index 76d3e69e3d9..f168fe8d192 100755 --- a/xbps.sh +++ b/xbps.sh @@ -41,7 +41,6 @@ $progname: [-C] [-c ] Targets: build Build a package (fetch + extract + configure + build). - build-chroot Build binary packages required for chroot. build-pkg Build a binary package from . Package must be installed into destdir before it. chroot Enter to the chroot in masterdir. @@ -50,7 +49,7 @@ Targets: fetch Download distribution file(s). info Show information about . install-destdir build + install into destdir. - install install-destdir + stow + build-pkg. + install install-destdir + stow. list List installed packages in masterdir. listfiles List installed files from . remove 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 $?