Browse Source

Fixed bugs in build + created backup of insteonplm

Joachim M. Giæver 5 years ago
parent
commit
aa38fb43d5
2 changed files with 17 additions and 15 deletions
  1. 0 1
      bin/lxcbuild
  2. 17 14
      snap/snapcraft.yaml

+ 0 - 1
bin/lxcbuild

@@ -79,7 +79,6 @@ function check_installed {
 
 function init_container {
 	RETRY=$( [ $# -eq 2 ] && echo 1 || echo "0" )
-	echo "${RETRY}"
 	if [ $(lxc list "${CONTAINER_NAME}" | grep "${CONTAINER_NAME}" | wc -l) -eq 0 ]; then 
 		lxc launch "${CONTAINER_OS}:${CONTIANER_VERSION}" "${CONTAINER_NAME}"
 		RET=$?

+ 17 - 14
snap/snapcraft.yaml

@@ -47,22 +47,25 @@ parts:
         override-build: |
             # Remove LICENCE-part of insteonplm, which causes pip to fail
             echo "Fixing broken insteonplm install"
-            PPACKAGES="$(pwd)/../python-packages/"
-            INSTEONPLM="${PPACKAGES}/$(basename "$(ls ${PPACKAGES} | grep insteonplm*.tar.gz --max-count=1)")"
-            echo " * Extracting ${INSTEONPLM}"
-            SCFG=$(tar -xvzf "${INSTEONPLM}" | grep setup.cfg --max-count=1)
-            BFILE="${INSTEONPLM}.bup" 
-            if [ ! -f "${BFILE}" ]; then
-                echo "Creating backup * ${BFILE}"
-                mv -f "${INSTEONPLM}" "${BFILE}"
+            PKGS="$(pwd)/../python-packages"
+            IPKG="$(ls ${PKGS}/insteonplm*.tar.gz | tail -n 1)"
+            BIPKG="${HOME}/$(basename ${IPKG}.bup)"
+            if [ ! -f "${BIPKG}" ]; then
+                echo -e " * Creating backup to\n\tTO: ${BIPKG}\n\t<= ${IPKG}"
+                cp "${IPKG}" "${BIPKG}"
+            else
+                echo -e " * Restoring backup\n\tFROM: ${BIPKG}\n\t=> ${IPKG}"
+                cp "${BIPKG}" "${IPKG}"
             fi
-            echo " * Editing ${SCFG}"
+            echo " * Insteonplm file: ${IPKG}"
+            SCFG=$(tar -xvzf "${IPKG}" | grep setup.cfg --max-count=1)
+            rm "${IPKG}"
+            echo " * Editing setup.cfg file: ${SCFG}"
             sed -i '/^license_file/d' "${SCFG}"
-            echo " * Compressing ${INSTEONPLM}"
-            tar -zcf "${INSTEONPLM}" $(dirname "${SCFG}")
-            echo " * Updated ${INSTEONPLM}"
-            rm -rf $(dirname "${SCFG}")
-            echo " * Deleted $(dirname ${SCFG})"
+            echo " * Compressing $(dirname ${SCFG}) to: ${IPKG}"
+            tar -zcf "${IPKG}" "$(dirname ${SCFG})"
+            echo " * Deleting tmp-folder $(dirname ${SCFG})"
+            rm -rf "$(dirname ${SCFG})"
             snapcraftctl build
         requirements: 
             - requirements_all.txt