Skip to content

Commit

Permalink
Destdirification, by Makoto Fujiwara via pkgsrc-wip.
Browse files Browse the repository at this point in the history
  • Loading branch information
wiz committed Jul 9, 2011
1 parent c3bd5e5 commit 9e68eb3
Show file tree
Hide file tree
Showing 6 changed files with 307 additions and 3 deletions.
73 changes: 71 additions & 2 deletions wm/fvwm-themes/Makefile
@@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.5 2009/08/11 12:12:34 drochner Exp $
# $NetBSD: Makefile,v 1.6 2011/07/09 14:20:53 wiz Exp $
#

DISTNAME= fvwm-themes-${THEM_VER}
Expand All @@ -8,6 +8,8 @@ MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=fvwm-themes/}
EXTRACT_SUFX= .tar.bz2
DISTFILES+= ${DISTNAME}${EXTRACT_SUFX} \
fvwm-themes-extra-${THEM_VER}.tar.bz2
LICENSE= gnu-gpl-v2
PKG_DESTDIR_SUPPORT= user-destdir

MAINTAINER= gendalia@NetBSD.org
HOMEPAGE= http://fvwm-themes.sourceforge.net/
Expand All @@ -26,9 +28,76 @@ CONFIGURE_ARGS+= --with-ft-datadir=${PREFIX}/share/fvwm2

REPLACE_PERL+= themes/cde/modules/create-buttonbar-config

#### 1 ####
SUBST_CLASSES+= Makefile
SUBST_FILES.Makefile= Makefile.am Makefile.in
SUBST_SED.Makefile= -e 's|FT_DATADIR=@FT_DATADIR@|FT_DATADIR=${DESTDIR}@FT_DATADIR@|'
SUBST_STAGE.Makefile= pre-configure
SUBST_MESSAGE.Makefile= Modify shell script (Makefile)

#### 2 ####
SUBST_CLASSES+= fvwm-config
SUBST_FILES.fvwm-config= bin/fvwm-themes-config-destdir.in
# -my @searchPath = ($userDir, $ftDataDir);
# +my @searchPath = ($userDir, "${DESTDIR}".$ftDataDir);
SUBST_SED.fvwm-config= -e 's|hD = ($$userDir, $$ftDataDir|hD = ($$userDir, \"${DESTDIR}\".$$ftDataDir|'
SUBST_STAGE.fvwm-config= pre-configure
SUBST_MESSAGE.fvwm-config= Modify perl script bin/fvwm-themes-config-destdir.in

#### 3 ####
SUBST_CLASSES+= fvwm-menuapp
SUBST_FILES.fvwm-menuapp= bin/fvwm-themes-menuapp-destdir.in
# -my $ftDir = "@FT_DATADIR@"
# +my $ftDir = "${DESTDIR}@FT_DATADIR@"
SUBST_SED.fvwm-menuapp= -e 's|$$userDir, $$ftDataDir|$$userDir, \"${DESTDIR}\".$$ftDataDir|'
SUBST_SED.fvwm-menuapp= -e 's|my $$ftDir = "@FT_DATADIR@"|my $$ftDir = \"${DESTDIR}@FT_DATADIR@\"|'
SUBST_STAGE.fvwm-menuapp= pre-configure
SUBST_MESSAGE.fvwm-menuapp= Fixing FT_DATADIR (fvwm-themes-datadir)

#### 4 ####
SUBST_CLASSES+= gnome_session
SUBST_FILES.gnome_session= configure.in
SUBST_SED.gnome_session= -e 's|GNOME_SESSION=/usr/bin/gnome-session|GNOME_SESSION=${PREFIX}/bin/gnome-session|'
SUBST_STAGE.gnome_session= pre-configure
SUBST_MESSAGE.gnome_session= gnome-session path fixed

