diff --git a/contrib/bee-completion.sh b/contrib/bee-completion.sh new file mode 100755 index 0000000..3d16e1e --- /dev/null +++ b/contrib/bee-completion.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +_bee_completion() +{ + COMPREPLY=() + + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + + options="init install remove check query list" + ls=$(ls $pwd) + + if [ "${prev}" = "bee" ]; then + COMPREPLY=($(compgen -W "${options} ${ls}" -- ${cur}) ) + return 0 + fi + + packages=$(bee list -a) + COMPREPLY=($(compgen -W "${packages} ${ls}" -- ${cur}) ) + + return 0 +} + +complete -F _bee_completion bee diff --git a/src/bee-check.sh.in b/src/bee-check.sh.in old mode 100755 new mode 100644 diff --git a/src/bee-dep.c b/src/bee-dep.c index 27b981f..7997705 100644 --- a/src/bee-dep.c +++ b/src/bee-dep.c @@ -81,17 +81,17 @@ static void get_bee_variables(void) { if (!bee_version()) { fprintf(stderr, "BEE-ERROR: please call bee-dep from bee\n"); - exit(1); + exit(EXIT_FAILURE); } if (!bee_metadir()) { fprintf(stderr, "BEE-ERROR: BEE_METADIR not set\n"); - exit(1); + exit(EXIT_FAILURE); } if (!bee_cachedir()) { fprintf(stderr, "BEE_ERROR: BEE_CACHEDIR not set\n"); - exit(1); + exit(EXIT_FAILURE); } } @@ -195,7 +195,7 @@ void ensure_directories(void) if (*c == '/' || !(*c)) { if (stat(dir, &st) == -1 && mkdir(dir, 0755) == -1) { perror("mkdir"); - exit(1); + exit(EXIT_FAILURE); } } @@ -353,7 +353,7 @@ struct hash *get_cache(void) graph = load_cache(cache_filename()); if (!graph) - exit(1); + exit(EXIT_FAILURE); return graph; } @@ -453,9 +453,6 @@ static int bee_dep_update(int argc, char *argv[]) if (stat(path, &st) != -1) { if (hash_search(graph, pkg)) { - fprintf(stderr, - "bee-dep: package \"%s\" is already in the cache\n", - pkg); hash_free(graph); return 0; } @@ -747,7 +744,7 @@ static FILE *lockfile(void) if ((file = fopen(lock_filename(), "w")) == NULL) { perror("bee-dep: lockfile"); - exit(1); + exit(EXIT_FAILURE); } fprintf(file, "locked by pid %d\n", getpid()); @@ -770,7 +767,7 @@ void lock(void) if (fcntl(fileno(f), F_SETLKW, &flo) == -1) { perror("bee-dep: lock"); - exit(1); + exit(EXIT_FAILURE); } } @@ -792,17 +789,17 @@ void unlock(void) if (ftruncate(fileno(f), 0) == -1) { perror("bee-dep: unlock: ftruncate"); - exit(1); + exit(EXIT_FAILURE); } if (fcntl(fileno(f), F_SETLK, &flo) == -1) { perror("bee-dep: unlock: fcntl"); - exit(1); + exit(EXIT_FAILURE); } if (fclose(f) == EOF) { perror("bee-dep: unlock: fclose"); - exit(1); + exit(EXIT_FAILURE); } } diff --git a/src/bee-init.sh.in b/src/bee-init.sh.in old mode 100755 new mode 100644 diff --git a/src/bee-install.sh.in b/src/bee-install.sh.in old mode 100755 new mode 100644 index 7f32697..cb59867 --- a/src/bee-install.sh.in +++ b/src/bee-install.sh.in @@ -282,9 +282,8 @@ do_install() { --transform="s,^DEPENDENCIES$,${BEE_METADIR}/${pkg}/DEPENDENCIES," \ --show-transformed-names - ${BEE_LIBEXECDIR}/bee/bee.d/bee-check -d ${pkg} > ${BEE_METADIR}/${pkg}/DEPENDENCIES - if [ "${OPT_NOOP}" != "yes" ]; then + ${BEE_LIBEXECDIR}/bee/bee.d/bee-check -d ${pkg} > ${BEE_METADIR}/${pkg}/DEPENDENCIES run_hooks post-install ${pkg} ${BEE_LIBEXECDIR}/bee/bee.d/bee-dep update ${pkg} fi diff --git a/src/bee-list.sh.in b/src/bee-list.sh.in old mode 100755 new mode 100644 diff --git a/src/bee-remove.sh.in b/src/bee-remove.sh.in old mode 100755 new mode 100644 index 0ad19dd..cbc0744 --- a/src/bee-remove.sh.in +++ b/src/bee-remove.sh.in @@ -62,7 +62,7 @@ do_remove() { FILES=$(${BEE_LIBEXECDIR}/bee/bee.d/bee-dep remove --print ${pkg##*/}) if [ $? -ne 0 ] ; then - echo "removal of ${pkg} failed" + echo "removal of ${pkg##*/} failed" exit 1 fi diff --git a/src/bee.sh.in b/src/bee.sh.in old mode 100755 new mode 100644 diff --git a/src/beedep_tree.c b/src/beedep_tree.c index a11b433..2bdb3d4 100644 --- a/src/beedep_tree.c +++ b/src/beedep_tree.c @@ -293,15 +293,12 @@ void tree_node_free(struct tree *t, struct tree_node *n) struct tree_node *delete, *replace, *to_update; - struct node *s; delete = n; if (!delete) return; - s = delete->n; - if (delete->left) { if (delete->right) { replace = predecessor(delete); diff --git a/src/beesh.sh.in b/src/beesh.sh.in old mode 100755 new mode 100644 index a32989e..7177527 --- a/src/beesh.sh.in +++ b/src/beesh.sh.in @@ -531,8 +531,8 @@ function bee_run() { config_init_colors -echo -e "${COLOR_CYAN}BEE v${BEE_VERSION} 2009-2011 - mariux64 package magic " -echo -e " by Marius Tolzmann und Tobias Dreyer <{tolzmann,dreyer}@molgen.mpg.de>" +echo -e "${COLOR_CYAN}BEE v${BEE_VERSION} 2009-2011" +echo -e " by Marius Tolzmann and Tobias Dreyer <{tolzmann,dreyer}@molgen.mpg.de>" echo -e " Max Planck Institute for Molecular Genetics Berlin Dahlem" echo -e "${COLOR_NORMAL}" diff --git a/src/graph.c b/src/graph.c index dc63850..be44e35 100644 --- a/src/graph.c +++ b/src/graph.c @@ -191,9 +191,8 @@ int graph_insert_nodes(struct hash *hash, char *filename) if (!l) { fprintf(stderr, - "bee-dep: %s: error at line %d: missing value " + "bee-dep: warning: %s: line %d: missing value " "for property \"%s\"\n", filename, line_cnt, prop); - return 1; } memset(value, '\0', LINE_MAX); @@ -386,7 +385,8 @@ void print_broken(struct hash *hash, char *remove) void sort_dirs(char **dirs, int dir_cnt) { - int i, j, c; + int i, j; + size_t c; char *h; for (i = 1; i < dir_cnt; i++) { @@ -518,36 +518,48 @@ int count_removable(struct hash *hash, char *remove) return c; } -static void list_all_files(struct node *n) +static int list_all_files(struct node *n, char print) { struct tree_node *t; + int count; - t = tree_first(n->provide->root); + t = tree_first(n->provide->root); + count = 0; while (t) { - if (IS_FILE(t->n->name)) - puts(t->n->name); + if (IS_FILE(t->n->name)) { + count++; - list_all_files(t->n); + if (print) + puts(t->n->name); + } + + count += list_all_files(t->n, print); t = tree_next(t); } + + return count; } -static void count_all_files(struct node *n, int *count) +static int count_all_files(struct node *n) { struct tree_node *t; + int count; - t = tree_first(n->provide->root); + t = tree_first(n->provide->root); + count = 0; while (t) { if (IS_FILE(t->n->name)) - (*count)++; + count++; - list_all_files(t->n); + count += list_all_files(t->n, 0); t = tree_next(t); } + + return count; } int list_files(struct hash *hash, char *pkgname) @@ -568,7 +580,7 @@ int list_files(struct hash *hash, char *pkgname) return 1; } - list_all_files(n); + list_all_files(n, 1); return 0; } @@ -576,7 +588,6 @@ int list_files(struct hash *hash, char *pkgname) int count_files(struct hash *hash, char *pkgname) { struct node *n; - int c; if ((n = hash_search(hash, pkgname)) == NULL) { fprintf(stderr, @@ -592,10 +603,7 @@ int count_files(struct hash *hash, char *pkgname) return -1; } - c = 0; - count_all_files(n, &c); - - return c; + return count_all_files(n); } static void get_all_providers(struct node *n, struct tree *all) diff --git a/src/hash.c b/src/hash.c index 85bed0b..561fbeb 100644 --- a/src/hash.c +++ b/src/hash.c @@ -87,6 +87,9 @@ void hash_free(struct hash *hash) { int i; + if (!hash) + return; + for (i = 0; i < TBLSIZE; i++) { tree_free_all_nodes(hash->tbl[i]); tree_free(hash->tbl[i]);