Skip to content

Commit

Permalink
compatibility: New FILES -> CONTENT converter
Browse files Browse the repository at this point in the history
add a script to convert the old FILES-file to the new CONTENT-file

the script will be installed in LIBEXECDIR/bee/
  • Loading branch information
mariux committed May 21, 2012
1 parent 8ff498a commit 5ae3aa7
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 3 deletions.
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ PROGRAMS_PERL=beefind.pl
HELPER_BEE_SHELL=bee-init bee-check bee-remove bee-install bee-list bee-query bee-download bee-update
HELPER_BEE_C=bee-dep

HELPER_SHELL=compat-filesfile2contentfile

LIBRARY_SHELL=beelib.config.sh

BUILDTYPES=configure cmake autogen perl-module perl-module-makemaker make python-module
Expand Down Expand Up @@ -88,7 +90,7 @@ compat: compat-bashlt4
compat-bashlt4: ${COMPAT_BASHLT4}
$(call quiet-command, sed ${sed-compat-bashlt4} -i ${COMPAT_BASHLT4}, "COMPAT $^" )

SHELLSCRIPTS=$(PROGRAMS_SHELL) $(HELPER_BEE_SHELL)
SHELLSCRIPTS=$(PROGRAMS_SHELL) $(HELPER_BEE_SHELL) $(HELPER_SHELL)

BEEVERSION_OBJECTS=beeversion.o bee_version_parse.o bee_version_compare.o bee_version_output.o
BEESEP_OBJECTS=beesep.o
Expand Down Expand Up @@ -144,7 +146,7 @@ beegetopt: $(addprefix src/, ${BEEGETOPT_OBJECTS})
$(call quiet-command,sed ${sed-rules} $< >$@,"SED $@")

clean:
$(call quiet-command,rm -f $(addsuffix .sh,${SHELLSCRIPTS}) $(LIBRARY_SHELL),"CLEAN <various>.sh")
$(call quiet-command,rm -f $(addsuffix .sh,${SHELLSCRIPTS}) $(LIBRARY_SHELL) $(HELPER_SHELL),"CLEAN <various>.sh")
$(call quiet-command,rm -f ${PROGRAMS_PERL},"CLEAN ${PROGRAMS_PERL}")
$(call quiet-command,rm -f ${PROGRAMS_C},"CLEAN ${PROGRAMS_C}")
$(call quiet-command,rm -f ${HELPER_BEE_C},"CLEAN ${HELPER_BEE_C}")
Expand All @@ -154,7 +156,7 @@ clean:

install: install-core install-config

install-core: build install-man install-hooks install-buildtypes install-beeshlib install-tools install-bin
install-core: build install-man install-hooks install-buildtypes install-beeshlib install-tools install-helper install-bin

install-bin: $(addprefix ${DESTDIR}${BINDIR}/,${PROGRAMS_PERL} ${PROGRAMS_C} ${PROGRAMS_SHELL})

Expand All @@ -178,6 +180,14 @@ ${DESTDIR}${LIBEXECDIR}/bee/bee.d/%: %.sh install-dir-tools
${DESTDIR}${LIBEXECDIR}/bee/bee.d/%: % install-dir-tools
$(call quiet-install,0755,$<,$@)

install-helper: $(addprefix ${DESTDIR}${LIBEXECDIR}/bee/,${HELPER_SHELL})

install-dir-helper:
$(call quiet-installdir,0755,${DESTDIR}${LIBEXECDIR}/bee)

${DESTDIR}${LIBEXECDIR}/bee/%: %.sh install-dir-helper
$(call quiet-install,0755,$<,$@)

install-beeshlib: $(addprefix ${DESTDIR}${LIBEXECDIR}/bee/,${LIBRARY_SHELL})

install-dir-beeshlib:
Expand Down
85 changes: 85 additions & 0 deletions src/compat-filesfile2contentfile.sh.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/bash
#
# bee-check - check consistency of installed bee-pkgs
#
# Copyright (C) 2009-2011
# Marius Tolzmann <tolzmann@molgen.mpg.de>
# Tobias Dreyer <dreyer@molgen.mpg.de>
# and other bee developers
#
# This file is part of bee.
#
# bee is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

: ${BEESEP=@BINDIR@/beesep}

declare -A hardlink

while read line ; do
md5=""
data=$(${BEESEP} ${line} 2>/dev/null)

if [ $? -ne '0' ] ; then
echo >&2 "**ERROR** INVALID CONTENT: ${line}"
exit 1
fi

eval ${data}

if [ $? -ne '0' -o -z "${md5}" ] ; then
echo >&2 "**ERROR** UNPARSABLE CONTENT: ${line}"
exit 1
fi

if [ "${md5}" = "directory" ] ; then
type='directory'
unset md5
elif [ "${md5}" = "link" ] ; then
type='symlink'
unset md5
elif [ "${md5}" = "block" ] ; then
type='block'
unset md5
elif [ "${md5}" = "char" ] ; then
type='char'
unset md5
else
type='regular'
fi

if [ -z "${nlink}" ] ; then
nlink=1
fi

if [ "${type}" = "regular" -a ${nlink} -gt 1 ] ; then
key=$md5-$size-$nlink
if [ -n "${hardlink[$key]}" ] ; then
type=hardlink
file=${file}//${hardlink[$key]}
else
hardlink[$key]=$file
fi
fi

echo -n "type=${type}"
printf ":mode=0%o" ${mode}
printf ":access=0%o" $(( ${mode} & 07777 ))
echo -n ":nlink=${nlink}:uid=${uid}:gid=${gid}:size=${size}:mtime=${mtime}"
if [ -n "${md5}" ] ; then
echo -n ":md5=${md5}"
fi
echo ":file=${file}"

done < <(cat $@)

0 comments on commit 5ae3aa7

Please sign in to comment.