#### 5 ####
SUBST_CLASSES+= root_prefix
SUBST_FILES.root_prefix= bin/fvwm-themes-config-destdir.in
SUBST_SED.root_prefix= -e 's|\/^$$ROOT_PREFIX\/\/|\|\^${DESTDIR}\|\||'
SUBST_STAGE.root_prefix= pre-configure
SUBST_MESSAGE.root_prefix= root_prefix tweak implementing

#### 6 ####
SUBST_CLASSES+= theme-cfg
SUBST_FILES.theme-cfg= ${DESTDIR}${PREFIX}/share/fvwm2/themes/current/theme.cfg
SUBST_SED.theme-cfg= -e 's|${WRKDR}/.destdir||'
SUBST_STAGE.theme-cfg= post-install
SUBST_MESSAGE.theme-cfg= theme-cfg tweak implementing

# Copied from bin/ and add -destdir onto its name.
# See following two targets.
bin_SCRIPTS_DESTDIR= fvwm-themes-config fvwm-themes-menuapp

# Fake by making two different version of script under bin/
pre-patch:
for i in ${bin_SCRIPTS_DESTDIR} ; do \
${CP} ${WRKSRC}/bin/$$i.in ${WRKSRC}/bin/$$i-destdir.in ;\
done

post-install:
${PREFIX}/bin/fvwm-themes-config --site --install \
${DESTDIR}${PREFIX}/bin/fvwm-themes-config-destdir --site --install \
${DISTDIR}/fvwm-themes-extra-${THEM_VER}.tar.bz2
# Remove Fake version of script created by above target
for i in ${bin_SCRIPTS_DESTDIR} ; do \
${RM} ${DESTDIR}${PREFIX}/bin/$$i-destdir ;\
done
# Disable warning as 'executable bit is set on non-executable file' etc
${FIND} ${DESTDIR}${PREFIX}/share/fvwm2/themes -type f -exec ${CHMOD} -x '{}' \;
${FIND} ${DESTDIR}${PREFIX}/share/fvwm2/images -name \*xpm -exec ${CHMOD} -x,g-w '{}' \;
${FIND} ${DESTDIR}${PREFIX}/share/fvwm2/images -type d -exec ${CHMOD} g-w '{}' \;
${FIND} ${DESTDIR}${PREFIX}/share/fvwm2/sounds -name \*au -exec ${CHMOD} -x,g-w '{}' \;
${FIND} ${DESTDIR}${PREFIX}/share/fvwm2/sounds -type d -exec ${CHMOD} g-w '{}' \;

DEPENDS+= ImageMagick-[0-9]*:../../graphics/ImageMagick
.include "../../mk/bsd.pkg.mk"
6 changes: 5 additions & 1 deletion wm/fvwm-themes/distinfo
@@ -1,8 +1,12 @@
$NetBSD: distinfo,v 1.1.1.1 2006/07/02 09:22:32 martti Exp $
$NetBSD: distinfo,v 1.2 2011/07/09 14:20:53 wiz Exp $

SHA1 (fvwm-themes-0.6.2.tar.bz2) = 63e2ed90bd172494611d3d37a418406c8e61bb27
RMD160 (fvwm-themes-0.6.2.tar.bz2) = 49706c0d2a367d2a2877ea5d1030397314ec211f
Size (fvwm-themes-0.6.2.tar.bz2) = 592419 bytes
SHA1 (fvwm-themes-extra-0.6.2.tar.bz2) = 3112f6ac44453f0fe1ec97553d6b167483f64012
RMD160 (fvwm-themes-extra-0.6.2.tar.bz2) = c78e47d355638760a990477c990e2f705dd347e7
Size (fvwm-themes-extra-0.6.2.tar.bz2) = 378884 bytes
SHA1 (patch-Makefile.am) = 3ffd7c82bc3102abfcbe31d1050a12612ab39d21
SHA1 (patch-Makefile.in) = ac08d78e293916ef2289b1a266d279b9028d4fde
SHA1 (patch-bin_Makefile.in) = 374482a3e72ebd312bbacd2e39e51e3460511c04
SHA1 (patch-bin_fvwm-themes-config-destdir.in) = 07913ca78721c6d3c53a7caad2e9834e6bd3cd05
19 changes: 19 additions & 0 deletions wm/fvwm-themes/patches/patch-Makefile.am
@@ -0,0 +1,19 @@
$NetBSD: patch-Makefile.am,v 1.1 2011/07/09 14:20:53 wiz Exp $

