File: make_executable_tar

package info (click to toggle)
ferret-vis 7.6.0-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 218,744 kB
  • sloc: fortran: 234,502; ansic: 51,846; csh: 2,516; makefile: 1,613; sh: 1,571; pascal: 569; sed: 184; lisp: 122; awk: 26
file content (170 lines) | stat: -rwxr-xr-x 4,914 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#! /bin/csh

# mycp needs to recursively copy subdirectories for the lib/python* directories
set mycp = "/bin/cp -R -p"
set mylns = "/bin/ln -s"

echo ""
if ( $#argv == 3 ) then
    if ( "$3" == "-y" ) then
        set auto_ans = "y"
    endif
endif
if ( ($#argv < 2) || ($#argv > 3) || \
     (($#argv == 3) && (! $?auto_ans)) ) then
   echo "Usage:  $0  <ferret_dir>  <target_dir>  [ -y ] "
   echo ""
   echo "    Creates the Ferret installation file fer_executables.tar.gz. "
   echo "    The required files will be copied from the ferret source directory "
   echo "    <ferret_dir>, in which ferret or pyferret, gksm2ps, and the font files "
   echo "    have been built.  All the files required will be copied to a temporary "
   echo "    directory which this script will create.  Any missing executables will "
   echo "    be noted.  The gzipped tar file fer_executables.tar.gz will be written "
   echo "    in <target_dir>, which must already exist.  If the optional third "
   echo "    argument '-y' is given, any questions normally asked by the script "
   echo "    will be automatically answered with 'y'. "
   echo ""
   exit 1
endif

if ( ! -d "$1" ) then
   echo "$1 does not exist or is not a directory"
   echo ""
   exit 1
endif
set ferret_dir = `cd "$1" ; pwd`
if ( ! -d "$2" ) then
   echo "$2 does not exist or is not a directory"
   echo ""
   exit 1
endif
set target_dir = `cd "$2" ; pwd`

set pyferret_dir = "${ferret_dir}/pyferret_install"
if ( ! -d "${pyferret_dir}" ) then
   echo "${pyferret_dir} does not exist or is not a directory"
   echo "    pyferret module not created"
   echo ""
   set pyferret_dir = ""
endif

# Get the version of ferret recorded in the code
set version = `awk '/revision_level/ {print $4}' ${ferret_dir}/fer/dat/xrevision_data.F`
if ( ($status != 0) || ("${version}" == "") ) then
   echo "Unable to read the version number from xrevision_data.F in ${ferret_dir}/fer/dat"
   echo ""
   exit 1
endif
echo "Ferret version number is ${version}"
echo ""

# Make a clean temporary directory for the tar file contents
if ( $?TMPDIR ) then
   set temp_dir = "${TMPDIR}/fer_exe_$$"
else
   set temp_dir = "/tmp/fer_exe_$$"
endif
rm -fr ${temp_dir}
mkdir ${temp_dir}

mkdir ${temp_dir}/bin

# Copy fer/ferret_c
if ( -x ${ferret_dir}/fer/ferret_c ) then
   ${mycp} ${ferret_dir}/fer/ferret_c ${temp_dir}/bin/ferret_v${version}
   cd ${temp_dir}/bin
   ${mylns} ferret_v${version} ferret
else
   echo "No ferret_c executable found in ${ferret_dir}/fer"
#  An error only if pyferret_dir was not given
   if ( "${pyferret_dir}" == "" ) then
      echo ""
      exit 1
   else
      echo "   ferret_v<n> and ferret symbolic link not created"
      echo ""
   endif
endif

# Copy dylibs, if present
if ( -d ${ferret_dir}/dylibs ) then
   ${mycp} ${ferret_dir}/dylibs ${temp_dir}
endif

# Copy the external function shared-object library files
mkdir -p ${temp_dir}/ext_func/libs
# If pyferret, do not copy the .so files at this time due to pyferret bug
if ( "${pyferret_dir}" == "" ) then
   find ${ferret_dir}/external_functions -type f -perm -100 -name \*.so -exec ${mycp} {} ${temp_dir}/ext_func/libs \;
endif

# Copy gksm2ps/gksm2ps
if ( ! -x ${ferret_dir}/gksm2ps/gksm2ps ) then
   echo "No gksm2ps executable found in ${ferret_dir}/gksm2ps"
   echo ""
   exit 1
endif
${mycp} ${ferret_dir}/gksm2ps/gksm2ps ${temp_dir}/bin/gksm2ps

# Copy font files from bin/build_fonts/unix/
set fer_files = ${ferret_dir}/bin/build_fonts/unix/f*
if ( ($status != 0) || ("${fer_files}" == "") ) then
   echo "No font files found in ${ferret_dir}/bin/build_fonts/unix"
   echo ""
   exit 1
endif
mkdir ${temp_dir}/ppl
mkdir ${temp_dir}/ppl/fonts
${mycp} ${fer_files} ${temp_dir}/ppl/fonts

# Copy pyferret files
if ( "${pyferret_dir}" != "" ) then
   set python_dirs = ${pyferret_dir}/lib/python*
   if ( ($status != 0) || ("${python_dirs}" == "") ) then
      echo "No python* directories found in ${pyferret_dir}/lib"
      echo ""
      exit 1
   endif
   if ( ! -d ${temp_dir}/lib ) then
      mkdir ${temp_dir}/lib
   endif
   ${mycp} ${python_dirs} ${temp_dir}/lib
endif

# Create the tar file
set ctar_file = "${target_dir}/fer_executables.tar.gz"
echo ""
echo "The tar file will be created from the contents of "
echo "${temp_dir}"
echo "(which can now be examined or tweaked from another shell/window)"
echo ""
echo -n "Create gzipped tar file ${ctar_file} (y/n)? "
if ( $?auto_ans ) then
    set ans = "${auto_ans}"
    echo $ans
else
    set ans = $<
endif
while ( ("${ans}" != "y") && ("${ans}" != "n") )
   echo -n "Answer either y or n: "
   set ans = $<
end
if ( "${ans}" == "y" ) then
   echo ""
   cd ${temp_dir}
   rm -f "${ctar_file}"
   tar czf "${ctar_file}" *
   echo ""
   ls -l "${ctar_file}"
else
   echo ""
   echo "Tar file NOT created"
endif

# Clean up
echo ""
echo "Cleaning up - removing ${temp_dir}"
cd "${target_dir}"
rm -fr "${temp_dir}"
echo ""