Obsolete
/
packaging
Archived
3
0
Fork 0

`package` can now be installed.

master
Luka Vandervelden 2019-08-03 13:12:23 +02:00
parent 99d1005fbb
commit f1cf318708
4 changed files with 233 additions and 1 deletions

191
Makefile Normal file
View File

@ -0,0 +1,191 @@
PACKAGE = 'package'
VERSION = '0.1.0'
PREFIX := /usr/local
BINDIR := $(PREFIX)/bin
LIBDIR := $(PREFIX)/lib
SHAREDIR := $(PREFIX)/share
INCLUDEDIR := $(PREFIX)/include
MANDIR := $(SHAREDIR)/man
LIBEXECDIR := $(PREFIX)/libexec
CC := cc
AR := ar
RANLIB := ranlib
CFLAGS :=
LDFLAGS :=
Q := @
all: package assemble-apk.sh src/config.cr
@:
package: src/main.cr src/config.cr src/context.cr src/instructions.cr src/main.cr src/package.cr src/recipe.cr src/sources.cr src/config.cr
@echo ' CR > package'
$(Q)crystal src/main.cr -o 'package'
package.install: package
@echo ' IN > $(BINDIR)/package'
$(Q)mkdir -p '$(DESTDIR)$(BINDIR)'
$(Q)install -m0755 package $(DESTDIR)$(BINDIR)/package
package.clean:
@echo ' RM > package'
$(Q)rm -f package
package.uninstall:
@echo ' RM > $(BINDIR)/package'
$(Q)rm -f '$(DESTDIR)$(BINDIR)/package'
assemble-apk.sh:
assemble-apk.sh.install: assemble-apk.sh
@echo ' IN > $(LIBEXECDIR)/package/assemble-apk.sh'
$(Q)mkdir -p '$(DESTDIR)$(LIBEXECDIR)/package'
$(Q)install -m0755 assemble-apk.sh $(DESTDIR)$(LIBEXECDIR)/package/assemble-apk.sh
assemble-apk.sh.clean:
assemble-apk.sh.uninstall:
@echo ' RM > $(LIBEXECDIR)/package/assemble-apk.sh'
$(Q)rm -f '$(DESTDIR)$(LIBEXECDIR)/package/assemble-apk.sh'
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)&;' src/config.cr.in > 'src/config.cr'
$(Q)chmod +x 'src/config.cr'
src/config.cr.install:
$(Q):
src/config.cr.clean:
@echo ' RM > src/config.cr'
$(Q)rm -f src/config.cr
src/config.cr.uninstall:
@echo ' RM > false/config.cr'
$(Q)rm -f '$(DESTDIR)false/config.cr'
src:
$(Q)mkdir -p src
$(DESTDIR)$(PREFIX):
@echo ' DIR > $(PREFIX)'
$(Q)mkdir -p $(DESTDIR)$(PREFIX)
$(DESTDIR)$(BINDIR):
@echo ' DIR > $(BINDIR)'
$(Q)mkdir -p $(DESTDIR)$(BINDIR)
$(DESTDIR)$(LIBDIR):
@echo ' DIR > $(LIBDIR)'
$(Q)mkdir -p $(DESTDIR)$(LIBDIR)
$(DESTDIR)$(SHAREDIR):
@echo ' DIR > $(SHAREDIR)'
$(Q)mkdir -p $(DESTDIR)$(SHAREDIR)
$(DESTDIR)$(INCLUDEDIR):
@echo ' DIR > $(INCLUDEDIR)'
$(Q)mkdir -p $(DESTDIR)$(INCLUDEDIR)
$(DESTDIR)$(MANDIR):
@echo ' DIR > $(MANDIR)'
$(Q)mkdir -p $(DESTDIR)$(MANDIR)
install: subdirs.install package.install assemble-apk.sh.install src/config.cr.install
@:
subdirs.install:
uninstall: subdirs.uninstall package.uninstall assemble-apk.sh.uninstall src/config.cr.uninstall
@:
subdirs.uninstall:
test: all subdirs subdirs.test
@:
subdirs.test:
clean: package.clean assemble-apk.sh.clean src/config.cr.clean
distclean: clean
dist: dist-gz dist-xz dist-bz2
$(Q)rm -- $(PACKAGE)-$(VERSION)
distdir:
$(Q)rm -rf -- $(PACKAGE)-$(VERSION)
$(Q)ln -s -- . $(PACKAGE)-$(VERSION)
dist-gz: $(PACKAGE)-$(VERSION).tar.gz
$(PACKAGE)-$(VERSION).tar.gz: distdir
@echo ' TAR > $(PACKAGE)-$(VERSION).tar.gz'
$(Q)tar czf $(PACKAGE)-$(VERSION).tar.gz \
$(PACKAGE)-$(VERSION)/src/config.cr.in \
$(PACKAGE)-$(VERSION)/src/context.cr \
$(PACKAGE)-$(VERSION)/src/instructions.cr \
$(PACKAGE)-$(VERSION)/src/main.cr \
$(PACKAGE)-$(VERSION)/src/package.cr \
$(PACKAGE)-$(VERSION)/src/recipe.cr \
$(PACKAGE)-$(VERSION)/src/sources.cr \
$(PACKAGE)-$(VERSION)/src/config.cr
dist-xz: $(PACKAGE)-$(VERSION).tar.xz
$(PACKAGE)-$(VERSION).tar.xz: distdir
@echo ' TAR > $(PACKAGE)-$(VERSION).tar.xz'
$(Q)tar cJf $(PACKAGE)-$(VERSION).tar.xz \
$(PACKAGE)-$(VERSION)/src/config.cr.in \
$(PACKAGE)-$(VERSION)/src/context.cr \
$(PACKAGE)-$(VERSION)/src/instructions.cr \
$(PACKAGE)-$(VERSION)/src/main.cr \
$(PACKAGE)-$(VERSION)/src/package.cr \
$(PACKAGE)-$(VERSION)/src/recipe.cr \
$(PACKAGE)-$(VERSION)/src/sources.cr \
$(PACKAGE)-$(VERSION)/src/config.cr
dist-bz2: $(PACKAGE)-$(VERSION).tar.bz2
$(PACKAGE)-$(VERSION).tar.bz2: distdir
@echo ' TAR > $(PACKAGE)-$(VERSION).tar.bz2'
$(Q)tar cjf $(PACKAGE)-$(VERSION).tar.bz2 \
$(PACKAGE)-$(VERSION)/src/config.cr.in \
$(PACKAGE)-$(VERSION)/src/context.cr \
$(PACKAGE)-$(VERSION)/src/instructions.cr \
$(PACKAGE)-$(VERSION)/src/main.cr \
$(PACKAGE)-$(VERSION)/src/package.cr \
$(PACKAGE)-$(VERSION)/src/recipe.cr \
$(PACKAGE)-$(VERSION)/src/sources.cr \
$(PACKAGE)-$(VERSION)/src/config.cr
help:
@echo ' :: package-0.1.0'
@echo ''
@echo 'Generic targets:'
@echo ' - help  Prints this help message.'
@echo ' - all  Builds all targets.'
@echo ' - dist  Creates tarballs of the files of the project.'
@echo ' - install  Installs the project.'
@echo ' - clean  Removes compiled files.'
@echo ' - uninstall  Deinstalls the project.'
@echo ''
@echo 'CLI-modifiable variables:'
@echo ' - CC  ${CC}'
@echo ' - CFLAGS  ${CFLAGS}'
@echo ' - LDFLAGS  ${LDFLAGS}'
@echo ' - DESTDIR  ${DESTDIR}'
@echo ' - PREFIX  ${PREFIX}'
@echo ' - BINDIR  ${BINDIR}'
@echo ' - LIBDIR  ${LIBDIR}'
@echo ' - SHAREDIR  ${SHAREDIR}'
@echo ' - INCLUDEDIR  ${INCLUDEDIR}'
@echo ' - MANDIR  ${MANDIR}'
@echo ' - LIBEXECDIR  ${LIBEXECDIR}'
@echo ''
@echo 'Project targets: '
@echo ' - package  crystal'
@echo ' - assemble-apk.sh script'
@echo ''
@echo 'Makefile options:'
@echo ' - gnu: false'
@echo ' - colors: true'
@echo ''
@echo 'Rebuild the Makefile with:'
@echo ' zsh ./build.zsh -c'
.PHONY: all subdirs clean distclean dist install uninstall help