Use destdir fake version at install target:

--- work/fvwm-themes-0.6.2/Makefile.am.orig 2002-12-06 02:01:37.000000000 +0000
+++ Makefile.am
@@ -33,10 +33,10 @@ install-data-local:
mv -f $(DESTDIR)$(SETTINGS_FILE).tmp $(DESTDIR)$(SETTINGS_FILE)

PATH="$(DESTDIR)$(bindir):$(FVWM_BINDIR):$$PATH"; \
- $(DESTDIR)$(bindir)/fvwm-themes-config --site --reset
+ $(DESTDIR)$(bindir)/fvwm-themes-config-destdir --site --reset

if test "$(BUILD_MENUS)" = "yes"; then \
- $(DESTDIR)$(bindir)/fvwm-themes-menuapp --site --build-menus --remove-popup; \
+ $(DESTDIR)$(bindir)/fvwm-themes-menuapp-destdir --site --build-menus --remove-popup; \
fi

if test "$(GNOME_ICONS)" = "yes"; then \
19 changes: 19 additions & 0 deletions wm/fvwm-themes/patches/patch-Makefile.in
@@ -0,0 +1,19 @@
$NetBSD: patch-Makefile.in,v 1.1 2011/07/09 14:20:53 wiz Exp $

Use destdir fake version at install target:

--- work/fvwm-themes-0.6.2/Makefile.in.orig 2002-12-06 02:59:28.000000000 +0000
+++ ./Makefile.in
@@ -372,10 +372,10 @@ install-data-local:
mv -f $(DESTDIR)$(SETTINGS_FILE).tmp $(DESTDIR)$(SETTINGS_FILE)

PATH="$(DESTDIR)$(bindir):$(FVWM_BINDIR):$$PATH"; \
- $(DESTDIR)$(bindir)/fvwm-themes-config --site --reset
+ $(DESTDIR)$(bindir)/fvwm-themes-config-destdir --site --reset

if test "$(BUILD_MENUS)" = "yes"; then \
- $(DESTDIR)$(bindir)/fvwm-themes-menuapp --site --build-menus --remove-popup; \
+ $(DESTDIR)$(bindir)/fvwm-themes-menuapp-destdir --site --build-menus --remove-popup; \
fi

if test "$(GNOME_ICONS)" = "yes"; then \
78 changes: 78 additions & 0 deletions wm/fvwm-themes/patches/patch-bin_Makefile.in
@@ -0,0 +1,78 @@
$NetBSD: patch-bin_Makefile.in,v 1.1 2011/07/09 14:20:53 wiz Exp $

(1) Delete harmful DESTDIR= (empty)
(2) Add bin_SCRIPTS_DESTDIR variable for extra files faking for DESTDIR
of two scripts.
(3) Add targets to generate above two scripts

--- work/fvwm-themes-0.6.2/bin/Makefile.in.orig 2002-12-06 02:59:29.000000000 +0000
+++ ./bin/Makefile.in
@@ -32,8 +32,6 @@ mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include

-DESTDIR =
-
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
@@ -97,6 +95,8 @@ bin_SCRIPTS = fvwm-themes-config fvwm-th
fvwm-themes-menuapp fvwm-themes-com fvwm-themes-script \
fvwm-themes-images

+bin_SCRIPTS_DESTDIR = fvwm-themes-config-destdir \
+ fvwm-themes-menuapp-destdir

man_MANS = fvwm-themes-config.1 fvwm-themes-menuapp.1 fvwm-themes-com.1 \
fvwm-themes-images.1 fvwm-themes-start.1
@@ -104,12 +104,12 @@ man_MANS = fvwm-themes-config.1 fvwm-the

