Added some ANSI colors for messages, may be disabled.

With the -e flag those colors will be disabled. As bonus also
I removed blank lines in .xbps-filelist and other misc tweaks, fixes
I cannot remember now.

--HG--
extra : convert_revision : 5e481d0faa14518363eafc622633d645c335ed78
This commit is contained in:
Juan RP 2008-10-29 03:20:14 +01:00
parent 93401521f9
commit 5a0aac4fd2
4 changed files with 194 additions and 92 deletions

View file

@ -10,16 +10,16 @@ trap umount_chroot_fs INT QUIT
check_installed_pkg xbps-base-chroot 0.1 check_installed_pkg xbps-base-chroot 0.1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "*** ERROR: xbps-base-chroot pkg not installed ***" msg_error "xbps-base-chroot pkg not installed."
exit 1 exit 1
fi fi
if [ "$(id -u)" -ne 0 ]; then if [ "$(id -u)" -ne 0 ]; then
if [ -z "$base_chroot" ]; then if [ -z "$base_chroot" ]; then
echo "*** ERROR: this package must be built inside of the chroot ***" msg_error "this package must be built inside of the chroot."
exit 1 exit 1
fi fi
echo "*** ERROR: you must be root to use this target ***" msg_error "you must be root to use this target."
exit 1 exit 1
fi fi
@ -29,9 +29,11 @@ if [ ! -f $XBPS_MASTERDIR/.xbps_perms_done ]; then
chmod +s $XBPS_MASTERDIR/usr/libexec/pt_chown chmod +s $XBPS_MASTERDIR/usr/libexec/pt_chown
cp -af /etc/passwd /etc/shadow /etc/group /etc/hosts /etc/resolv.conf $XBPS_MASTERDIR/etc cp -af /etc/passwd /etc/shadow /etc/group /etc/hosts /etc/resolv.conf $XBPS_MASTERDIR/etc
touch $XBPS_MASTERDIR/.xbps_perms_done touch $XBPS_MASTERDIR/.xbps_perms_done
set_color bold
echo "done." echo "done."
restore_color
else else
echo "==> Entering into the chroot on $XBPS_MASTERDIR." msg_normal "Entering into the chroot on $XBPS_MASTERDIR."
fi fi
REQDIRS="bin sbin tmp var sys proc dev xbps xbps_builddir \ REQDIRS="bin sbin tmp var sys proc dev xbps xbps_builddir \
@ -56,9 +58,14 @@ for f in ${REQFS}; do
mount --bind $blah $XBPS_MASTERDIR/$f mount --bind $blah $XBPS_MASTERDIR/$f
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
touch $XBPS_MASTERDIR/.${f}_mount_bind_done touch $XBPS_MASTERDIR/.${f}_mount_bind_done
set_color bold
echo "done." echo "done."
restore_color
else else
set_color red
set_color bold
echo "failed." echo "failed."
restore_color
fi fi
fi fi
done done
@ -80,7 +87,9 @@ rebuild_ldso_cache()
echo -n "==> Rebuilding chroot's dynamic linker cache..." echo -n "==> Rebuilding chroot's dynamic linker cache..."
chroot $XBPS_MASTERDIR /sbin/ldconfig -c /etc/ld.so.conf chroot $XBPS_MASTERDIR /sbin/ldconfig -c /etc/ld.so.conf
chroot $XBPS_MASTERDIR /sbin/ldconfig -C /etc/ld.so.cache chroot $XBPS_MASTERDIR /sbin/ldconfig -C /etc/ld.so.cache
set_color bold
echo " done." echo " done."
restore_color
} }
chroot_pkg_handler() chroot_pkg_handler()
@ -100,7 +109,7 @@ chroot_pkg_handler()
env in_chroot=yes chroot $XBPS_MASTERDIR /xbps/xbps.sh \ env in_chroot=yes chroot $XBPS_MASTERDIR /xbps/xbps.sh \
$action $pkg $action $pkg
fi fi
echo "==> Exiting from the chroot on $XBPS_MASTERDIR." msg_normal "Exiting from the chroot on $XBPS_MASTERDIR."
umount_chroot_fs umount_chroot_fs
} }
@ -115,9 +124,14 @@ umount_chroot_fs()
umount -f $XBPS_MASTERDIR/$fs umount -f $XBPS_MASTERDIR/$fs
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
rm -f $XBPS_MASTERDIR/.${fs}_mount_bind_done rm -f $XBPS_MASTERDIR/.${fs}_mount_bind_done
set_color bold
echo "done." echo "done."
restore_color
else else
set_color red
set_color bold
echo "failed." echo "failed."
restore_color
fi fi
unset fs unset fs
done done

