Obsolete
/
packaging
Archived
3
0
Fork 0

Configuration file added.

master
Luka Vandervelden 2019-08-29 00:20:15 +02:00
parent 06cea3694e
commit 656a640738
5 changed files with 38 additions and 1 deletions

View File

@ -8,6 +8,7 @@ SHAREDIR := $(PREFIX)/share
INCLUDEDIR := $(PREFIX)/include
MANDIR := $(SHAREDIR)/man
LIBEXECDIR := $(PREFIX)/libexec
SYSCONFDIR := $(PREFIX)/etc
VERSION := 0.3.0
CC := cc
@ -54,7 +55,7 @@ assemble-apk.sh.uninstall:
src/config.cr: src/config.cr.in src
@echo ' SED > src/config.cr'
$(Q)sed -e 's&@PREFIX@&$(PREFIX)&;s&@BINDIR@&$(BINDIR)&;s&@LIBDIR@&$(LIBDIR)&;s&@SHAREDIR@&$(SHAREDIR)&;s&@INCLUDEDIR@&$(INCLUDEDIR)&;s&@MANDIR@&$(MANDIR)&;s&@LIBEXECDIR@&$(LIBEXECDIR)&;s&@VERSION@&$(VERSION)&;' src/config.cr.in > 'src/config.cr'
$(Q)sed -e 's&@PREFIX@&$(PREFIX)&;s&@BINDIR@&$(BINDIR)&;s&@LIBDIR@&$(LIBDIR)&;s&@SHAREDIR@&$(SHAREDIR)&;s&@INCLUDEDIR@&$(INCLUDEDIR)&;s&@MANDIR@&$(MANDIR)&;s&@LIBEXECDIR@&$(LIBEXECDIR)&;s&@SYSCONFDIR@&$(SYSCONFDIR)&;s&@VERSION@&$(VERSION)&;' src/config.cr.in > 'src/config.cr'
$(Q)chmod +x 'src/config.cr'
@ -183,6 +184,7 @@ help:
@echo ' - INCLUDEDIR  ${INCLUDEDIR}'
@echo ' - MANDIR  ${MANDIR}'
@echo ' - LIBEXECDIR  ${LIBEXECDIR}'
@echo ' - SYSCONFDIR  ${SYSCONFDIR}'
@echo ' - VERSION  ${VERSION}'
@echo ''
@echo 'Project targets: '

View File

@ -4,6 +4,7 @@ version=0.3.0
variables+=(
LIBEXECDIR '$(PREFIX)/libexec'
SYSCONFDIR '$(PREFIX)/etc'
VERSION "$version"
)

View File

@ -1,6 +1,7 @@
# These values are changed by `make` at build-time.
OWN_LIBEXEC_DIR = "@LIBEXECDIR@/package"
SYSCONF_DIR = "@SYSCONFDIR@"
module Package
Version = "@VERSION@"

View File

@ -1,3 +1,5 @@
require "specfileparser"
require "./exception.cr"
require "./config.cr"
@ -224,5 +226,21 @@ class Package::Context
read_recipe recipe_file_name if repo
end
def read_configuration(filename : String)
specs = SpecFileParser.parse(filename).not_nil!
specs.assignments.each do |key, value|
puts key, value
case key
when "packages-directory"
@packages_directory = value.as_s
when "sources-directory"
@sources_directory = value.as_s
when "prefixes"
@prefixes = value.as_a_or_s
end
end
end
end

View File

@ -11,6 +11,9 @@ context = Context.new()
context.packaging_backend = "apk"
context.repositories << "."
configuration_file = "#{SYSCONF_DIR}/package.cfg"
configuration_file_requested = false
requested_recipes = [] of String
download_only = false
do_not_clean = false
@ -29,6 +32,11 @@ OptionParser.parse! do |parser|
context.repositories << dir
}
parser.on("-c FILE", "--conf FILE", "Use a configuration file other than the default one.") { |file|
configuration_file = file
configuration_file_requested = true
}
parser.on("-D", "--download-only", "Only download sources, do not build.") {
download_only = true
}
@ -58,6 +66,13 @@ OptionParser.parse! do |parser|
end
end
if File.exists? configuration_file
context.read_configuration configuration_file
elsif configuration_file_requested
STDERR.puts "ERROR: configuration file '#{configuration_file}' does not exist"
exit 1
end
found_recipes = requested_recipes.map do |name|
puts context.find_recipe(name)
context.find_recipe(name) || name