Skip to content

Commit

Permalink
Merge remote-tracking branch 'matze/formarius'
Browse files Browse the repository at this point in the history
* matze/formarius:
  bee-install: fix call of bee-check
  bee-remove: proper error message
  repository: fix modes of *.sh.in scripts
  beesh: fix header which is printed when executing a bee file
  bash completion script for bee added
  bee-dep: fix exit codes in bee-dep.c
  bee-dep: graph.c: change type of variable to size_t since strlen returns size_t
  bee-dep: beedep_tree.c: remove unecessary variable
  bee-dep: rebuild: fix access of null reference if init_cache failed
  bee-dep: remove unnecessary message
  bee-dep: fix option --files combined with --count
  bee-dep: fix wrong behaviour of graph_insert_nodes
  • Loading branch information
mariux committed Jan 26, 2012
2 parents 8b12761 + 768d12e commit 1783480
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 39 deletions.
24 changes: 24 additions & 0 deletions contrib/bee-completion.sh
Original file line number Diff line number Diff line change
@@ -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
Empty file modified src/bee-check.sh.in
100755 → 100644
Empty file.
23 changes: 10 additions & 13 deletions src/bee-dep.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -353,7 +353,7 @@ struct hash *get_cache(void)
graph = load_cache(cache_filename());

if (!graph)
exit(1);
exit(EXIT_FAILURE);

return graph;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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());
Expand All @@ -770,7 +767,7 @@ void lock(void)

if (fcntl(fileno(f), F_SETLKW, &flo) == -1) {
perror("bee-dep: lock");
exit(1);
exit(EXIT_FAILURE);
}
}

Expand All @@ -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);
}
}

Expand Down
Empty file modified src/bee-init.sh.in
100755 → 100644
Empty file.
3 changes: 1 addition & 2 deletions src/bee-install.sh.in
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Empty file modified src/bee-list.sh.in
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion src/bee-remove.sh.in
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Empty file modified src/bee.sh.in
100755 → 100644
Empty file.
3 changes: 0 additions & 3 deletions src/beedep_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/beesh.sh.in
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down
44 changes: 26 additions & 18 deletions src/graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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++) {
Expand Down Expand Up @@ -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)
Expand All @@ -568,15 +580,14 @@ int list_files(struct hash *hash, char *pkgname)
return 1;
}

list_all_files(n);
list_all_files(n, 1);

return 0;
}

int count_files(struct hash *hash, char *pkgname)
{
struct node *n;
int c;

if ((n = hash_search(hash, pkgname)) == NULL) {
fprintf(stderr,
Expand All @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions src/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down

0 comments on commit 1783480

Please sign in to comment.