Daniel Gruss vor 2 Jahren
Ursprung
Commit
3012492b38
3 geänderte Dateien mit 119 neuen und 164 gelöschten Zeilen
  1. 69 9
      generator.php
  2. 50 150
      main.tex.php
  3. 0 5
      tugraz_defaults.sty

+ 69 - 9
generator.php

@@ -45,6 +45,10 @@ The absolute minimum for a cumulative thesis is currently 3 papers first-authore
 --no-overwrite           do not overwrite files and folders
 --no-compile-check       do not perform a compile check
 --use-backups            restore backups before making changes
+--cv                     add a CV
+                         (unusual for PhD theses, required for habilitation theses)
+--no-stat-declaration    do not add the statutory declaration
+                         (required for PhD thesis, unusual for habilitation theses)
 -n                       skip all prompts (implies --no-overwrite)
 --help                   display this help and exit
 END;
@@ -191,24 +195,24 @@ END;
     }
     return array_combine($targets,$texfiles);
   }
-  function file_get_and_backup($f)
+  function file_get_and_backup($f,$bak = ".orig_bak")
   {
     global $options;
     if (isset($options["--use-backups"]))
     {
-      if (file_exists("$f.bak"))
-        copy("$f.bak", $f);
+      if (file_exists("$f$bak"))
+        copy("$f$bak", $f);
     }
     $content = file_get_contents("$f");
-    if (!file_exists("$f.bak"))
-      file_put_contents("$f.bak",$content);
+    if (!file_exists("$f$bak"))
+      file_put_contents("$f$bak",$content);
     return $content;
   }
   function adjust_references($papers,$extensions = [])
   {
+    $bibresources = [];
     foreach ($papers as $d => $f)
     {
-      $tex = file_get_and_backup("$d/$f");
       $files = rscandir($d,$extensions);
       foreach ($files as $file)
       {
@@ -218,6 +222,7 @@ END;
           $bib = preg_replace("/(^\s*@\s*[a-z]+\s*\{\s*)((?!$d)\S)/i",'${1}'.$d.':${2}',$bib);
           $bib = preg_replace("/(\n\s*@\s*[a-z]+\s*\{\s*)((?!$d)\S)/i",'${1}'.$d.':${2}',$bib);
           file_put_contents($file,$bib);
+          $bibresources[$d] = $file;
         }
         else
         {
@@ -250,7 +255,44 @@ END;
         }
       }
     }
