Add debianisation code and automatic build script
[wmaker-crm.git] / debian / wmaker.sh
1 #!/bin/sh
2
3 set -e
4
5 [ -n "$GNUSTEP_USER_ROOT" ] || export GNUSTEP_USER_ROOT="$HOME/GNUstep"
6 gs_base="$GNUSTEP_USER_ROOT"
7 gs_defaults="$gs_base/Defaults"
8 gs_system_defaults=/etc/GNUstep/Defaults
9 wm_base="$gs_base/Library/WindowMaker"
10 wm_backgrounds="$wm_base/Backgrounds"
11 wm_iconsets="$wm_base/IconSets"
12 wm_soundsets="$wm_base/SoundSets"
13 wm_pixmaps="$wm_base/Pixmaps"
14 gs_icons="$gs_base/Library/Icons"
15 wm_style="$wm_base/Style"
16 wm_styles="$wm_base/Styles"
17 wm_sounds="$wm_base/Sounds"
18 wm_themes="$wm_base/Themes"
19 WindowMaker=/usr/lib/WindowMaker/WindowMaker
20 convertfonts=/usr/lib/WindowMaker/convertfonts
21
22 make_dir_if_needed ()
23 {
24 if [ ! -d "$1" ] ; then
25 install -m 0755 -d "$1"
26 fi
27 }
28
29 rename_dir_if_possible ()
30 {
31 if [ ! -d "$2" ] ; then
32 if [ -d "$1" ] ; then
33 mv "$1" "$2"
34 fi
35 fi
36 }
37
38 copy_defaults_if_needed ()
39 {
40 file="$gs_defaults/$1"
41 system_file="$gs_system_defaults/$1"
42 if [ ! -f "$file" ] ; then
43 install -m 0644 "$system_file" "$file"
44 fi
45 }
46
47 make_dir_if_needed "$gs_defaults"
48 make_dir_if_needed "$wm_base"
49 make_dir_if_needed "$wm_backgrounds"
50 make_dir_if_needed "$wm_iconsets"
51 make_dir_if_needed "$wm_soundsets"
52 make_dir_if_needed "$wm_pixmaps"
53 make_dir_if_needed "$gs_icons"
54 make_dir_if_needed "$wm_sounds"
55 rename_dir_if_possible "$wm_style" "$wm_styles"
56 make_dir_if_needed "$wm_styles"
57 make_dir_if_needed "$wm_themes"
58
59 copy_defaults_if_needed WindowMaker
60 copy_defaults_if_needed WMRootMenu
61 copy_defaults_if_needed WMState
62 #copy_defaults_if_needed WMWindowAttributes
63
64 if [ -x $convertfonts -a ! -e "$wm_base/.fonts_converted" ] ; then
65 # --keep-xlfd is used in order to preserve the original information
66 $convertfonts --keep-xlfd "$gs_defaults/WindowMaker"
67 if [ -f "$gs_defaults/WMGLOBAL" ] ; then
68 $convertfonts --keep-xlfd "$gs_defaults/WMGLOBAL"
69 fi
70 find "$wm_styles" -type f -print0 -mindepth 1 -maxdepth 1 |
71 xargs -0 -r -n 1 $convertfonts --keep-xlfd
72 touch "$wm_base/.fonts_converted"
73 fi
74
75 if [ -n "$1" -a -x "$WindowMaker$1" ] ; then
76 WindowMaker="$WindowMaker$1"
77 shift
78 fi
79
80 exec "$WindowMaker" "$@"