EXTRA_DIST = $(man_MANS)

-CLEANFILES = $(bin_SCRIPTS)
+CLEANFILES = $(bin_SCRIPTS) $(bin_SCRIPTS_DESTDIR)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_CLEAN_FILES = fvwm-themes-config fvwm-themes-start \
fvwm-themes-xrdb fvwm-themes-menuapp fvwm-themes-com fvwm-themes-script \
fvwm-themes-images
-SCRIPTS = $(bin_SCRIPTS)
+SCRIPTS = $(bin_SCRIPTS) $(bin_SCRIPTS_DESTDIR)

man1dir = $(mandir)/man1
MANS = $(man_MANS)
@@ -117,7 +117,7 @@ MANS = $(man_MANS)
NROFF = nroff
DIST_COMMON = Makefile.am Makefile.in fvwm-themes-com.in \
fvwm-themes-config.in fvwm-themes-images.in fvwm-themes-menuapp.in \
-fvwm-themes-script.in fvwm-themes-start.in fvwm-themes-xrdb.in
+fvwm-themes-script.in fvwm-themes-start.in fvwm-themes-xrdb.in fvwm-themes-config-destdir.in


DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
@@ -146,11 +146,15 @@ fvwm-themes-script: $(top_builddir)/conf
cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
fvwm-themes-images: $(top_builddir)/config.status fvwm-themes-images.in
cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+fvwm-themes-config-destdir: $(top_builddir)/config.status fvwm-themes-config-destdir.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+fvwm-themes-menuapp-destdir: $(top_builddir)/config.status fvwm-themes-menuapp-destdir.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status

-install-binSCRIPTS: $(bin_SCRIPTS)
+install-binSCRIPTS: $(bin_SCRIPTS) $(bin_SCRIPTS_DESTDIR)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(bindir)
- @list='$(bin_SCRIPTS)'; for p in $$list; do \
+ @list='$(bin_SCRIPTS) $(bin_SCRIPTS_DESTDIR)'; for p in $$list; do \
if test -f $$p; then \
echo " $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \
$(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \
@@ -162,7 +166,7 @@ install-binSCRIPTS: $(bin_SCRIPTS)

uninstall-binSCRIPTS:
@$(NORMAL_UNINSTALL)
- list='$(bin_SCRIPTS)'; for p in $$list; do \
+ list='$(bin_SCRIPTS) $(bin_SCRIPTS_DESTDIR)'; for p in $$list; do \
rm -f $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \
done

115 changes: 115 additions & 0 deletions wm/fvwm-themes/patches/patch-bin_fvwm-themes-config-destdir.in
@@ -0,0 +1,115 @@
$NetBSD: patch-bin_fvwm-themes-config-destdir.in,v 1.1 2011/07/09 14:20:53 wiz Exp $

(0) This file (fvwm-themes-config-destdir) is fake version of
fvwm-themes-config.
It is only for build time, and will be deleted before install.
(1) Duplicates @searchPath to @searchPathD for DESTDIR version.
It will be SUBST'ed by Makefile
(2) s/^$ROOT_PREFIX//; tweak borrowed from another purpose of original scripts
It also will be SUBST'ed.

--- work/fvwm-themes-0.6.2/bin/fvwm-themes-config-destdir.in.orig 2011-07-02 00:38:28.000000000 +0000
+++ ./bin/fvwm-themes-config-destdir.in
@@ -21,6 +21,7 @@ my $buildId = '@FT_BUILD_ID@';