-    return array();
+    return $bibresources;
+  }
+  function adjust_papers($papers,$extensions = [])
+  {
+    foreach ($papers as $d => $f)
+    {
+      $files = rscandir($d,$extensions);
+      foreach ($files as $file)
+      {
+        $tex = file_get_and_backup($file,".interm_bak");
+        // labels of lstlistings etc
+        $tex = preg_replace("/([\[,]\s*label\s*=\s*)((?!$d)[^\[,]+[\[,])/i",'${1}'.$d.':${2}',$tex);
+        // normal labels
+        $tex = preg_replace("/(\\\label\s*\{\s*)((?!$d)[^}]+\})/i",'${1}'.$d.':${2}',$tex);
+        // cref ref autoref
+        $refs = [];
+        preg_match_all("/\\\(cref|ref|autoref)\s*\{\s*[^}]+\}/i",$tex,$refs);
+        foreach ($refs[0] as $ref)
+        {
+          $oldref = $ref;
+          $ref = preg_replace("/([{,])\s*((?!$d)[^,}]+[},])/i",'${1}'.$d.':${2}',$ref);
+          $ref = preg_replace("/([{,])\s*((?!$d)[^,}]+[},])/i",'${1}'.$d.':${2}',$ref);
+          $tex = str_replace($oldref,$ref,$tex);
+        }
+        // cite citeA citeauthor etc
+        $cites = [];
+        preg_match_all("/\\\([a-z]*cite[a-z]*)\s*\{\s*[^}]+\}/i",$tex,$cites);
+        foreach ($cites[0] as $cite)
+        {
+          $oldcite = $cite;
+          $cite = preg_replace("/([{,])\s*((?!$d)[^,}]+[},])/i",'${1}'.$d.':${2}',$cite);
+          $cite = preg_replace("/([{,])\s*((?!$d)[^,}]+[},])/i",'${1}'.$d.':${2}',$cite);
+          $tex = str_replace($oldcite,$cite,$tex);
+        }
+        file_put_contents($file,$tex);
+      }
+    }
+    return $bibresources;
   }
   function check_options($argv)
   {
@@ -326,6 +368,8 @@ END;
     echo "Skipping...\n";
   else
     compile_check($papers);
+  echo "\n=== Step 5/$steps: Adjusting Papers (checking only *.tex files) ===\n\n";
+  adjust_papers($papers,[".tex"]);
   echo "\n=== Step 6/$steps: Generate main.tex ===\n\n";
   $thesis_type = user_prompt("Enter Thesis Type ","PhD Thesis");
   $thesis_title = user_prompt("Enter Thesis Title ","Security of TODO");
@@ -333,12 +377,28 @@ END;
   $thesis_author = user_prompt("Enter Your Name ","Harry Potter");
   $thesis_date = user_prompt("Enter Prospective Defense Month", "July 1998");
   $thesis_institute = user_prompt("Enter Your Institute","Institute for Applied Information Processing and Communications");
+  $thesis_assessors = user_prompt("Enter Names of your Assessors (comma-separated)","Severus Snape, Minerva McGonagall");
+  $num_publications_in_thesis = count($papers);
+  $num_publications = user_prompt("How many publications did you co-author during your PhD? (6 is the absolute minimum for a cumulative thesis)","6");
   ob_start();
   require "main.tex.php";
   $maintex_content = ob_get_contents();
   ob_end_clean();
-  if (!file_exists("main.bib"))
-    file_put_contents("main.bib","");
   //if (!file_exists("main.tex") || user_consent("main.tex already exists. overwrite?")) // TODO: enable this check
   file_put_contents("main.tex",$maintex_content);
+
+  if (!file_exists("abstract.tex"))
+    file_put_contents("abstract.tex","");
+  if (!file_exists("intro.tex"))
+    file_put_contents("intro.tex","");
+
+  if (!file_exists("main.bib"))
+    file_put_contents("main.bib","");
+  if (isset($options["--cv"]))
+  {
+    if (!file_exists("cv.bib"))
+      file_put_contents("cv.bib","");
+    if (!file_exists("cv.tex"))
+      file_put_contents("cv.tex","This is my CV! Thanks for checking it out!");
+  }
 ?>

+ 50 - 150
main.tex.php

@@ -1,5 +1,4 @@
 \documentclass[paper=a4,fontsize=11pt,twoside,titlepage,parskip=half-,openright]{scrbook}
-\usepackage[utf8]{inputenc}
 \usepackage[paperwidth=15.5cm,
             paperheight=23.5cm,
             lmargin = 2.1cm,
@@ -8,14 +7,10 @@
             headsep = 0.6cm,
             textheight = 19.3cm,
             footskip = 1.0cm]{geometry}
-
-\usepackage{moresize}
 \usepackage{tugraz_defaults}
+\usepackage{moresize}
 \usepackage{pdfpages}
-\usepackage{csquotes}
 \usepackage{enumitem}
-%\usepackage[hidelinks]{hyperref}
-\usepackage{subcaption}
 \usepackage{mdframed}
 
 \usepackage[breakable, theorems, skins]{tcolorbox}
@@ -31,24 +26,29 @@
             backref=true, %
            ]{biblatex}
 \addbibresource{main.bib}
