<commit_before><!-- 
 Rhizi build targets
-->
<project name="rhizi-server" default="pkg-deb">

<macrodef name="rsync">
   <attribute name="src" />
   <attribute name="dst" />
   <attribute name="extraOpts" default="" />
   <sequential>
      <exec dir="${basedir}" executable="/usr/bin/rsync" >
         <arg line="-avz @{extraOpts}" />
         <arg value="@{src}" />
         <arg value="@{dst}" />

         <!-- note: RSYNC_CONNECT_PROG has not effect when dst is local dir path -->
         <env key="RSYNC_CONNECT_PROG"
              value="ssh root@%H nc 127.0.0.1 873" />
      </exec>
   </sequential>
</macrodef>

   <property name="pkg_name" value="rhizi-server" />
   <property name="pkg_version" value="0.1.0" />
   <property name="buildDir" value="build/${pkg_name}-${pkg_version}" />
   <property name="deployDirLocal"
             value="${rzRootDir}/rhizi-server/deploy-local" />

   <fail unless="rzRootDir"
         message="'rzRootDir' arg missing - must point to root rhizi code dir" />

   <tstamp>
      <format property="versionQualifier" pattern="yyyyMMddHHmm" />
   </tstamp>

   <target name="clean" description="remove all work folders">
      <delete dir="dist" />
      <delete dir="build" />
   </target>

   <target name="deploy-local.clean">
      <delete dir="deploy-local" followsymlinks="false">
         <include name="**/*" />
      </delete>
   </target>

   <target name="deploy-local"
           depends="deploy-local.clean"
           description="locally deploy webapp">

      <local name="src_client" />
      <local name="src_server" />
      <local name="dst" />

      <property name="src_client" value="${rzRootDir}/rhizi-client" />
      <property name="src_server" value="${rzRootDir}/rhizi-server" />
      <property name="dst" value="${deployDirLocal}" />

      <mkdir dir="${dst}/static" />

      <parallel>
         <!-- [!] trailing '/' critical -->
         <rsync src="${src_client}/src/" dst="${dst}/static" />
         <rsync src="${src_client}/res" dst="${dst}/static" />
         <rsync src="${src_client}/lib" dst="${dst}/static" />

         <exec executable="/bin/ln">
            <arg line="-rs -T ${src_server}/src-py ${dst}/bin" />
         </exec>

         <rsync src="${src_server}/res/etc" dst="${dst}" />
         <rsync src="${src_server}/res/templates/" dst="${dst}/templates" />
      </parallel>

   </target>

   <target name="deploy-remote" depends="deploy-local">

      <local name="src_server" />
      <local name="src_client" />
      <local name="dstServer" />
      <local name="module" />
      <property name="src_client" value="${rzRootDir}/rhizi-client" />
      <property name="src_server" value="${rzRootDir}/rhizi-server" />
      <property name="dstServer" value="rz_0.unige.ch" />
      <property name="module" value="rhizi.net" />

      <rsync src="${src_server}/deploy-local/"
             dst="rsync://${dstServer}/${module}/" />

      <parallel>
         <!-- apply production patches -->
         <rsync src="${src_server}/res/production-patch-set/rhizi-server.production.conf"
                dst="rsync://${dstServer}/${module}/etc/rhizi-server.conf" />
         <rsync src="${src_server}/res/production-patch-set/rz_config.js"
                dst="rsync://${dstServer}/${module}/static/" />

      </parallel>
   </target>

   <target name="deploy-remote.htpasswd.db" description="manual invocation">
      <rsync src="${src_server}/res/production-patch-set/htpasswd.db"
             dst="root@rz_<EMAIL>:/srv/www/rhizi/auth/" />
   </target>

   <target name="pkg-deb" depends="clean" description="package as .deb">
      <mkdir dir="dist" />
      <mkdir dir="${buildDir}" />

      <exec dir="${basedir}" executable="/usr/bin/git">
         <arg value="clone" />
         <arg line="--depth 1" />
         <arg value="file://${basedir}" />
         <arg value="${buildDir}" />
      </exec>

      <copy todir="${buildDir}/debian">
         <fileset dir="debian" />
      </copy>

      <exec dir="${buildDir}" executable="/usr/bin/debuild">
         <arg value="-b" />
         <arg value="-us" />
         <arg value="-uc" />
      </exec>
   </target>

   <target name="pkg-deb.list">
      <exec dir="${buildDir}" executable="/usr/bin/dpkg">
         <arg line="-c rhizi-server_0.1.0_amd64.deb" />
      </exec>
   </target>

</project><commit_msg>bin -> ../src-py symlink handling<commit_after><!-- 
 Rhizi build targets
-->
<project name="rhizi-server" default="pkg-deb">

