diff options
author | schnetter <schnetter@83718e91-0e4f-0410-abf4-91180603181f> | 2005-05-25 13:18:59 +0000 |
---|---|---|
committer | schnetter <schnetter@83718e91-0e4f-0410-abf4-91180603181f> | 2005-05-25 13:18:59 +0000 |
commit | fe82daa7373a7b1d0347a7f7b2c2cf55c33d83a8 (patch) | |
tree | cb3914290b19a5a9fadccf4d2f45abebd3ec4b1e /src/output_source.c | |
parent | e6127db547407be2e1370b8606292fb1ca02dc47 (diff) |
Correct parameter file that outputs that tarball.
Create one tarball per thorn; this scales much better, and is only
slightly less convenient.
Create the output directory if it does not yet exist.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusUtils/Formaline/trunk@9 83718e91-0e4f-0410-abf4-91180603181f
Diffstat (limited to 'src/output_source.c')
-rw-r--r-- | src/output_source.c | 76 |
1 files changed, 51 insertions, 25 deletions
diff --git a/src/output_source.c b/src/output_source.c index 45bfb6a..db70022 100644 --- a/src/output_source.c +++ b/src/output_source.c @@ -12,49 +12,75 @@ -struct chunkinfo +struct sourceinfo { char const * data; - size_t const * length; + size_t length; + char const * arrangement; + char const * thorn; }; -extern struct chunkinfo cactus_source_chunks []; -extern size_t cactus_source_chunks_length; +extern struct sourceinfo const * const cactus_source []; +extern size_t const cactus_source_length; -void -Formaline_OutputSource (CCTK_ARGUMENTS) +int +Formaline_OutputSource () { - DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; - char const sourcename [] = "cactus-source.tar.gz"; - size_t filenamelength; - char * filename; + char filename [10000]; FILE * file; - size_t chunk; + int count; - if (CCTK_MyProc (cctkGH) != 0) return; - - filenamelength = strlen (out_dir) + strlen (sourcename) + 2; - filename = malloc (filenamelength); - assert (filename); - sprintf (filename, "%s/%s", out_dir, sourcename); + if (CCTK_MyProc (0) != 0) return; + { CCTK_PRINTSEPARATOR } CCTK_VInfo (CCTK_THORNSTRING, - "Writing tarball with Cactus sources to file \"%s\"", filename); + "Writing tarballs with the Cactus sources into the directory \"%s\"", out_dir); - file = fopen (filename, "w"); - assert (file); - for (chunk = 0; chunk < cactus_source_chunks_length; ++ chunk) + CCTK_CreateDirectory (0755, out_dir); + + /* Output all thorns' tarballs */ + for (count = 0; count < cactus_source_length; ++ count) { - fwrite (cactus_source_chunks[chunk].data, - sizeof * cactus_source_chunks[chunk].data, - * cactus_source_chunks[chunk].length, + snprintf (filename, sizeof filename, + "%s/cactus-source-%s.tar.gz", + out_dir, cactus_source[count]->thorn); + file = fopen (filename, "w"); + assert (file); + fwrite (cactus_source[count]->data, + sizeof * cactus_source[count]->data, + cactus_source[count]->length, file); + fclose (file); } + + /* Add a README */ + snprintf (filename, sizeof filename, "%s/README", out_dir); + file = fopen (filename, "w"); + assert (file); + fprintf (file, +"README for the Cactus source tree\n" +"\n" +"This directory contains a complete Cactus source tree in several tarballs.\n" +"(A tarball is a file with a suffix like \".tar.gz\".)\n" +"The tarballs were created by the thorn AEIThorns/Formaline when the\n" +"corresponding executable was produced, and were stored in the executable.\n" +"The parameter file in this directory was used to extract the tarballs\n" +"from the executable.\n" +"Thorn AEIThorns/Formaline contains more information about this feature.\n" +"\n" +"In order to fully recreate the Cactus source tree, unpack all tarballs\n" +"in this directory, e.g. with commands like\n" +"\ttar xzf cactus-source-Cactus.tar.gz\n" +"for all tarballs. All tarballs should be unpacked into the same directory.\n" +"\n" +"The files \"config-info\" and \"ThornList\" that were used to build the\n" +"executable can then be found in the \"configs\" subdirectory.\n" + ); fclose (file); - free (filename); + return 0; } |