-<?php echo $bibresources; ?>
-\usepackage[acronym]{glossaries}
+<?php 
+foreach ($bibresources as $br => $bib)
+{
+  echo '\addbibresource{'.$bib.'}
+';
+}
+if (isset($options["--cv"]))
+  echo '\addbibresource{cv.bib}
+';
+?>
 \DeclareFieldFormat*{title}{#1} 
 \DeclareFieldFormat*{booktitle}{#1}  
 \DeclareFieldFormat*{journaltitle}{#1}  
 \newcommand{\itemcite}[1]{\begin{itemize}\item \fullcite{#1}\end{itemize}}
 
 
-\usepackage{csquotes}
 \usepackage{graphicx}
 \usepackage[openbib,NoDate]{currvita}
-\usepackage{paralist}
 \preto\fullcite{\AtNextCite{\defcounter{maxnames}{99}}}
 
 
 \usepackage{scrhack}
 \usepackage{quotchap} %
-\usepackage{arydshln}
 
 \DefineBibliographyStrings{english}{%
   backrefpage = {p.},%
@@ -81,8 +81,6 @@
 \if@twocolumn\hbox{}\newpage\fi\fi\fi}
 \makeatother
 
-\usepackage{soul}
-
 \usepackage{titling}
 \usepackage[english]{babel}
 \addto{\captionsenglish}{\renewcommand*{\appendixname}{Appendix}}
@@ -161,6 +159,7 @@
   \vspace{2cm}
 
   {\sffamily\Large\noindent <?php echo $thesis_type ?>}\\[0.2cm]
+  {\sffamily\noindent Assessors: <?php echo $thesis_assessors ?>}\\[0.2cm]
   {\sffamily\noindent <?php echo $thesis_date ?>}\\[0.2cm]
   \vspace{6cm}
 \end{titlepage}%
@@ -201,8 +200,7 @@
 
 \addtocontents{toc}{\vspace*{\baselineskip}}
 
-\chapter*{Information on Part II}
-Note that Part II is not included in this PDF. Please download the full version for Part II.
+\cleardoublepage
 
 \part{Publications}
 \addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
@@ -214,15 +212,13 @@ Note that Part II is not included in this PDF. Please download the full version
 \label{sec:publicationlist}
 \addcontentsline{toc}{chapter}{List of Publications}
 
-During my habilitation, I contributed to 33 publications (48 in since I started my PhD), 11 of which are included in this habilitation, as shown below.
-Out of the 33 publications, 16 were top-tier publications (8 included in this habilitation).
-Internationally, only a single person had a higher number of publications at the four top-tier system security conferences in the same time frame.
+During my thesis, I contributed to <?php echo $num_publications ?> publications in conference proceedings, <?php echo $num_publications_in_thesis ?> of which are included in this thesis as shown below.
 
 \newrefcontext[sorting=ydnt]
-\nocite{CV:How2020Fall,CV:Donky2020August,CV:Meltdown2020June,CV:Nethammer2020June,CV:Take2020June,CV:KASLR2020June,CV:LVI2020May,CV:Plundervolt2020May,CV:RAMBleed2020May,CV:ConTExT2020February,CV:Malware2020January,CV:ZombieLoad2019November,CV:Page2019November,CV:Fallout2019November,CV:SGXJail2019September,CV:NetSpectre2019September,CV:Wait2019August,CV:ScatterCache2019August,CV:A2019August,CV:Practical2019June,CV:Store-to-Leak2019May,CV:Spectre2019May,CV:JavaScript2019February,CV:Kernel2018December,CV:Software-based2018November,CV:Software-basierte2018September,CV:Meltdown2018August,CV:Automated2018June,CV:Use-After-FreeMail2018June,CV:ProcHarvester2018June,CV:Another2018May,CV:JavaScript2018February,CV:KeyDrown2018February,CV:Practical2017September,CV:Strong2017August,CV:KASLR2017July,CV:Malware2017July,CV:Software-based2017June,CV:Fantastic2017April,CV:Hello2017February,CV:Prefetch2016October,CV:Drammer2016October,CV:DRAMA2016August,CV:ARMageddon2016August,CV:Rowhammer.js2016July,CV:Flush+Flush2016July,CV:Practical2015September,CV:Cache2015August}
+\nocite{CV:*}
 
 \begin{sloppypar}
-\printbibliography[title={Publications in this Habilitation}, type=inproceedings, heading=subbibliography, keyword={mine}]
+\printbibliography[title={Publications in this Thesis}, type=inproceedings, heading=subbibliography, keyword={mine}]
 
 \printbibliography[title={Other Contributions}, type=inproceedings, heading=subbibliography, keyword={mine_other}]
 \end{sloppypar}
@@ -230,104 +226,28 @@ Internationally, only a single person had a higher number of publications at the
 \end{refsection}
 \egroup
 
-\bgroup
-\begin{refsection}
-
-\input{spectre}
-
-\end{refsection}
-\egroup
-
-\newpage
-\bgroup
-\begin{refsection}
-
-\input{netspectre}
-
-\end{refsection}
-\egroup
-
-\newpage
-\bgroup
-\begin{refsection}
-
-\input{meltdown}
-
-\end{refsection}
-\egroup
-
-\newpage
-\bgroup
-\begin{refsection}
-
-\input{kaiser1}
-
-\end{refsection}
-\egroup
-
-\newpage
-\bgroup
-\begin{refsection}
-
-\input{kaiser2}
-
-\end{refsection}
-\egroup
-
-\newpage
-\bgroup
-\begin{refsection}
-
-\input{prefetch}
-
-\end{refsection}
-\egroup
-
-\newpage
-\bgroup
-\begin{refsection}
-
-\input{systematic}
-
-\end{refsection}
-\egroup
-
-\newpage
-\bgroup
-\begin{refsection}
-
-\input{zombieload}
-
-\end{refsection}
-\egroup
-
-\newpage
-\bgroup
-\begin{refsection}
-
-\input{fallout}
-
-\end{refsection}
-\egroup
-
-\newpage
-\bgroup
-\begin{refsection}
-
-\input{lvi}
-
-\end{refsection}
-\egroup
-
-\newpage
-\bgroup
-\begin{refsection}
-
-\input{context}
-
-\end{refsection}
-\egroup
-
+<?php
+foreach ($papers as $p => $f)
+{
+echo '
+
+  \bgroup
+  \begin{refsection}
+  
+  \input{'.$p.'/'.$f.'}
+  
+  \end{refsection}
+  \egroup
+  
+  \newpage
+
+';
+}
+?>
+<?php
+if (!isset($options['--cv']))
+{
+echo <<<'END'
 \cleardoublepage
 
 \appendix 
@@ -361,40 +281,20 @@ Internationally, only a single person had a higher number of publications at the
 
 \cleardoublepage
 
-\chapter*{Acknowledgements}
-I have worked with so many wonderful people over the past years, had so many inspiring discussions, and got to know so many extraordinarily clever and kind people that it feels very difficult to write these acknowledgements.
-My feeling is that I surely forgot to mention someone and I will only realize it the week after everything is published and went into print.
-I owe thanks to more people than I can list here by name.
-Instead, if you are reading this: Thank you for the discussions we had, for the beers we shared, the time we spent, and for the papers we wrote together.
-
-First and foremost, I want to thank the head of the Institute of Applied Information Processing and Communications, Stefan Mangard, for creating an excellent working environment, supporting my research group, and inspiring me to be ambitious and strive for excellence in research.
-Thank you for your guidance on how to lead research and research groups.
-
-This habilitation would not have been possible in this time frame without my extraordinary research group: Michael Schwarz (now at CISPA), Moritz Lipp, Claudio Canella, Martin Schwarzl, Lukas Giner, Catherine Easdon, and Andreas Kogler.
-I tried to get the best people into my research group, the most clever, most productive, most empathetic, most kind.
-I must have succeeded.
-It is a pleasure to spend time with you every day.
-
-I want to thank all the master and bachelor students that have worked in our group over the past years.
-One of the most important reasons for staying in Graz was the excellent environment here, and that includes you, students.
-It is amazing and impressive to see you contributing to our research projects.
-
-I also owe thanks to my teaching assistants and co-lecturers.
-Attracting the best students to our group requires to have excellent positive visibility in lectures.
-Your incredible support for the students, your motivation, and the ambition we share, to make our classes the best experience possible, was the basis for winning the prize for excellence in teaching.
-
-I want to thank my co-authors from all the collaborations, colleagues from our institute, and from other universities and industry, in particular Jo Van Bulck, Daniel Moghimi, Frank Piessens, Berk Sunar, and Anders Fogh.
-I want to thank Thorsten Holz, Thomas Eisenbarth, and Frank Piessens for giving me the opportunity to visit their institutions during my habilitation.
-
-I want to thank the industry partners that funded my research group in the last years and made this research possible: Intel, Arm, Amazon, Cloudflare, and Red Hat.
-It was great to have the opportunity to work on problems we are all interested in and to engage in interesting and enlightening discussions with many clever people.
-
-I want to thank my fiancée Maria Eichlseder for her love and patience with me.
-Thank you for supporting me and (still) tolerating my healthy work-job balance.
+END;
+}
+?>
+<?php
+if (!isset($options['--no-statutory-declaration']))
+{
+echo <<<'END'
+\chapter*{Statutory Declaration}
 
-Finally, I would like to thank my friends, my fiancée's and my family, and my cats for both supporting my work and distracting me from it in the past years.
+I declare that I have authored this thesis independently, that I have not used other than the declared sources / resources, and that I have explicitly marked all material which has been quoted either literally or by content from the used sources.
 
-%\includepdf[pages=-]{back.pdf}
+END;
+}
+?>
 
 \end{document}
 

+ 0 - 5
tugraz_defaults.sty

@@ -453,11 +453,6 @@
 \newcommand{\muop}{$\mu$OP\xspace}
 \newcommand{\muops}{$\mu$OPs\xspace}
 
-\RequirePackage{titlesec}
-\titlespacing*{\section}{0pt}{1.6ex}{1.2ex}
-\titlespacing*{\subsection}{0pt}{1.3ex}{1ex}
-%\titlespacing*{\subsubsection}{0pt}{0.4ex}{0.05ex}
-
 \lstdefinestyle{python}{
   language=python,
   % syntax higlights