View file

@ -39,8 +39,8 @@ replace_interpreter()
if [ -f $wrksrc/$file ]; then if [ -f $wrksrc/$file ]; then
sed -i -e "1s|^#![[:space:]]*${orsb}|#!${trpath}|" $file && \ sed -i -e "1s|^#![[:space:]]*${orsb}|#!${trpath}|" $file && \
echo "=> Transformed $lang script: ${file##$wrksrc}." msg_normal "Transformed $lang script: ${file##$wrksrc}."
else else
echo "=> Ignoring unexistent $lang script: ${file##$wrksrc}." msg_warn "Ignoring unexistent $lang script: ${file##$wrksrc}."
fi fi
} }

View file

@ -110,14 +110,17 @@ main(int argc, char **argv)
perror("ERROR: couldn't write database file"); perror("ERROR: couldn't write database file");
exit(1); exit(1);
} }
printf("==> Package database file not found, " printf("%s\e[0m==> \e[37m\e[1mPackage database file "
"creating it.\n"); "not found, creating it.\n",
in_chroot ? "[chroot] " : "");
prop_object_release(dbdict); prop_object_release(dbdict);
} else { } else {
/* register pkg if it's not registered already */ /* register pkg if it's not registered already */
pkg = prop_dictionary_get(dbdict, argv[2]); pkg = prop_dictionary_get(dbdict, argv[2]);
if (pkg && prop_object_type(pkg) == PROP_TYPE_STRING) { if (pkg && prop_object_type(pkg) == PROP_TYPE_STRING) {
printf("==> Package `%s' already registered.\n", argv[2]); printf("%s\e[0m=> \e[37m\e[1mPackage `%s' "
"already registered.\n",
in_chroot ? "[chroot] " : "", argv[2]);
exit(0); exit(0);
} }
prop_dictionary_set_cstring_nocopy(dbdict, argv[2], argv[3]); prop_dictionary_set_cstring_nocopy(dbdict, argv[2], argv[3]);
@ -127,8 +130,8 @@ main(int argc, char **argv)
} }
} }
printf("%s%s-%s registered successfully.\n", printf("%s\e[0m=> \e[37m\e[1m%s-%s registered successfully.\n",
in_chroot ? "[chroot] " : "==> ", argv[2], argv[3]); in_chroot ? "[chroot] " : "", argv[2], argv[3]);
} else if (strcmp(argv[1], "unregister") == 0) { } else if (strcmp(argv[1], "unregister") == 0) {
/* Unregisters a package from the database */ /* Unregisters a package from the database */
@ -152,8 +155,8 @@ main(int argc, char **argv)
exit(1); exit(1);
} }
printf("%s%s-%s unregistered successfully.\n", printf("%s\e[0m==> \e[37m\e[1m%s-%s unregistered successfully.\n",
in_chroot ? "[chroot] " : "==> ", argv[2], argv[3]); in_chroot ? "[chroot] " : "", argv[2], argv[3]);
} else if (strcmp(argv[1], "list") == 0) { } else if (strcmp(argv[1], "list") == 0) {
/* Lists packages currently registered in database */ /* Lists packages currently registered in database */

241
xbps.sh
View file

@ -30,6 +30,8 @@
# Default path to configuration file, can be overriden # Default path to configuration file, can be overriden
# via the environment or command line. # via the environment or command line.
# #
trap restore_color INT QUIT
: ${XBPS_CONFIG_FILE:=/etc/xbps.conf} : ${XBPS_CONFIG_FILE:=/etc/xbps.conf}
: ${progname:=$(basename $0)} : ${progname:=$(basename $0)}
@ -40,7 +42,7 @@
usage() usage()
{ {
cat << _EOF cat << _EOF
$progname: [-C] [-c <config_file>] <target> [package_name] $progname: [-Ce] [-c <config_file>] <target> [package_name]
Targets: Targets:
build Builds a package, only build phase is done. build Builds a package, only build phase is done.
@ -61,6 +63,7 @@ Options:
-C Do not remove build directory after successful installation. -C Do not remove build directory after successful installation.
-c Path to global configuration file: -c Path to global configuration file:
if not specified /etc/xbps.conf is used. if not specified /etc/xbps.conf is used.
-e Disable ANSI colors in messages.
_EOF _EOF
exit 1 exit 1
} }
@ -107,6 +110,37 @@ check_path()
path_fixed="$orig" path_fixed="$orig"
} }
set_color()
{
[ -n "$disable_colors" ] && return 0
case "$1" in
black) echo -n -e "\[e30m";;
red) echo -n -e "\e[31m";;
green) echo -n -e "\e[32m";;
brown) echo -n -e "\e[33m";;
blue) echo -n -e "\e[34m";;
magenta) echo -n -e "\e[35m";;
cyan) echo -n -e "\e[36m";;
white) echo -n -e "\e[37m";;
bold) echo -n -e "\e[1m";;
*) return 1 ;;
esac
}
bye()
{
restore_color
exit "$1"
}
restore_color()
{
[ -n "$disable_colors" ] && return 0
echo -n -e "\e[0m"
}
run_file() run_file()
{ {
local file="$1" local file="$1"
@ -129,33 +163,47 @@ msg_error()
{ {
[ -z "$1" ] && return 1 [ -z "$1" ] && return 1
set_color red
set_color bold
if [ -n "$in_chroot" ]; then if [ -n "$in_chroot" ]; then
echo "[chroot] ERROR: $1" echo -n "[chroot] ERROR: "
else else
echo "ERROR: $1" echo -n "ERROR: "
fi fi
restore_color
set_color bold
echo "$1"
restore_color
} }
msg_warn() msg_warn()
{ {
[ -z "$1" ] && return 1 [ -z "$1" ] && return 1
set_color cyan
set_color bold
if [ -n "$in_chroot" ]; then if [ -n "$in_chroot" ]; then
echo "[chroot] WARNING: $1" echo -n "[chroot] WARNING: "
else else
echo "WARNING: $1" echo -n "WARNING: "
fi fi
restore_color
set_color bold
echo "$1"
restore_color
} }
msg_normal() msg_normal()
{ {
[ -z "$1" ] && return 1 [ -z "$1" ] && return 1
if [ -n "$in_chroot" ]; then set_color green
echo "[chroot] $1" [ -n "$in_chroot" ] && echo -n "[chroot] "
else restore_color
echo "=> $1" echo -n "=> "
fi set_color bold
echo "$1"
restore_color
} }
# #
@ -165,6 +213,7 @@ info_tmpl()
{ {
local i= local i=
set_color bold
echo "pkgname: $pkgname" echo "pkgname: $pkgname"
echo "version: $version" echo "version: $version"
for i in "${distfiles}"; do for i in "${distfiles}"; do
@ -183,6 +232,7 @@ info_tmpl()
echo " $i" echo " $i"
done done
fi fi
restore_color
} }
# #
@ -202,7 +252,7 @@ check_config_vars()
done done
if [ -z "$cffound" ]; then if [ -z "$cffound" ]; then
msg_error "cannot find a config file" msg_error "cannot find a config file"
exit 1 bye 1
fi fi
fi fi
@ -211,7 +261,7 @@ check_config_vars()
if [ ! -f "$XBPS_CONFIG_FILE" ]; then if [ ! -f "$XBPS_CONFIG_FILE" ]; then
msg_error "cannot find configuration file: $XBPS_CONFIG_FILE" msg_error "cannot find configuration file: $XBPS_CONFIG_FILE"
exit 1 bye 1
fi fi
local XBPS_VARS="XBPS_MASTERDIR XBPS_DESTDIR XBPS_BUILDDIR \ local XBPS_VARS="XBPS_MASTERDIR XBPS_DESTDIR XBPS_BUILDDIR \
@ -221,14 +271,14 @@ check_config_vars()
eval val="\$$f" eval val="\$$f"
if [ -z "$val" ]; then if [ -z "$val" ]; then
msg_error "'$f' not set in configuration file" msg_error "'$f' not set in configuration file"
exit 1 bye 1
fi fi
if [ ! -d "$val" ]; then if [ ! -d "$val" ]; then
mkdir "$val" mkdir "$val"
if [ "$?" -ne 0 ]; then if [ "$?" -ne 0 ]; then
msg_error "couldn't create '$f' directory" msg_error "couldn't create '$f' directory"
exit 1 bye 1
fi fi
fi fi
done done
@ -267,6 +317,8 @@ setup_tmpl()
{ {
local pkg="$1" local pkg="$1"
[ -z "$pkg" ] && msg_error "missing package name." && usage
if [ -f "$XBPS_TEMPLATESDIR/$pkg.tmpl" ]; then if [ -f "$XBPS_TEMPLATESDIR/$pkg.tmpl" ]; then
if [ "$pkgname" != "$pkg" ]; then if [ "$pkgname" != "$pkg" ]; then
run_file $XBPS_TEMPLATESDIR/$pkg.tmpl run_file $XBPS_TEMPLATESDIR/$pkg.tmpl
@ -274,7 +326,7 @@ setup_tmpl()
prepare_tmpl prepare_tmpl
else else
msg_error "cannot find '$pkg' template build file." msg_error "cannot find '$pkg' template build file."
exit 1 bye 1
fi fi
} }
@ -297,7 +349,7 @@ prepare_tmpl()
eval val="\$$i" eval val="\$$i"
if [ -z "$val" -o -z "$i" ]; then if [ -z "$val" -o -z "$i" ]; then
msg_error "\"$i\" not set on $pkgname template." msg_error "\"$i\" not set on $pkgname template."
exit 1 bye 1
fi fi
done done
@ -353,7 +405,7 @@ extract_distfiles()
if [ $count -gt 1 ]; then if [ $count -gt 1 ]; then
if [ -z "$wrksrc" ]; then if [ -z "$wrksrc" ]; then
msg_error "\$wrksrc must be defined with multiple distfiles." msg_error "\$wrksrc must be defined with multiple distfiles."
exit 1 bye 1
fi fi
mkdir $wrksrc mkdir $wrksrc
fi fi
@ -396,21 +448,21 @@ extract_distfiles()
$ltar_cmd xfj $XBPS_SRCDISTDIR/$curfile -C $lwrksrc $ltar_cmd xfj $XBPS_SRCDISTDIR/$curfile -C $lwrksrc
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
msg_error "extracting $curfile into $lwrksrc." msg_error "extracting $curfile into $lwrksrc."
exit 1 bye 1
fi fi
;; ;;
.tar.gz|.tgz) .tar.gz|.tgz)
$ltar_cmd xfz $XBPS_SRCDISTDIR/$curfile -C $lwrksrc $ltar_cmd xfz $XBPS_SRCDISTDIR/$curfile -C $lwrksrc
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
msg_error "extracting $curfile into $lwrksrc." msg_error "extracting $curfile into $lwrksrc."
exit 1 bye 1
fi fi
;; ;;
.tar) .tar)
$ltar_cmd xf $XBPS_SRCDISTDIR/$curfile -C $lwrksrc $ltar_cmd xf $XBPS_SRCDISTDIR/$curfile -C $lwrksrc
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
msg_error "extracting $curfile into $lwrksrc." msg_error "extracting $curfile into $lwrksrc."
exit 1 bye 1
fi fi
;; ;;
.zip) .zip)
@ -427,18 +479,18 @@ extract_distfiles()
unset tmpf tmpsufx tmpwrksrc unset tmpf tmpsufx tmpwrksrc
else else
msg_error "cannot find unzip helper." msg_error "cannot find unzip helper."
exit 1 bye 1
fi fi
extract_unzip $XBPS_SRCDISTDIR/$curfile $lwrksrc extract_unzip $XBPS_SRCDISTDIR/$curfile $lwrksrc
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
msg_error "extracting $curfile into $lwrksrc." msg_error "extracting $curfile into $lwrksrc."
exit 1 bye 1
fi fi
;; ;;
*) *)
msg_error "cannot guess $curfile extract suffix. ($cursufx)" msg_error "cannot guess $curfile extract suffix. ($cursufx)"
exit 1 bye 1
;; ;;
esac esac
done done
@ -460,7 +512,7 @@ verify_sha256_cksum()
filesum=$($XBPS_DIGEST_CMD $XBPS_SRCDISTDIR/$file) filesum=$($XBPS_DIGEST_CMD $XBPS_SRCDISTDIR/$file)
if [ "$origsum" != "$filesum" ]; then if [ "$origsum" != "$filesum" ]; then
msg_error "SHA256 checksum doesn't match for $file." msg_error "SHA256 checksum doesn't match for $file."
exit 1 bye 1
fi fi
msg_normal "SHA256 checksum OK for $file." msg_normal "SHA256 checksum OK for $file."
@ -478,7 +530,7 @@ fetch_distfiles()
local ckcount=0 local ckcount=0
local f= local f=
[ -z $pkgname ] && exit 1 [ -z $pkgname ] && bye 1
# #
# There's nothing of interest if we are a meta template. # There's nothing of interest if we are a meta template.
@ -502,7 +554,7 @@ fetch_distfiles()
if [ -z $found ]; then if [ -z $found ]; then
msg_error "cannot find checksum for $curfile." msg_error "cannot find checksum for $curfile."
exit 1 bye 1
fi fi
verify_sha256_cksum $curfile $cksum verify_sha256_cksum $curfile $cksum
@ -531,7 +583,7 @@ fetch_distfiles()
else else
msg_error "there was an error fetching $curfile." msg_error "there was an error fetching $curfile."
fi fi
exit 1 bye 1
else else
unset localurl unset localurl
# #
@ -549,7 +601,7 @@ fetch_distfiles()
if [ -z $found ]; then if [ -z $found ]; then
msg_error "cannot find checksum for $curfile." msg_error "cannot find checksum for $curfile."
exit 1 bye 1
fi fi
verify_sha256_cksum $curfile $cksum verify_sha256_cksum $curfile $cksum
@ -672,25 +724,25 @@ apply_tmpl_patches()
cp -f $patch $wrksrc cp -f $patch $wrksrc
# Try to guess if its a compressed patch. # Try to guess if its a compressed patch.
if $(echo $patch|$grep_cmd -q .gz); then if [[ "$patch" == *.diff.gz ]]; then
gunzip $wrksrc/$i gunzip $wrksrc/$i
patch=${i%%.gz} patch=${i%%.gz}
elif $(echo $patch|$grep_cmd -q .bz2); then elif [[ "$patch" == *.diff.bz2 ]]; then
bunzip2 $wrksrc/$i bunzip2 $wrksrc/$i
patch=${i%%.bz2} patch=${i%%.bz2}
elif $(echo $patch|$grep_cmd -q .diff); then elif [[ "$patch" == *.diff ]]; then
patch=$i patch=$i
else else
msg_warn "unknown patch type: $i." msg_warn "unknown patch type: $i."
continue continue
fi fi
cd $wrksrc && patch -p0 < $patch 2>/dev/null cd $wrksrc && patch -s -p0 < $patch 2>/dev/null
if [ "$?" -eq 0 ]; then if [ "$?" -eq 0 ]; then
msg_normal "Patch applied: $i." msg_normal "Patch applied: $i."
else else
msg_error "couldn't apply patch: $i." msg_error "couldn't apply patch: $i."
exit 1 bye 1
fi fi
done done
fi fi
@ -719,7 +771,7 @@ configure_src_phase()
if [ ! -d $wrksrc ]; then if [ ! -d $wrksrc ]; then
msg_error "unexistent build directory [$wrksrc]." msg_error "unexistent build directory [$wrksrc]."
exit 1 bye 1
fi fi
# Apply patches if requested by template file # Apply patches if requested by template file
@ -735,8 +787,6 @@ configure_src_phase()
msg_normal "Running configure phase for $pkgname-$version." msg_normal "Running configure phase for $pkgname-$version."
set_build_vars
[ -z "$configure_script" ] && configure_script="./configure" [ -z "$configure_script" ] && configure_script="./configure"
local _prefix= local _prefix=
@ -746,7 +796,7 @@ configure_src_phase()
_prefix= _prefix=
fi fi
cd $wrksrc || exit 1 cd $wrksrc || bye 1
# #
# Packages using GNU autoconf # Packages using GNU autoconf
@ -784,12 +834,12 @@ configure_src_phase()
# #
else else
msg_error "unknown build_style [$build_style]" msg_error "unknown build_style [$build_style]"
exit 1 bye 1
fi fi
if [ "$build_style" != "perl_module" -a "$?" -ne 0 ]; then if [ "$build_style" != "perl_module" -a "$?" -ne 0 ]; then
msg_error "building $pkg (configure phase)." msg_error "building $pkg (configure phase)."
exit 1 bye 1
fi fi
# unset configure_env vars. # unset configure_env vars.
@ -824,10 +874,10 @@ build_src_phase()
if [ ! -d $wrksrc ]; then if [ ! -d $wrksrc ]; then
msg_error "unexistent build directory [$wrksrc]" msg_error "unexistent build directory [$wrksrc]"
exit 1 bye 1
fi fi
cd $wrksrc || exit 1 cd $wrksrc || bye 1
# #
# Assume BSD make if make_cmd not set in template. # Assume BSD make if make_cmd not set in template.
@ -852,7 +902,6 @@ build_src_phase()
libtool_fixup_file libtool_fixup_file
set_build_vars set_build_vars
msg_normal "Running build phase for $pkg." msg_normal "Running build phase for $pkg."
# #
@ -861,7 +910,7 @@ build_src_phase()
${make_cmd} ${makejobs} ${make_build_args} ${make_build_target} ${make_cmd} ${makejobs} ${make_build_args} ${make_build_target}
if [ "$?" -ne 0 ]; then if [ "$?" -ne 0 ]; then
msg_error "building $pkg (build phase)." msg_error "building $pkg (build phase)."
exit 1 bye 1
fi fi
unset makejobs unset makejobs
@ -898,10 +947,10 @@ install_src_phase()
if [ ! -d $wrksrc ]; then if [ ! -d $wrksrc ]; then
msg_error "unexistent build directory [$wrksrc]" msg_error "unexistent build directory [$wrksrc]"
exit 1 bye 1
fi fi
cd $wrksrc || exit 1 cd $wrksrc || bye 1
msg_normal "Running install phase for: $pkgname-$version." msg_normal "Running install phase for: $pkgname-$version."
@ -949,7 +998,7 @@ make_install()
${make_cmd} ${make_install_target} ${make_install_args} ${make_cmd} ${make_install_target} ${make_install_args}
if [ "$?" -ne 0 ]; then if [ "$?" -ne 0 ]; then
msg_error "installing $pkgname-$version." msg_error "installing $pkgname-$version."
exit 1 bye 1
fi fi
# Replace libtool archives if requested. # Replace libtool archives if requested.
@ -976,13 +1025,15 @@ register_pkg_handler()
[ -z "$action" -o -z "$pkg" -o -z "$version" ] && return 1 [ -z "$action" -o -z "$pkg" -o -z "$version" ] && return 1
set_color green
if [ "$action" = "register" ]; then if [ "$action" = "register" ]; then
$XBPS_PKGDB_CMD register $pkg $version $XBPS_PKGDB_CMD register $pkg $version
[ $? -ne 0 ] && exit 1 [ $? -ne 0 ] && bye 1
elif [ "$action" = "unregister" ]; then elif [ "$action" = "unregister" ]; then
$XBPS_PKGDB_CMD unregister $pkg $version $XBPS_PKGDB_CMD unregister $pkg $version
[ $? -ne 0 ] && exit 1 [ $? -ne 0 ] && bye 1
else else
restore_color
return 1 return 1
fi fi
} }
@ -1100,18 +1151,28 @@ install_dependencies_pkg()
add_dependency_tolist $pkg add_dependency_tolist $pkg
find_dupdeps_inlist installed find_dupdeps_inlist installed
find_dupdeps_inlist notinstalled find_dupdeps_inlist notinstalled
set_color bold
echo "done." echo "done."
restore_color
[ -z "$deps_list" -a -z "$installed_deps_list" ] && return 0 [ -z "$deps_list" -a -z "$installed_deps_list" ] && return 0
msg_normal "Required dependencies for $(basename $pkg):" msg_normal "Required dependencies for $(basename $pkg):"
for i in ${installed_deps_list}; do for i in ${installed_deps_list}; do
fpkg="$($XBPS_PKGDB_CMD list|$grep_cmd -w ${i%-[0-9]*.*})" fpkg="$($XBPS_PKGDB_CMD list|$grep_cmd -w ${i%-[0-9]*.*})"
echo " $i: found $fpkg." echo -n " $i: "
set_color green
set_color bold
echo "found $fpkg."
restore_color
done done
for i in ${deps_list}; do for i in ${deps_list}; do
echo " $i: not installed." echo -n " $i: "
set_color red
set_color bold
echo "not installed."
restore_color
done done
for i in ${deps_list}; do for i in ${deps_list}; do
@ -1223,7 +1284,7 @@ install_pkg()
local cur_tmpl="$XBPS_TEMPLATESDIR/$curpkgn.tmpl" local cur_tmpl="$XBPS_TEMPLATESDIR/$curpkgn.tmpl"
if [ -z $cur_tmpl -o ! -f $cur_tmpl ]; then if [ -z $cur_tmpl -o ! -f $cur_tmpl ]; then
msg_error "cannot find $cur_tmpl template build file." msg_error "cannot find $cur_tmpl template build file."
exit 1 bye 1
fi fi
# #
@ -1314,14 +1375,17 @@ list_pkgs()
local i= local i=
if [ ! -r "$XBPS_PKGDB_FPATH" ]; then if [ ! -r "$XBPS_PKGDB_FPATH" ]; then
echo "=> No packages registered or missing register db file." msg_warn "No packages registered or missing register db file."
exit 0 bye 0
fi fi
for i in $($XBPS_PKGDB_CMD list); do for i in $($XBPS_PKGDB_CMD list); do
# Run file to get short_desc and print something useful # Run file to get short_desc and print something useful
run_file $XBPS_TEMPLATESDIR/${i%-[0-9]*.*}.tmpl run_file $XBPS_TEMPLATESDIR/${i%-[0-9]*.*}.tmpl
echo "$i $short_desc" set_color bold
echo -n "$i"
restore_color
echo " $short_desc"
reset_tmpl_vars reset_tmpl_vars
done done
} }
@ -1335,16 +1399,18 @@ list_pkg_files()
local f="$XBPS_DESTDIR/$pkg/.xbps-filelist" local f="$XBPS_DESTDIR/$pkg/.xbps-filelist"
if [ -z $pkg ]; then if [ -z $pkg ]; then
echo "ERROR: unexistent package, aborting." msg_error "unexistent package, aborting."
exit 1 bye 1
fi fi
if [ ! -d "$XBPS_DESTDIR/$pkg" ]; then if [ ! -d "$XBPS_DESTDIR/$pkg" ]; then
echo "ERROR: cannot find $pkg in $XBPS_DESTDIR." msg_error "cannot find $pkg in $XBPS_DESTDIR."
exit 1 bye 1
fi fi
set_color bold
cat $f|sort -u cat $f|sort -u
restore_color
} }
# #
@ -1355,13 +1421,13 @@ remove_pkg()
local pkg="$1" local pkg="$1"
if [ -z "$pkg" ]; then if [ -z "$pkg" ]; then
echo "ERROR: unexistent package, aborting." msg_error "unexistent package, aborting."
exit 1 bye 1
fi fi
if [ ! -f "$XBPS_TEMPLATESDIR/$pkg.tmpl" ]; then if [ ! -f "$XBPS_TEMPLATESDIR/$pkg.tmpl" ]; then
echo "ERROR: cannot find template build file." msg_error "cannot find template build file."
exit 1 bye 1
fi fi
run_file $XBPS_TEMPLATESDIR/$pkg.tmpl run_file $XBPS_TEMPLATESDIR/$pkg.tmpl
@ -1371,14 +1437,15 @@ remove_pkg()
# #
if [ "$build_style" = "meta-template" ]; then if [ "$build_style" = "meta-template" ]; then
register_pkg_handler unregister $pkgname $version register_pkg_handler unregister $pkgname $version
[ $? -eq 0 ] && \ [ $? -eq 0 ] && set_color green && \
echo "=> Removed meta-template: $pkg." echo "=> Removed meta-template: $pkg." && \
restore_color
return $? return $?
fi fi
if [ ! -d "$XBPS_DESTDIR/$pkg-$version" ]; then if [ ! -d "$XBPS_DESTDIR/$pkg-$version" ]; then
echo "ERROR: cannot find package on $XBPS_DESTDIR." msg_error "cannot find package on $XBPS_DESTDIR."
exit 1 bye 1
fi fi
unstow_pkg $pkg unstow_pkg $pkg
@ -1409,9 +1476,9 @@ stow_pkg()
[ "$build_style" = "meta-template" ] && return 0 [ "$build_style" = "meta-template" ] && return 0
fi fi
cd $XBPS_DESTDIR/$pkgname-$version || exit 1 cd $XBPS_DESTDIR/$pkgname-$version || bye 1
find . > $flist find . > $flist
sed -i -e "s|^.$||g;s|^./||g;s|.xbps-filelist||g" $flist sed -i -e "s|^.$||g;s|^./||g;s|.xbps-filelist||g;/^$/d" $flist
cp -ar . $XBPS_MASTERDIR cp -ar . $XBPS_MASTERDIR
mv -f $flist $XBPS_DESTDIR/$pkgname-$version/.xbps-filelist mv -f $flist $XBPS_DESTDIR/$pkgname-$version/.xbps-filelist
@ -1439,8 +1506,8 @@ unstow_pkg()
local f= local f=
if [ -z "$pkg" ]; then if [ -z "$pkg" ]; then
echo "ERROR: template wasn't specified?" msg_error "template wasn't specified?"
exit 1 bye 1
fi fi
if [ "$pkgname" != "$pkg" ]; then if [ "$pkgname" != "$pkg" ]; then
@ -1452,22 +1519,33 @@ unstow_pkg()
# #
[ "$build_style" = "meta-template" ] && return 0 [ "$build_style" = "meta-template" ] && return 0
cd $XBPS_DESTDIR/$pkgname-$version || exit 1 cd $XBPS_DESTDIR/$pkgname-$version || bye 1
[ ! -f .xbps-filelist ] && exit 1 [ ! -f .xbps-filelist ] && bye 1
for f in $(cat .xbps-filelist|sort -ur); do for f in $(cat .xbps-filelist|sort -ur); do
if [ -f $XBPS_MASTERDIR/$f -o -h $XBPS_MASTERDIR/$f ]; then if [ -f $XBPS_MASTERDIR/$f -o -h $XBPS_MASTERDIR/$f ]; then
rm $XBPS_MASTERDIR/$f >/dev/null 2>&1 rm $XBPS_MASTERDIR/$f >/dev/null 2>&1
[ $? -eq 0 ] && echo "Removing file: $f" if [ $? -eq 0 ]; then
echo -n "Removing file: "
set_color bold
echo "$f"
restore_color
fi
fi fi
done done
for f in $(cat .xbps-filelist|sort -ur); do for f in $(cat .xbps-filelist|sort -ur); do
if [ -d $XBPS_MASTERDIR/$f ]; then if [ -d $XBPS_MASTERDIR/$f ]; then
rmdir $XBPS_MASTERDIR/$f >/dev/null 2>&1 rmdir $XBPS_MASTERDIR/$f >/dev/null 2>&1
[ $? -eq 0 ] && echo "Removing directory: $f" if [ $? -eq 0 ]; then
echo -n "Removing directory: "
set_color bold
echo "$f"
restore_color
fi
fi fi
done done
restore_color
register_pkg_handler unregister $pkgname $version register_pkg_handler unregister $pkgname $version
} }
@ -1475,7 +1553,7 @@ unstow_pkg()
# #
# main() # main()
# #
while getopts "Cc:" opt; do while getopts "Cc:e" opt; do
case $opt in case $opt in
C) C)
dontrm_builddir=yes dontrm_builddir=yes
@ -1485,6 +1563,9 @@ while getopts "Cc:" opt; do
XBPS_CONFIG_FILE="$OPTARG" XBPS_CONFIG_FILE="$OPTARG"
shift shift
;; ;;
e)
disable_colors=yes
;;
--) --)
shift shift
break break
@ -1497,7 +1578,7 @@ shift $(($OPTIND - 1))
target="$1" target="$1"
if [ -z "$target" ]; then if [ -z "$target" ]; then
echo "ERROR: missing target." msg_error "missing target."
usage usage
fi fi
@ -1556,19 +1637,23 @@ info)
info_tmpl $2 info_tmpl $2
;; ;;
install-destdir) install-destdir)
[ -z "$2" ] && msg_error "missing package name." && usage
install_destdir_target=yes install_destdir_target=yes
install_pkg $2 install_pkg $2
;; ;;
install) install)
[ -z "$2" ] && msg_error "missing package name." && usage
install_pkg $2 install_pkg $2
;; ;;
list) list)
list_pkgs list_pkgs
;; ;;
listfiles) listfiles)
[ -z "$2" ] && msg_error "missing package." && usage
list_pkg_files $2 list_pkg_files $2
;; ;;
remove) remove)
[ -z "$2" ] && msg_error "missing package name." && usage
remove_pkg $2 remove_pkg $2
;; ;;
stow) stow)
@ -1581,9 +1666,9 @@ unstow)
unstow_pkg $2 unstow_pkg $2
;; ;;
*) *)
echo "ERROR: invalid target: $target." msg_error "invalid target: $target."
usage usage
esac esac
# Agur # Agur
exit 0 bye 0