Skip to content

Commit

Permalink
Merge remote-tracking branch 'matze/formarius'
Browse files Browse the repository at this point in the history
* matze/formarius:
  hooks: gdk-pixbuf-query-loaders: exit if pkg-config returned nothing
  beelib: set default DOCDIR as it is defined by autoconf
  beesh: exit if image directory is empty
  beesh: do not print info if --help was given
  bee-dep: do nothing if BEE_METADIR does not exist
  contrib: improve bash completion for bee
  bee-tools: fix 'getopt -n' arguments
  bee{-list,sh}: use 'uname -m' instead of arch since the arch command is deprecated
  bee-dep: ensure_directories now uses mkdirp to create BEE_CACHEDIR
  bee-dep: implement mkdirp function
  • Loading branch information
mariux committed Mar 19, 2012
2 parents 317c9bb + 1571e57 commit b313d3c
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 35 deletions.
17 changes: 11 additions & 6 deletions contrib/bee-completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,23 @@ _bee_completion()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"

options="init install remove check query list"
ls=$(ls $pwd)
bee_tools="check dep download init install list query remove"
bee_dep_options="rebuild update remove list conflicts"

if [ "${prev}" = "bee" ]; then
COMPREPLY=($(compgen -W "${options} ${ls}" -- ${cur}) )
COMPREPLY=( $(compgen -W "${bee_tools}" -- ${cur} ) )
return 0
fi

packages=$(bee list -a)
COMPREPLY=($(compgen -W "${packages} ${ls}" -- ${cur}) )
if [ "${prev}" = "dep" ]; then
COMPREPLY=( $(compgen -W "${bee_dep_options}" -- ${cur}) )
return 0
fi

packages="$(bee list -a)"
packages="${packages} $(bee list -i)"
COMPREPLY=( $(compgen -W "${packages}" -- ${cur}) )
return 0
}

complete -F _bee_completion bee
complete -f -F _bee_completion bee
4 changes: 4 additions & 0 deletions hooks/gdk-pixbuf-query-loaders.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ fi
gdk_pixbuf_moduledir=$(pkg-config --variable=gdk_pixbuf_moduledir gdk-pixbuf-2.0)
gdk_pixbuf_cache_file=$(pkg-config --variable=gdk_pixbuf_cache_file gdk-pixbuf-2.0)

if [ -z "${gdk_pixbuf_moduledir}" -o -z "${gdk_pixbuf_cache_file}" ]; then
exit 0
fi