my $scriptName = ($0 =~ m:([^/]+)$:, $1);
my $scriptFile = "$bindir/$scriptName";
+ $scriptFile =~ s|-destdir||;
my $rcFile = "themes-rc";
my $rcFile2 = "$rcFile-2";
# maybe we may use .$rcFile-3
@@ -28,6 +29,7 @@ my $rcFile3 = "$rcFile-3";
my $userHome = $ENV{'HOME'} || "./.";
my $userDir = $ENV{'FVWM_USERDIR'} || "$userHome/.fvwm";
my @searchPath = ($userDir, $ftDataDir);
+my @searchPathD = ($userDir, $ftDataDir);
my ($workDir, $siteDir);
my $themesSubDir = 'themes';
my $currentThemeName = 'current';
@@ -274,7 +276,7 @@ sub getExpandedRc ($) {
my $file = shift;
### should detect infinitive loops?
if (!-f $file) {
- foreach (@searchPath) {
+ foreach (@searchPathD) {
if (-f "$_/$file") { $file = "$_/$file"; last; }
}
}
@@ -310,7 +312,7 @@ sub searchThemeCfgIncludeFile ($$) {
unshift @subDirs, ".";
}
my $dir;
- foreach $dir (@searchPath) {
+ foreach $dir (@searchPathD) {
foreach (@subDirs) {
my $file = "$dir/$themesSubDir/$_/$file";
return $file if -f $file;
@@ -655,7 +657,7 @@ sub parseComponentName ($) {
sub getThemeDir ($) {
my $theme = shift;
my $dir;
- foreach $dir (@searchPath) {
+ foreach $dir (@searchPathD) {
my $dir = "$dir/$themesSubDir/$theme";
return $dir if -d $dir;
}
@@ -712,7 +714,7 @@ sub getAllThemes (;$$) {
my @dirList = ();
push @dirList, $siteDir if $onlySite;
push @dirList, $userDir if $onlyUser;
- @dirList = @searchPath unless @dirList;
+ @dirList = @searchPathD unless @dirList;
my $themes = {};
my $dir;
foreach $dir (@dirList) {
@@ -1322,6 +1324,7 @@ sub getAllThemeSubMenusRc ($) {
} @$components);

my $readmeFile = getThemeDir($theme) . "/README";
+ $readmeFile =~ s/^$ROOT_PREFIX//;
if (-r $readmeFile) {
$menuRc .= qq(+ "" Nop\n);
$menuRc .= qq(+ "README%menu/information.xpm%"\tFuncFvwmViewFile "$readmeFile"\n);
@@ -2023,6 +2026,7 @@ sub getReadsRc($) {
. $valueFile0;
$optionFile =~ s/^$ROOT_PREFIX//;
$valueFile =~ s/^$ROOT_PREFIX//;
+ $valueFile0 =~ s/^$ROOT_PREFIX//;

push @$optionExports, {
'f' => $valueFile, 'c' => $current, 'v' => $valueFile0
@@ -2296,8 +2300,10 @@ Read @$rcFile2@
"\nFuncFvwmRestartFvwmTheme\n": "";

$contents = "# fvwm/$rcFile2 $version$header";
+ my $siteDirD = $siteDir;
+ $siteDirD =~ s/^$ROOT_PREFIX//;
$contents .= qq{
-SetEnv FT_DATADIR '$siteDir'
+SetEnv FT_DATADIR '$siteDirD'
ImagePath $imagePath
$funcFvwmRestartFvwmTheme
$menusAndHooksRc
@@ -2307,7 +2313,7 @@ Mouse 2 A CM Menu MenuFvwmThemes

$contents = "# fvwm/$rcFile3 $version$header";
$contents .= qq{
-SetEnv FT_DATADIR '$siteDir'
+SetEnv FT_DATADIR '$siteDirD'
ImagePath $imagePath

$switchMenusAndHooksRc
@@ -2399,10 +2405,9 @@ GetOptions(
"no-cfg-cache" => \$noCfgCache,
) || wrongUsage();

-shift @searchPath if $site;
-$workDir = $searchPath[0];
-$siteDir = $searchPath[-1];
-
+shift @searchPathD if $site;
+$workDir = $searchPathD[0];
+$siteDir = $searchPathD[-1];
if ($install) {
my $themesDir = "$workDir";
my $version = $version;

0 comments on commit 9e68eb3

Please sign in to comment.