From 5ae3aa7a021103702b2cf10d66c63b9eb4ef3226 Mon Sep 17 00:00:00 2001 From: Marius Tolzmann Date: Mon, 21 May 2012 14:56:05 +0200 Subject: [PATCH] compatibility: New FILES -> CONTENT converter add a script to convert the old FILES-file to the new CONTENT-file the script will be installed in LIBEXECDIR/bee/ --- Makefile | 16 ++++- src/compat-filesfile2contentfile.sh.in | 85 ++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 3 deletions(-) create mode 100755 src/compat-filesfile2contentfile.sh.in diff --git a/Makefile b/Makefile index 6f34565..dd26fa0 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 @@ -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 .sh") + $(call quiet-command,rm -f $(addsuffix .sh,${SHELLSCRIPTS}) $(LIBRARY_SHELL) $(HELPER_SHELL),"CLEAN .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}") @@ -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}) @@ -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: diff --git a/src/compat-filesfile2contentfile.sh.in b/src/compat-filesfile2contentfile.sh.in new file mode 100755 index 0000000..a8b6e85 --- /dev/null +++ b/src/compat-filesfile2contentfile.sh.in @@ -0,0 +1,85 @@ +#!/bin/bash +# +# bee-check - check consistency of installed bee-pkgs +# +# Copyright (C) 2009-2011 +# Marius Tolzmann +# Tobias Dreyer +# 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 . +# + +: ${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 $@)