<macrodef name="rsync">
   <attribute name="src" />
   <attribute name="dst" />
   <attribute name="extraOpts" default="" />
   <sequential>
      <exec dir="${basedir}" executable="/usr/bin/rsync" >
         <arg line="-avz @{extraOpts}" />
         <arg value="@{src}" />
         <arg value="@{dst}" />

         <!-- note: RSYNC_CONNECT_PROG has not effect when dst is local dir path -->
         <env key="RSYNC_CONNECT_PROG"
              value="ssh root@%H nc 127.0.0.1 873" />
      </exec>
   </sequential>
</macrodef>

   <property name="pkg_name" value="rhizi-server" />
   <property name="pkg_version" value="0.1.0" />
   <property name="buildDir" value="build/${pkg_name}-${pkg_version}" />
   <property name="deployDirLocal"
             value="${rzRootDir}/rhizi-server/deploy-local" />

   <fail unless="rzRootDir"
         message="'rzRootDir' arg missing - must point to root rhizi code dir" />

   <tstamp>
      <format property="versionQualifier" pattern="yyyyMMddHHmm" />
   </tstamp>

   <target name="clean" description="remove all work folders">
      <delete dir="dist" />
      <delete dir="build" />
   </target>

   <target name="deploy-local.clean">
      <!-- bin/ -> link: avoid specifying followsymlinks on the following delete task -->
      <symlink action="delete" link="deploy-local/bin" />
      <delete verbose="true" includeemptydirs="true">
         <fileset dir="${deployDirLocal}"
                  includes="**/*"
                  defaultexcludes="false" />
      </delete>
   </target>

   <target name="deploy-local"
           depends="deploy-local.clean"
           description="locally deploy webapp">

      <local name="src_client" />
      <local name="src_server" />
      <local name="dst" />

      <property name="src_client" value="${rzRootDir}/rhizi-client" />
      <property name="src_server" value="${rzRootDir}/rhizi-server" />
      <property name="dst" value="${deployDirLocal}" />

      <mkdir dir="${dst}/static" />

      <parallel>
         <!-- [!] trailing '/' critical -->
         <rsync src="${src_client}/src/" dst="${dst}/static" />
         <rsync src="${src_client}/res" dst="${dst}/static" />
         <rsync src="${src_client}/lib" dst="${dst}/static" />

         <symlink action="single"
                  overwrite="true"
                  link="${dst}/bin"
                  resource="${src_server}/src-py" />

         <rsync src="${src_server}/res/etc" dst="${dst}" />
         <rsync src="${src_server}/res/templates/" dst="${dst}/templates" />
      </parallel>

   </target>

   <target name="deploy-remote" depends="deploy-local">

      <local name="src_server" />
      <local name="src_client" />
      <local name="dstServer" />
      <local name="module" />
      <property name="src_client" value="${rzRootDir}/rhizi-client" />
      <property name="src_server" value="${rzRootDir}/rhizi-server" />
      <property name="dstServer" value="rz_0.unige.ch" />
      <property name="module" value="rhizi.net" />

      <!-- -l: traverse bin/ -> ../src-py link -->
      <rsync src="${deployDirLocal}/"
             extraopts="-lL"
             dst="rsync://${dstServer}/${module}/" />

      <parallel>
         <!-- apply production patches -->
         <rsync src="${src_server}/res/production-patch-set/rhizi-server.production.conf"
                dst="rsync://${dstServer}/${module}/etc/rhizi-server.conf" />
         <rsync src="${src_server}/res/production-patch-set/rz_config.js"
                dst="rsync://${dstServer}/${module}/static/" />

      </parallel>
   </target>

   <target name="deploy-remote.htpasswd.db" description="manual invocation">
      <rsync src="${src_server}/res/production-patch-set/htpasswd.db"
             dst="root@rz_0.unige.ch:/srv/www/rhizi/auth/" />
   </target>

   <target name="pkg-deb" depends="clean" description="package as .deb">
      <mkdir dir="dist" />
      <mkdir dir="${buildDir}" />

      <exec dir="${basedir}" executable="/usr/bin/git">
         <arg value="clone" />
         <arg line="--depth 1" />
         <arg value="file://${basedir}" />
         <arg value="${buildDir}" />
      </exec>

      <copy todir="${buildDir}/debian">
         <fileset dir="debian" />
      </copy>

      <exec dir="${buildDir}" executable="/usr/bin/debuild">
         <arg value="-b" />
         <arg value="-us" />
         <arg value="-uc" />
      </exec>
   </target>

   <target name="pkg-deb.list">
      <exec dir="${buildDir}" executable="/usr/bin/dpkg">
         <arg line="-c rhizi-server_0.1.0_amd64.deb" />
      </exec>
   </target>

</project>
{'fraction_non_alphanumeric': 0.1999119815161184, 'fraction_numerical': 0.004290901089228738, 'mean_word_length': 2.496153846153846, 'pattern_counts': {'":': 0, '<': 197, '<?xml version=': 0, '>': 200, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '438005', 'n_tokens_mistral': 2946, 'n_tokens_neox': 2812, 'n_words': 508}