Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
80 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
struct Manager::List | ||
@path : Path | ||
getter path : Path | ||
|
||
def initialize(prefix) | ||
@path = Path.new prefix | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
struct Manager::Package::Clean | ||
getter prefix : String, | ||
pkgdir : String, | ||
packages = Set(String).new | ||
|
||
def initialize(@prefix) | ||
list = List.new @prefix | ||
@pkgdir = list.path.pkg | ||
Log.info "retrieving available packages", @pkgdir | ||
list.pkg { |pkg| @packages << pkg } | ||
Log.info "excluding used packages by applications", list.path.app | ||
list.app do |app| | ||
app_path = list.path.app + '/' + app | ||
@packages.delete File.basename(File.real_path(app_path + "/app").rstrip("app")) | ||
lib_path = app_path + "/lib/" | ||
Dir.each_child lib_path do |lib_package| | ||
@packages.delete File.basename(File.real_path lib_path + lib_package) | ||
end | ||
end | ||
end | ||
|
||
def simulate | ||
String.build do |str| | ||
str << "\npkgdir: " << @pkgdir | ||
str << "\nunused packages: \n" | ||
@packages.each do |pkg| | ||
str << pkg << '\n' | ||
end | ||
end | ||
end | ||
|
||
def run | ||
Log.info "deleting packages", @pkgdir | ||
@packages.each do |pkg| | ||
path = @pkgdir + '/' + pkg | ||
FileUtils.rm_rf path | ||
Log.info "package deleted", pkg | ||
end | ||
Log.info "packages cleaned", @pkgdir | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
require "./service/**" | ||
require "./service/*" | ||
|
||
LOG_OUTPUT_PATH = "log/output.log" | ||
LOG_ERROR_PATH = "log/error.log" | ||
|
||
module Service | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
require "./system" | ||
require "./openrc/*" | ||
|
||
module Service::OpenRC | ||
extend self | ||
include Cli | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
require "./system" | ||
require "./systemd/*" | ||
|
||
module Service::Systemd | ||
extend self | ||
include Cli | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters