From 69e7d6d33c7d7f25872496fb3789943e514ec38a Mon Sep 17 00:00:00 2001
From: Stefan Laudemann <thisco@webcake.de>
Date: Mon, 24 Nov 2014 14:16:45 +0100
Subject: [PATCH] Adjusts ffpb-banner to avoid file collision error messages.

By now, the package was trying to overwrite "/etc/banner" in the image,
which caused opkg to stop the operation, as this file is already
provided by the base-files package. Without the --force-overwrite option
set for opkg (e.g. in the global gluon Makefile, where it is not set by
default), the installation of the package will fail.
Hence the problem got circumvented by renaming the customized banner file
provided by this package to "/etc/banner.ffpb" and using the prerm,
preinst, and postinst hooks of the packages' make-file to rename the
already existent "/etc/banner" to "/etc/banner.openwrt" and establish a
symbolic link "/etc/banner" to "/etc/banner.ffpb".
For deinstallation of the package, this link gets removed and a new one
(pointing at "/etc/banner.openwrt") gets created.
---
 ffpb/ffpb-banner/Makefile                     | 35 ++++++++++++++++++-
 .../files/etc/{banner => banner.ffpb}         |  0
 2 files changed, 34 insertions(+), 1 deletion(-)
 rename ffpb/ffpb-banner/files/etc/{banner => banner.ffpb} (100%)

diff --git a/ffpb/ffpb-banner/Makefile b/ffpb/ffpb-banner/Makefile
index adc9ef8..5578aa0 100644
--- a/ffpb/ffpb-banner/Makefile
+++ b/ffpb/ffpb-banner/Makefile
@@ -29,8 +29,41 @@ endef
 define Build/Compile
 endef
 
+define Package/ffpb-banner/preinst
+#!/bin/sh
+cd "$${IPKG_INSTROOT}/etc/"
+if [ -h "./banner" ] ; then
+	/bin/rm "./banner"
+elif [ -f "./banner" ] ; then
+	/bin/mv "./banner" "./banner.openwrt"
+fi
+/bin/ln -s "./banner.openwrt" "./banner"
+exit 0
+endef
+
+define Package/ffpb-banner/postinst
+#!/bin/sh
+cd "$${IPKG_INSTROOT}/etc/"
+[ -h "./banner" ] && /bin/rm -f "./banner"
+/bin/ln -s "./banner.ffpb" "./banner"
+exit $$?
+endef
+
+define Package/ffpb-banner/prerm
+#!/bin/sh
+cd "$${IPKG_INSTROOT}/etc/"
+if [ -h "./banner" ] ; then
+	[[ "$$(readlink -n ./banner)" == "./banner.ffpb" ]] && \
+	/bin/rm -f "./banner" && \
+	[ -f "./banner.openwrt" ] && \
+	/bin/ln -s "./banner.openwrt" "./banner"
+fi
+exit 0
+endef
+
 define Package/ffpb-banner/install
-	$(CP) ./files/* $(1)/
+	$(INSTALL_DIR) $(1)/etc/
+	$(INSTALL_DATA) ./files/etc/banner.ffpb $(1)/etc/
 endef
 
 $(eval $(call BuildPackage,ffpb-banner))
diff --git a/ffpb/ffpb-banner/files/etc/banner b/ffpb/ffpb-banner/files/etc/banner.ffpb
similarity index 100%
rename from ffpb/ffpb-banner/files/etc/banner
rename to ffpb/ffpb-banner/files/etc/banner.ffpb
-- 
GitLab