]> git.rmz.io Git - dotfiles.git/blobdiff - bin/chakra/check-texlive
merge bin from shada
[dotfiles.git] / bin / chakra / check-texlive
diff --git a/bin/chakra/check-texlive b/bin/chakra/check-texlive
new file mode 100644 (file)
index 0000000..a9da25a
--- /dev/null
@@ -0,0 +1,106 @@
+#!/bin/bash
+
+remote_directory="ftp://ftp.archlinux.org/other/texlive/"
+local_directory=${PWD}
+page="/tmp/texlive-update"
+pkgs="bibtexextra bin core fontsextra htmlxml latexextra"
+
+wget -O ${page} ${remote_directory} &>/dev/null
+
+page_data=$(cat ${page})
+
+
+for pkg in ${pkgs} ; do
+  echo " :: scanning ${pkg}.."
+
+  unset found_pkg
+
+  for x in {1..250} ; do
+    if [ "${found_pkg}" == "true" ] ; then
+      break
+    fi
+
+    pkg_match_line=$(echo ${page_data} | cut -d\" -f${x})
+    pkg_match_file=$(echo ${pkg_match_line} | grep texlive-${pkg})
+    if [ -n "${pkg_match_file}" ] ; then
+      if [ "${pkg}" == "bin" ] ; then
+        #-source
+          local_revision=$(cat ${local_directory}/texlive-${pkg}/PKGBUILD | grep texlive-${pkg}-source | cut -d- -f4 | cut -d. -f1)
+          if [ -n "$(echo ${pkg_match_file} | grep href | grep source)" ] ; then
+            remote_revision=$(echo ${pkg_match_file} | cut -d- -f4 | cut -d. -f1)
+            ver=$(vercmp ${local_revision} ${remote_revision})
+            if [ "${ver}" == "-1" ] ; then
+              echo " :: !! new texlive-bin-source tarball found"
+              echo "   -- local: ${local_revision}"
+              echo "   -- remote: ${remote_revision}"
+              sed -i -e "s/${local_revision}/${remote_revision}/g" ${local_directory}/texlive-${pkg}/PKGBUILD
+            fi
+          fi
+        #-texmf
+          local_revision=$(cat ${local_directory}/texlive-${pkg}/PKGBUILD | grep texlive-${pkg}-texmf | cut -d- -f4 | cut -d. -f1)
+          if [ -n "$(echo ${pkg_match_file} | grep href | grep texmf)" ] ; then   
+            remote_revision=$(echo ${pkg_match_file} | cut -d- -f4 | cut -d. -f1)
+            ver=$(vercmp ${local_revision} ${remote_revision})
+            if [ "${ver}" == "-1" ] ; then
+              echo " :: !! new texlive-bin-texmf tarball found"
+              echo "   -- local: ${local_revision}"
+              echo "   -- remote: ${remote_revision}"
+              sed -i -e "s/${local_revision}/${remote_revision}/g" ${local_directory}/texlive-${pkg}/PKGBUILD
+            fi
+          fi
+        #luatext
+          if [ "${found_luatext}" == "true" ] ; then
+            continue
+          fi
+
+          local_revision=$(cat ${local_directory}/texlive-${pkg}/PKGBUILD | grep "luatex-svn" | cut -d- -f2 | cut -d. -f1 | cut -dn -f2)
+          remote_revision=$(echo ${page_data} | sed -e 's/\n//g' -e 's/xz/xz\n/g' -e 's/zip/zip\n/g' -e 's/a>/a>\n/g' -e 's/ref=/ref=\n/g' | grep luatex | cut -d. -f1 | cut -dn -f2 | sed -e 's/ /\n/g' | uniq | grep -v ftp)
+          for match in ${remote_revision} ; do
+            ver=$(vercmp ${local_revision} ${match})
+            if [ "${ver}" == "-1" ] ; then
+              echo " :: !! new luatext tarball found"
+              echo "   -- local: ${local_revision}"
+              echo "   -- remote: ${match}"
+              sed -i -e "s/${local_revision}/${match}/g" ${local_directory}/texlive-${pkg}/PKGBUILD
+              found_luatext="true"
+            fi
+          done
+        fi
+    elif [ "${pkg}" == "bibtexextra" ] ; then
+      if [ "${found_match}" == "true" ] ; then
+        continue
+      fi
+
+      local_revision=$(cat ${local_directory}/texlive-${pkg}/PKGBUILD | grep pkgver= | cut -d= -f2 | cut -d. -f2)
+      remote_revision=$(echo ${page_data} | sed -e 's/\n//g' -e 's/xz/xz\n/g' -e 's/zip/zip\n/g' -e 's/a>/a>\n/g' -e 's/ref=/ref=\n/g' | grep ${pkg} | cut -d. -f2 | cut -d- -f1 | uniq | grep -v ftp)
+      for match in ${remote_revision} ; do
+        ver=$(vercmp ${local_revision} ${match})
+        if [ "${ver}" == "-1" ] ; then
+          echo " :: !! new tarball found"
+          echo "   -- local: ${local_revision}"
+          echo "   -- remote: ${match}"
+          sed -i -e "s/${local_revision}/${match}/g" ${local_directory}/texlive-${pkg}/PKGBUILD
+          found_match="true"
+        fi
+      done
+    else
+      if [ "${found_pkg}" == "true" ] ; then
+        break
+      fi
+
+      local_revision=$(cat ${local_directory}/texlive-${pkg}/PKGBUILD | grep pkgver= | cut -d= -f2 | cut -d. -f2)
+      remote_revision=$(echo ${page_data} | sed -e 's/\n//g' -e 's/xz/xz\n/g' -e 's/zip/zip\n/g' -e 's/a>/a>\n/g' -e 's/ref=/ref=\n/g' | grep ${pkg} | cut -d. -f2 | cut -d- -f1 | uniq | grep -v ftp)
+      for match in ${remote_revision} ; do
+        ver=$(vercmp ${local_revision} ${match})
+        if [ "${ver}" == "-1" ] ; then
+          echo " :: !! new tarball found"
+          echo "   -- local: ${local_revision}"
+          echo "   -- remote: ${match}"
+          sed -i -e "s/${local_revision}/${match}/g" ${local_directory}/texlive-${pkg}/PKGBUILD
+          found_pkg="true"
+        fi
+      done
+    fi
+  done
+done
+