Skip to content

Commit

Permalink
Update latte
Browse files Browse the repository at this point in the history
  • Loading branch information
Pandademic committed Sep 19, 2021
1 parent 056abf3 commit ea456ec
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions dist/latte
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

# frozen_string_literal
require 'inifile'
require 'open-uri'
require 'facter'
#require 'facter'
# TODO: bring back helper
# module to download Packages
module Pkg
Expand All @@ -12,38 +13,35 @@ module Pkg
end

def self.getPkgfile
ensure
pfr = URI.open("https://raw.githubusercontent.com/Pandademic/Latte/master/packages/#{$query}.ini").read
packageFileURL = "https://raw.githubusercontent.com/Pandademic/Latte/master/packages/#{$query}.ini"
pfr = URI.open("https://raw.githubusercontent.com/Pandademic/Latte/master/pkgs/#{$query}.ini").read
packageFileURL = "https://raw.githubusercontent.com/Pandademic/Latte/master/pkgs/#{$query}.ini"
puts "Package file:#{pfr}"
system("wget #{packageFileURL} --directory-prefix=/tmp/")
# implemnt no donwload of pkg file by using pfr
system("curl -O #{packageFileURL}")
puts 'package file download complete'
Pkg.downloadLatest
# TODO: implement begin.resuce,else,ensure,end
# TODO: changes global vars to :: scopes
end

def self.downloadLatest
file = IniFile.load("/tmp/#{$query}.ini")
file = IniFile.load("#{$query}.ini")
puts 'loaded file'
pkgdata = file['package']
zipsupport = pkgdata['Zip']
zipsupport = pkgdata['Media']
if zipsupport == true
# TODO: #13 add zipsupport to docs (package-example.ini)
@RURL = pkgdata['Release']
puts 'Running zip downloadd with wget'
system("wget #{@RURL}")
@RURL = pkgdata['MediaUrl']
system "curl -O #{@RURL}"
else
$isc = pkgdata['Isc'] # install command
puts 'running Install command as specified in Pkgfile'
puts $isc.to_s
system(@ISC.to_s)
@Isc = pkgdata['InstallCommand'] # install command
system @Isc.to_s
end
end
end
# FileUtils.touch('info.log')
@param1 = ARGV[1]
$os = Facter['osfamily'].value
abort('ERROR:No task specified') while ARGV.empty?
Helper.man if ARGV[0] == 'man'
Pkg.findPkg(@param1.to_s) if ARGV[0] == 'install'
#$os = Facter['osfamily'].value
abort('That is not a command') while ARGV.empty?
if ARGV[0] == 'add'
Pkg.findPkg @param1.to_s
elsif Pkg.findPkg @param1.to_s
else
puts 'Unknown Command'
end

0 comments on commit ea456ec

Please sign in to comment.