From 64051ede9b59acf6ca9d95cd7adbb90df63cfbf8 Mon Sep 17 00:00:00 2001 From: Yessiest Date: Sun, 11 Dec 2022 03:12:17 +0400 Subject: [PATCH] Added dependency installation for janitor --- Rakefile | 54 ++++++++++++++++++++++++++++++++--------- extra/install_luapam.sh | 13 +++++----- 2 files changed, 49 insertions(+), 18 deletions(-) diff --git a/Rakefile b/Rakefile index a6cce41..4bf9e60 100644 --- a/Rakefile +++ b/Rakefile @@ -1,21 +1,45 @@ task default: [:install] ConfigPath = (ENV["XDG_DATA_HOME"] or ENV["HOME"]+'/.config') -desc "Copy files to .config" -file "copy-config" => ["rc.lua"] do +desc "Install (copy) config files" +task "install-files" do + base = ["libs","modules","themes","widgets","rc.lua","desktop.conf"] sh "mkdir -p #{ConfigPath}/awesome" - ["libs","modules","themes","widgets","rc.lua","desktop.conf"].each { |x| - cp_r "./#{x}" "#{ConfigPath}/awesome" + base.each { |f| + cp_r "./#{f}", "#{ConfigPath}/awesome" } end -desc "Compile and install luapam" -file "build-luapam" => "#{ConfigPath}/libs/pam.so" do - sh "sh ./extra/install_luapam.sh" +desc "Install LuaPAM" +task "install-luapam" do + unless File.exist? "#{ConfigPath}/awesome/libs/pam.so" + sh "sh ./extra/install_luapam.sh" + cp "./pam.so","#{ConfigPath}/awesome/libs/" + cp_r "./pam","#{ConfigPath}/awesome/libs/" + rm "./pam.so" + rm_rf "./pam" + rm_rf "./lua-pam" + else + puts "LuaPAM already installed - skipping" + end end +desc "Force install config" +task "install-force" => ["install-files","install-luapam"] + desc "Install config" -task install: ["copy-config","build-luapam"] +task :install do + installed = true + base = ["libs","modules","themes","widgets","rc.lua","desktop.conf"] + (base+["libs/pam.so"]).each { |f| + installed &= File.exist? "#{ConfigPath}/awesome/#{f}" + } + if installed + puts "Baseline files already installed - skipping" + else + Rake::Task["install-force"].invoke + end +end desc "Build documentation" task :doc do @@ -27,14 +51,14 @@ task "install-extra" do if Process.euid != 0 raise Exception, "You need to be root to install extras" end - cp "./extra/udev/backlight.rules" "/etc/udev/rules.d" + cp "./extra/udev/backlight.rules", "/etc/udev/rules.d" mkdir "#{ConfigPath}/autostart" begin - cp "/usr/share/applications/picom.desktop" "#{ConfigPath}/autostart/" + cp "/usr/share/applications/picom.desktop", "#{ConfigPath}/autostart/" rescue puts "picom not installed - ignoring" else - cp "./extra/picom.conf" "#{ConfigPath}" + cp "./extra/picom.conf", "#{ConfigPath}" end puts "Done! Reload awesome to complete installation" end @@ -44,6 +68,14 @@ task :clean do rm_rf "#{ConfigPath}/awesome" end +desc "Install dependencies for code cleaner" +task "install-janitor-deps" do + if Process.euid != 0 + raise Exception, "You need to be root to install gems" + end + Gem.install "language_server-protocol" +end + desc "Wipe configuration and reinstall from scratch" task reinstall: [:clean,:install] diff --git a/extra/install_luapam.sh b/extra/install_luapam.sh index 855c398..1957784 100644 --- a/extra/install_luapam.sh +++ b/extra/install_luapam.sh @@ -16,12 +16,11 @@ if [ "$LUA_VERSION" == "" ]; then exit 1 fi echo "Target version: $LUA_VERSION" -git clone --recursive https://github.com/devurandom/lua-pam ~/.config/awesome/lua-pam -cd ~/.config/awesome/lua-pam +git clone --recursive https://github.com/devurandom/lua-pam lua-pam +cd lua-pam make LUA_VERSION="$LUA_VERSION" -mkdir -p ~/.config/awesome/libs/pam/ -cp LICENSE ~/.config/awesome/libs/pam/ -echo "https://github.com/devurandom/lua-pam" > ~/.config/awesome/libs/pam/README -cp pam.so ~/.config/awesome/libs/ -rm -rf ~/.config/awesome/lua-pam +mkdir -p ../pam/ +cp LICENSE ../pam/ +echo "https://github.com/devurandom/lua-pam" > ../pam/README +cp pam.so ../