35
project.zsh Normal file
View File

@ -0,0 +1,35 @@
package=package
version=0.1.0
variables+=(
LIBEXECDIR '$(PREFIX)/libexec'
)
targets=(package assemble-apk.sh)
type[package]=crystal
sources[package]=src/main.cr
depends[package]="$(echo src/*.cr | sed 's| src/config.cr||') src/config.cr"
type[assemble-apk.sh]=script
targets+=(src/config.cr)
type[src/config.cr]=script
sources[src/config.cr]=src/config.cr.in
auto[src/config.cr]=true # Dont display it in `make help`.
install[src/config.cr]=false
# FIXME: Clean and upstream this.
function script.install {
if [[ false == "${install[$target]}" ]]; then
write "$target.install:"
write "\t${Q}:"
write
else
binary.install "$@"
fi
}
install[assemble-apk.sh]='$(LIBEXECDIR)/package'

4
src/config.cr.in Normal file
View File

@ -0,0 +1,4 @@
# These values are changed by `make` at build-time.
OWN_LIBEXEC_DIR = "@LIBEXECDIR@/package"

View File

@ -1,4 +1,6 @@
require "./config.cr"
# FIXME: Where should this go? We cant just leave it here. :(
def pkginfo(package)
du = `du -sk #{package.fake_root_directory}`
@ -92,7 +94,7 @@ class Package::Context
Dir.mkdir_p File.dirname package_target
# FIXME: This shouldnt have to be in users PATH. libexec?
r = run package.fake_root_directory, "assemble-apk.sh", [
r = run package.fake_root_directory, "#{OWN_LIBEXEC_DIR}/assemble-apk.sh", [
package_target
]