if grep -q "file=${gdk_pixbuf_moduledir}" ${BEE_METADIR}/${pkg}/FILES ; then
case "${action}" in
"post-install")
Expand Down
2 changes: 1 addition & 1 deletion src/bee-check.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ usage() {
###############################################################################
##
##
options=$(getopt -n bee_check \
options=$(getopt -n bee-check \
-o advfh \
--long verbose,all,force,help,deps \
-- "$@")
Expand Down
58 changes: 41 additions & 17 deletions src/bee-dep.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include <unistd.h>
#include <getopt.h>
#include <fcntl.h>
#include <assert.h>
#include <errno.h>

#include "graph.h"

Expand Down Expand Up @@ -178,28 +180,44 @@ static void usage_conflicts(void)
printf("Usage: bee dep conflicts [pkgname]\n");
}

void ensure_directories(void)
/* create all directories in path with mode mode */
int mkdirp(char *path, mode_t mode)
{
char *c;
int i;
char dir[PATH_MAX + 1] = {0};
struct stat st;
char *dir, *pdir, *end;
int ret;

c = bee_cachedir();
i = 0;
assert(path);

while (*c) {
dir[i] = *c;
c++;
dir = end = path;

if (*c == '/' || !(*c)) {
if (stat(dir, &st) == -1 && mkdir(dir, 0755) == -1) {
perror("mkdir");
exit(EXIT_FAILURE);
}
}
while (*dir) {
/* skip "/" */
dir = end + strspn(end, "/");

/* skip non-"/" */
end = dir + strcspn(dir, "/");

/* grab everything in path till current end */
if (!(pdir = strndup(path, end - path)))
return -1;

/* create the directory ; ignore err if it already exists */
ret = mkdir(pdir, mode);

free(pdir);

if (ret == -1 && errno != EEXIST)
return -1;
}

i++;
return 0;
}

void ensure_directories(void)
{
if (mkdirp(bee_cachedir(), 0755) == -1) {
perror("bee-dep: mkdirp");
exit(EXIT_FAILURE);
}
}

Expand All @@ -211,6 +229,9 @@ static struct hash *init_cache(void)
struct stat st;
struct hash *graph;

if (stat(bee_metadir(), &st) == -1)
return NULL;

if ((pkg_cnt = scandir(bee_metadir(), &package, 0, alphasort)) < 0) {
perror("bee-dep: init_cache: scandir");
return NULL;
Expand Down Expand Up @@ -270,6 +291,9 @@ static int update_cache(struct hash *graph)
struct stat st;
struct tree_node *t;

if (stat(bee_metadir(), &st) == -1)
return 0;

if ((pkg_cnt = scandir(bee_metadir(), &package, 0, alphasort)) < 0) {
perror("bee-dep: update_cache: scandir");
return 1;
Expand Down
2 changes: 1 addition & 1 deletion src/bee-list.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ VERSION=${BEE_VERSION}
# - lists are alpha-num sorted and not as pkg-versions ..
# - check for grep -P support and use it..

ARCH=$(arch)
ARCH=$(uname -m)

#
# print usage information
Expand Down
2 changes: 1 addition & 1 deletion src/bee-remove.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ usage() {
EOF
}

options=$(getopt -n bee_remove \
options=$(getopt -n bee-remove \
-o n,h \
--long noop,help \
-- "$@")
Expand Down
2 changes: 1 addition & 1 deletion src/beelib.config.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ function config_verify_builtin_prefixes() {
: ${DATADIR:='${DATAROOTDIR}'}
: ${INFODIR:='${DATAROOTDIR}/info'}
: ${MANDIR:='${DATAROOTDIR}/man'}
: ${DOCDIR:='${DATAROOTDIR}/doc/gtkhtml'}
: ${DOCDIR:='${DATAROOTDIR}/doc/${PKGNAME}'}
: ${LOCALEDIR:='${DATAROOTDIR}/locale'}
}

Expand Down
21 changes: 13 additions & 8 deletions src/beesh.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
set -e

#architecture
ARCH=$(arch)
ARCH=$(uname -m)

# Version
BEE_VERSION="@BEE_VERSION@"
Expand Down Expand Up @@ -373,6 +373,11 @@ function bee_pkg_pack() {

beefind.pl --dump ${D}/FILES | sed -e "s,^,${D}," - > ${DUMP}

if [ ! -s "${D}/FILES" ]; then
print_error "ERROR: empty image directory"
exit 1
fi

cp ${BEE} ${D}/BUILD

create_meta
Expand Down Expand Up @@ -534,15 +539,9 @@ config_init

config_set_skiplist

print_info " BEE_SKIPLIST ${BEE_SKIPLIST}"
print_info " BEE_REPOSITORY_PREFIX ${BEE_REPOSITORY_PREFIX}"
print_info " BEE_METADIR ${BEE_METADIR}"
print_info " BEE_TMP_TMPDIR ${BEE_TMP_TMPDIR}"
print_info " BEE_TMP_BUILDROOT ${BEE_TMP_BUILDROOT}"

###############################################################################

OPTIONS=$(getopt -n bee-option-parser \
OPTIONS=$(getopt -n beesh \
-o hifcs \
--long help,install,force-install,cleanup,silent-build,debug: \
--long archive-build,no-archive-build \
Expand Down Expand Up @@ -601,6 +600,12 @@ while true ; do
esac
done

print_info " BEE_SKIPLIST ${BEE_SKIPLIST}"
print_info " BEE_REPOSITORY_PREFIX ${BEE_REPOSITORY_PREFIX}"
print_info " BEE_METADIR ${BEE_METADIR}"
print_info " BEE_TMP_TMPDIR ${BEE_TMP_TMPDIR}"
print_info " BEE_TMP_BUILDROOT ${BEE_TMP_BUILDROOT}"

###############################################################################
###############################################################################
###############################################################################
Expand Down

0 comments on commit b313d3c

Please sign in to comment.