From dd75afe9bcbda384ceca64c32ea77e1507ed878b Mon Sep 17 00:00:00 2001 From: Matthias Ruester Date: Tue, 27 Dec 2011 12:30:20 +0100 Subject: [PATCH 01/12] bee-dep: fix wrong behaviour of graph_insert_nodes a missing value in a DEPENDENCIES file is not an error anymore; just print a warning --- src/graph.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/graph.c b/src/graph.c index dc63850..a3771f8 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); From fea89850560a9517574e219055d659fa5e8fb108 Mon Sep 17 00:00:00 2001 From: Matthias Ruester Date: Mon, 16 Jan 2012 11:53:30 +0100 Subject: [PATCH 02/12] bee-dep: fix option --files combined with --count bug was: bee dep --count --files has printed the files of a package instead of just count the files fix: now function list_all_files counts all provided files of a node and returns the number introducing a second parameter the function is able to be verbose and print the files if needed so we can use this function both in list_files and count_files --- src/graph.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/graph.c b/src/graph.c index a3771f8..9ee1a98 100644 --- a/src/graph.c +++ b/src/graph.c @@ -517,36 +517,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) @@ -567,7 +579,7 @@ int list_files(struct hash *hash, char *pkgname) return 1; } - list_all_files(n); + list_all_files(n, 1); return 0; } @@ -575,7 +587,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, @@ -591,10 +602,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) From 3bb46a869302384d610835736fbdb6471d7e2238 Mon Sep 17 00:00:00 2001 From: Matthias Ruester Date: Mon, 16 Jan 2012 14:48:33 +0100 Subject: [PATCH 03/12] bee-dep: remove unnecessary message --- src/bee-dep.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/bee-dep.c b/src/bee-dep.c index 27b981f..71ec915 100644 --- a/src/bee-dep.c +++ b/src/bee-dep.c @@ -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; } From a9a2baca6318b89a2b724153072aa158f829721b Mon Sep 17 00:00:00 2001 From: Matthias Ruester Date: Mon, 16 Jan 2012 15:21:30 +0100 Subject: [PATCH 04/12] bee-dep: rebuild: fix access of null reference if init_cache failed --- src/hash.c | 3 +++ 1 file changed, 3 insertions(+) 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]); From 2d271ec5c2a614cf8d579e91681d8c19938798e0 Mon Sep 17 00:00:00 2001 From: Matthias Ruester Date: Tue, 17 Jan 2012 12:56:06 +0100 Subject: [PATCH 05/12] bee-dep: beedep_tree.c: remove unecessary variable --- src/beedep_tree.c | 3 --- 1 file changed, 3 deletions(-) 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); From 929aa9487862e698340f205f546c06168421dc22 Mon Sep 17 00:00:00 2001 From: Matthias Ruester Date: Tue, 17 Jan 2012 13:00:28 +0100 Subject: [PATCH 06/12] bee-dep: graph.c: change type of variable to size_t since strlen returns size_t discovered with compiler flag -Wextra --- src/graph.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/graph.c b/src/graph.c index 9ee1a98..be44e35 100644 --- a/src/graph.c +++ b/src/graph.c @@ -385,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++) { From 2cbdbb54b74096e1cf5416b10a716d56b5946470 Mon Sep 17 00:00:00 2001 From: Matthias Ruester Date: Tue, 17 Jan 2012 14:43:02 +0100 Subject: [PATCH 07/12] bee-dep: fix exit codes in bee-dep.c --- src/bee-dep.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/bee-dep.c b/src/bee-dep.c index 71ec915..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; } @@ -744,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()); @@ -767,7 +767,7 @@ void lock(void) if (fcntl(fileno(f), F_SETLKW, &flo) == -1) { perror("bee-dep: lock"); - exit(1); + exit(EXIT_FAILURE); } } @@ -789,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); } } From 78e77b7f86d13c1eb821dad690c07e6acac51879 Mon Sep 17 00:00:00 2001 From: Matthias Ruester Date: Sat, 21 Jan 2012 23:25:41 +0100 Subject: [PATCH 08/12] bash completion script for bee added --- contrib/bee-completion.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 contrib/bee-completion.sh 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 From 362d05639d9bcbaade25df137685825c777116e8 Mon Sep 17 00:00:00 2001 From: Matthias Ruester Date: Sat, 21 Jan 2012 23:29:03 +0100 Subject: [PATCH 09/12] beesh: fix header which is printed when executing a bee file --- src/beesh.sh.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/beesh.sh.in b/src/beesh.sh.in index a32989e..7177527 100755 --- 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}" From 7597515a05148d66d0a903ec1cf56d85d8221719 Mon Sep 17 00:00:00 2001 From: Matthias Ruester Date: Sat, 21 Jan 2012 23:32:22 +0100 Subject: [PATCH 10/12] repository: fix modes of *.sh.in scripts --- src/bee-check.sh.in | 0 src/bee-init.sh.in | 0 src/bee-install.sh.in | 0 src/bee-list.sh.in | 0 src/bee-remove.sh.in | 0 src/bee.sh.in | 0 src/beesh.sh.in | 0 7 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 src/bee-check.sh.in mode change 100755 => 100644 src/bee-init.sh.in mode change 100755 => 100644 src/bee-install.sh.in mode change 100755 => 100644 src/bee-list.sh.in mode change 100755 => 100644 src/bee-remove.sh.in mode change 100755 => 100644 src/bee.sh.in mode change 100755 => 100644 src/beesh.sh.in 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-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 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 diff --git a/src/bee.sh.in b/src/bee.sh.in old mode 100755 new mode 100644 diff --git a/src/beesh.sh.in b/src/beesh.sh.in old mode 100755 new mode 100644 From 2ff9a3acb8b95fc31701f641eb4db76bf2cb5915 Mon Sep 17 00:00:00 2001 From: Matthias Ruester Date: Wed, 25 Jan 2012 16:02:58 +0100 Subject: [PATCH 11/12] bee-remove: proper error message print the package name instead of its path --- src/bee-remove.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bee-remove.sh.in b/src/bee-remove.sh.in index 0ad19dd..cbc0744 100644 --- 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 From 768d12e70c86e13b2661817f7f1dc61b3a431093 Mon Sep 17 00:00:00 2001 From: Matthias Ruester Date: Thu, 26 Jan 2012 08:30:04 +0100 Subject: [PATCH 12/12] bee-install: fix call of bee-check do not call bee-check if option --noop was given --- src/bee-install.sh.in | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/bee-install.sh.in b/src/bee-install.sh.in index 1588382..59309f0 100644 --- 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