Revision 42824

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/resources-application/tools/mkexec
44 44
  cd "$WORKINGFOLDER"
45 45

  
46 46
  echo "Making selfextract for ${OS} ${ARCH} using:"
47
  echo "  ${SELF_EXTRACT}"
48
  echo "  ${GVSPKG_JRE}"
49
  echo "  ${INSTALL_JAR_BASENAME}"
47
  echo "  selfextract: ${SELF_EXTRACT}"
48
  echo "  jre: ${GVSPKG_JRE}"
49
  echo "  java installer: ${INSTALL_JAR_BASENAME}"
50
  echo "  working folder: ${WORKINGFOLDER}"
50 51

  
51 52

  
52 53
  echo "Remove previous temporary files"
......
95 96
  # -------------------------------------------------------------
96 97
  # Creamos con el fichero tar generado el autoextraible
97 98
  echo "Making selfextract with archive file"
98
  "${WORKINGFOLDER}/${SELF_EXTRACT}" --create "${INSTALL_JAR%.jar}.run" "$DATA_ARCHIVE"
99

  
99
  {
100
    cat ${WORKINGFOLDER}/${SELF_EXTRACT}
101
    echo ";!@selfextract@!'"
102
    cat "$DATA_ARCHIVE"
103
  } > "${INSTALL_JAR%.jar}.run"
100 104
  echo "Created ${INSTALL_JAR%.jar}.run"
101 105
  echo ""
102 106
}
......
118 122
  cd "$WORKINGFOLDER"
119 123

  
120 124
  echo "Making selfextract for ${OS} ${ARCH} using:"
121
  echo "  ${SELF_EXTRACT}"
122
  echo "  ${GVSPKG_JRE}"
123
  echo "  ${INSTALL_JAR_BASENAME}"
125
  echo "  selfextract: ${SELF_EXTRACT}"
126
  echo "  jre: ${GVSPKG_JRE}"
127
  echo "  java installer: ${INSTALL_JAR_BASENAME}"
128
  echo "  working folder: ${WORKINGFOLDER}"
124 129

  
125 130
  echo "Remove previous temporary files"
126 131
  rm -f "$DATA_ARCHIVE"
......
205 210
  GVSIG_STATE="$3"
206 211
  GVSIG_DISTRIBUTION="$4"
207 212
  ROOTFOLDER="$5"
208

  
209

  
213
  
214
  echo "
215
mkexec
216
  root folder=$ROOTFOLDER
217
"
210 218
  mkdir -p "$ROOTFOLDER"
211 219

  
212 220
  for os_arch in "lin x86_64" "lin x86" "win x86_64" "win x86"
......
220 228
      echo "Downloading installer ${INSTALL_JAR_BASENAME}"
221 229
      wget  -q $WGET_SHOW_PROGRESSBAR "$URL_DISTS/${GVSIG_VERSION}/builds/${GVSIG_BUILDNUMBER}/${INSTALL_JAR_BASENAME}"
222 230
    fi
223
    mkexec "$OS" "$ARCH" "$INSTALL_JAR" "$ROOTFOLDER/mkexec"
231
    mkexec "$OS" "$ARCH" "$INSTALL_JAR" "$ROOTFOLDER/mkexec.tmp"
224 232
  done
225
  rm -rf "$ROOTFOLDER/mkexec"
233
  rm -rf "$ROOTFOLDER/mkexec.tmp"
226 234
}
227 235

  
228
main $@ #"2.3.0" "2428" "testing" "online" "/home/jjdelcerro/temp/selfextracts/lin-x86_64"
229

  
236
main $@
237
  
238
  
trunk/org.gvsig.desktop/org.gvsig.desktop.installer/org.gvsig.desktop.selfextract.lin/selfextract.c
10 10
#include <errno.h>
11 11
#include <dirent.h>
12 12

  
13
char *end_of_header = "\n\n END OF HEADER\n\n";
14 13

  
15 14
int remove_directory(const char *path) {
16 15
  DIR *d = opendir(path);
......
29 28
      if (!strcmp(p->d_name, ".") || !strcmp(p->d_name, "..")) {
30 29
          continue;
31 30
      }
32
      len = path_len + strlen(p->d_name) + 2; 
31
      len = path_len + strlen(p->d_name) + 2;
33 32
      buf = malloc(len);
34 33
      if (buf) {
35 34
        struct stat statbuf;
......
54 53
}
55 54

  
56 55

  
56
char *getMark() {
57
  static char buffer[100];
58

  
59
  strcpy(buffer, ";!@self");
60
  strcat(buffer,"extract@!\n");
61
  return buffer;
62
}
63

  
64
int findMark(int fd) {
65
  static char buffer[1024*50];
66

  
67
  int x=lseek(fd,0,SEEK_SET);
68
  if( x<0 ) {
69
    printf("seek 0 error\n");
70
    return -1;
71
  }
72
  x=read(fd,buffer,1024*50);
73
  if( x<0 ) {
74
    printf("read error\n");
75
    return -1;
76
  }
77
  char *mark = getMark();
78
  int markSize = strlen(mark);
79
  char *p;
80
  for( p=buffer ; p<buffer+x; p++ ) {
81
    if( strncmp(p,mark,markSize)==0 ) {
82
      int n = p-buffer + markSize;
83
      printf("found %d\n", n);
84
      return n;
85
    }
86
  }
87
  printf("not found\n");
88
  return -1;
89
}
90

  
57 91
void extract(char *source) {
58 92
  static char path[1024];
59 93
  static char folder[1024];
60 94
  TAR *tar;
61 95
  int start,x;
62
  
63
  
96

  
97

  
64 98
  x = tar_open(&tar, source, 0, O_RDONLY, 0, 0);
65 99
  if( x <0 ) {
66 100
    fprintf(stderr,"Can 't extract from '%s', don't create tar object.\n", source);
67 101
    perror(NULL);
68 102
    exit(1);
69 103
  }
70
  
104

  
71 105
  int fdi = tar_fd(tar);
72
  x = lseek(fdi,-sizeof(start),SEEK_END);
73
  if( x <0 ) {
74
    fprintf(stderr,"Can 't extract from '%s', don't position at end of file.\n", source);
106
  start = findMark(fdi);
107
  if( start <0 ) {
108
    fprintf(stderr,"Can 't extract from '%s', don't find position of tar start.\n", source);
75 109
    perror(NULL);
76
    exit(2);
77
  }
78
  x = read(fdi,&start,sizeof(start));
79
  if( x <0 ) {
80
    fprintf(stderr,"Can 't extract from '%s', don't read position of tar start.\n", source);
81
    perror(NULL);
82 110
    exit(3);
83 111
  }
84
  x = lseek(fdi,start+strlen(end_of_header),SEEK_SET);
112
  x = lseek(fdi,start,SEEK_SET);
85 113
  if( x <0 ) {
86 114
    fprintf(stderr,"Can 't extract from '%s', don't seek at position of tar start.\n", source);
87 115
    perror(NULL);
88 116
    exit(4);
89 117
  }
90
  
118

  
91 119
  sprintf(folder,"/tmp/selfextract-%d", getpid());
92 120
  printf("Extracting to %s...\n", folder);
93
  x = tar_extract_all(tar, folder); 
121
  x = tar_extract_all(tar, folder);
94 122
  if( x <0 ) {
95 123
    fprintf(stderr,"Can 't extract from '%s', output folder '%s'.\n", source, folder);
96 124
    perror(NULL);
......
117 145
  printf("Removing %s...\n", folder);
118 146
  remove_directory(folder);
119 147
  printf("Finish\n");
120
  exit(0);  
148
  exit(0);
121 149
}
122 150

  
123 151
void create(char *source,char *target, char *tarfile) {
124 152
  static char buffer[1024];
125 153
  int size;
126 154
  int n,x;
127
  
155

  
128 156
  int fdo = creat(target,S_IWUSR|S_IXUSR|S_IRUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IXOTH);
129 157
  if( fdo <0 ) {
130 158
    fprintf(stderr,"Can't create '%s'.\n", target);
......
137 165
    perror(NULL);
138 166
    exit(21);
139 167
  }
140
  
141
  size = lseek(fdi,0,SEEK_END);
142
  if( size<0 ) {
143
    fprintf(stderr,"Can't create '%s', don't calculate the size of file '%s'.\n", target, source);
144
    perror(NULL);
145
    exit(22);
146
  }
147
  x=lseek(fdi,0,SEEK_SET);
148
  if( x<0 ) {
149
    fprintf(stderr,"Can't create '%s', don't rewind file '%s'.\n", target, source);
150
    perror(NULL);
151
    exit(23);
152
  }
153
  
168

  
154 169
  while( (n=read(fdi,buffer,1024)) != 0 ) {
155 170
    if( n<0 ) {
156 171
      fprintf(stderr,"Can't create '%s', don't read file '%s'.\n", target, source);
......
165 180
    }
166 181
  }
167 182
  close(fdi);
168
  
169
  x=write(fdo,end_of_header,strlen(end_of_header));
170
  if( x!=strlen(end_of_header) ) {
183

  
184
  char *mark = getMark();
185
  x=write(fdo,mark,strlen(mark));
186
  if( x!=strlen(mark) ) {
171 187
    fprintf(stderr,"Can't create '%s', magic to end of file.\n", target);
172 188
    perror(NULL);
173 189
    exit(26);
174 190
  }
175
  
191

  
176 192
  fdi = open(tarfile,O_RDONLY);
177 193
  if( fdi<0 ) {
178 194
    fprintf(stderr,"Can't create '%s', don't open file '%s'.\n", target, tarfile);
......
194 210
  }
195 211
  close(fdi);
196 212

  
197
  x=write(fdo,&size,sizeof(size));
198
  if( x!=sizeof(size) ) {
199
    fprintf(stderr,"Can't create '%s', don't add size to end of file.\n", target);
200
    perror(NULL);
201
    exit(30);
202
  }
203 213
  close(fdo);
204 214
  exit(0);
205 215
}
trunk/org.gvsig.desktop/org.gvsig.desktop.installer/src/main/packaging/gvspkg
23 23
VERBOSE = False
24 24
SEARCH_VERSIONS = list()
25 25

  
26
#LINUX_EXEC_EXTENSION=".run" # antes ".bin"
27

  
28 26
class Platform:
29 27
  def __init__(self,os,arch,exe):
30 28
    self.os = os
31 29
    self.arch = arch
32 30
    self.exe_extension = exe
33
  
34
  def getOS():
31

  
32
  def getOS(self):
35 33
    return self.os
36
  
37
  def getArch():
34

  
35
  def getArch(self):
38 36
    return self.arch
39
  
40
  def getExeExtension():
37

  
38
  def getExeExtension(self):
41 39
    return self.exe_extension
42 40

  
43
platforms = ( 
41
platforms = (
44 42
  Platform("lin","x86",".run"),
45 43
  Platform("lin","x86_64",".run"),
46 44
  Platform("win","x86",".exe"),
......
867 865
  item.getOwner()
868 866
      )
869 867
    html += """ </tbody>\n </table>
870
<!--javascript para la visualizaci�n de la tabla y carga din�mica del contenido del enlace -->
868
<!--javascript para la visualizacion de la tabla y carga dinamica del contenido del enlace -->
871 869
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
872 870
<script src="http://datatables.net/release-datatables/media/js/jquery.dataTables.js" type="text/javascript"></script>
873 871
<script type="text/javascript" src="js/thickbox-compressed.js"></script>
874 872

  
875
<!-- inicializacin de la tabla con cosas chachis -->
873
<!-- inicializaci�n de la tabla con cosas chachis -->
876 874
<script type="text/javascript">
877 875
  $(document).ready(function() {
878 876
      $('#pkglist').dataTable( {
......
958 956
  html += '    <tr valing="top"><th valing="top">%s </th><td>%s</td></tr>\n'%("Description", description)
959 957
  html += """  </tbody>\n</table>\n"""
960 958
  html += """
961
  <!-- javascript para la visualizacin de la tabla -->
959
  <!-- javascript para la visualizacion de la tabla -->
962 960
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>
963 961
  <script src="http://datatables.net/release-datatables/media/js/jquery.dataTables.js" type="text/javascript"></script>
964
  <!-- inicializacin de la tabla con cosas chachis -->
962
  <!-- inicializaci�n de la tabla con cosas chachis -->
965 963
  <script type="text/javascript">
966 964
    $(document).ready(function() {
967 965
      $('#pkgdetails').dataTable( {
......
992 990
  f.close()
993 991
  zf.close()
994 992

  
993

  
994
def extract_mkexec(zfile, targetfolder):
995
  print "extract_mkexec: zfile=%s, target=%s" % (zfile, os.path.join(targetfolder,"mkexec"))
996
  zf = zipfile.ZipFile(zfile)
997
  data = zf.read("tools/mkexec")
998
  f = open(os.path.join(targetfolder,"mkexec"),"wb")
999
  f.write(data)
1000
  f.close()
1001
  zf.close()
1002

  
1003

  
995 1004
def prepare_portable(args):
996 1005
    cmd = Command(args)
997 1006
    try:
......
1122 1131
    if not os.path.isdir(portable_folder) :
1123 1132
      do_prepare_portable(build,state)
1124 1133
    os.system('cd %s ; ./make-portable' % (portable_folder))
1125
    
1134

  
1126 1135
    message("Removing previos portable zip files")
1127 1136
    for platform in platforms :
1128 1137
      removefile(join(build_folder,"gvSIG-desktop-%s-%s-%s-%s-%s.zip" %  (getVersion(),build,state,platform.getOS(),platform.getArch())))
......
1134 1143
        join(portable_folder,"gvSIG-desktop-%s-%s-%s-%s-%s" % (getVersion(),build,state,platform.getOS(),platform.getArch())),
1135 1144
        build_folder
1136 1145
      )
1137
    #message("Remove temporary folders")
1138
    #shutil.rmtree(target_folder)
1146
    message("Remove temporary folders")
1147
    shutil.rmtree(target_folder)
1139 1148

  
1149
def mkexec(version, build, state, distribution_name, folder):
1150
  fname = "gvSIG-desktop-%s-%s-%s-lin-x86_64-online.zip" % (version,build,state)
1151
  extract_mkexec(os.path.join(folder,fname), folder)
1152
  mychmod(os.path.join(folder,"mkexec"),RWXALL)
1153
  cmd = 'cd %s ; ./mkexec "%s" "%s" "%s" "%s" "%s"' % (folder,version, build, state, distribution_name, folder)
1154
  print "mkexec: cmd=", cmd
1155
  os.system(cmd)
1156
  os.remove(os.path.join(folder,"mkexec"))
1157

  
1140 1158
def mkdist(args):
1141 1159
    cmd = Command(args)
1142 1160
    try:
......
1187 1205
    shutil.copyfile("packages.gvspki.md5", gvspki_filename +".md5")
1188 1206

  
1189 1207
    for platform in platforms:
1190
        message( "Creating installers for platform "+cur_os+"/"+cur_arch+"...")
1208
        message( "Creating installers for platform "+platform.getOS()+"/"+platform.getArch()+"...")
1191 1209
        gvspks_filename = "builds/"+build+"/gvSIG-desktop-" + VERSION + "-" + build+ "-" + state + "-"+platform.getOS()+"-"+platform.getArch()+".gvspks"
1192 1210
        online_filename = "builds/"+build+"/gvSIG-desktop-" + VERSION + "-" + build+ "-" + state + "-"+platform.getOS()+"-"+platform.getArch() + "-online.jar"
1193 1211

  
......
1206 1224
        mychmod(online_filename+".md5",RWALL)
1207 1225

  
1208 1226

  
1209
        executeCommand("mkinstall" , "--addjre"+platform.getOS(), online_filename, gvspks_filename)
1227
        executeCommand("mkinstall" , online_filename, gvspks_filename)
1210 1228

  
1211 1229
        message( "Renaming files from custom to standard...")
1212 1230
        target_filename = "builds/"+build+"/gvSIG-desktop-" + VERSION + "-" + build+ "-" + state + "-"+platform.getOS()+"-"+platform.getArch()+"-"+distribution_name + ".jar"
......
1221 1239

  
1222 1240
        message( "Createds installers for platform "+platform.getOS()+"/"+platform.getArch()+"\n")
1223 1241

  
1242
    mkexec(VERSION, build, state, distribution_name, os.path.join(os.getcwd(), "builds", build))
1243

  
1224 1244
    message( "Coping html index to browse paqueges of the distro.")
1225 1245
    shutil.rmtree("builds/"+build+"/web", ignore_errors=True)
1226 1246
    shutil.copytree("web", "builds/"+build+"/web")
......
1235 1255
    message( "\nCreation of distribution completed.\n")
1236 1256

  
1237 1257

  
1238

  
1239

  
1240 1258
def show(args):
1241 1259
    cmd = Command(args)
1242 1260
    try:
......
1682 1700
        No crea el fichero gvspks, solo crea el gvspki
1683 1701

  
1684 1702
     -I full-path-to-package | --include full-path-to-package
1685
        A�ade el paquete indicado a la lista de paquetes aunque no coincida para
1703
        Agrega el paquete indicado a la lista de paquetes aunque no coincida para
1686 1704
        la version de gvSIG con la que se esta trabajando.
1687 1705

  
1688 1706
mkdist [OPTIONS]

Also available in: Unified diff