Skip to content

Instantly share code, notes, and snippets.

@jakzal
Last active June 9, 2020 15:20
Show Gist options
  • Save jakzal/79521be5baae3432eaf6 to your computer and use it in GitHub Desktop.
Save jakzal/79521be5baae3432eaf6 to your computer and use it in GitHub Desktop.
Build an rpm/deb package for a Symfony project
config:
packagename: symfony-demo
version: 1.0.0
arch: all
maintainer: Bob The Builder <[email protected]>
description: Symfony demo project
url: http://symfony.com
packagetype: rpm
depends: ''
# - apache2
# - libapache2-mod-php5
tmpdir: /tmp
templatedir: templates
postinst: ''
preinst: ''
postrm: ''
prerm: ''
debconfconfig: ''
debconftemplate: ''
rpmconfconfig: --rpm-os linux
configfile: ''
installcmd: mkdir -p \$(PTMP)/build/var/www/symfony-demo; rsync -a --exclude Makefile* \$(PTMP)/src/ \$(PTMP)/build/var/www/symfony-demo
#!/bin/bash
CONFIG=.package.yml
REQUIRED_COMMANDS="fpm shyaml"
for command in $REQUIRED_COMMANDS; do
echo -n "checking for $command... "
which $command || { echo "not found"; exit 1; }
done
cp Makefile.in Makefile
for key in $(cat $CONFIG | shyaml keys config); do
value=$(cat $CONFIG | shyaml get-value config.$key | sed -e 's/[\/&]/\\&/g')
variable=$(echo $key | tr '[:lower:]' '[:upper:]')
if [[ $(cat $CONFIG | shyaml get-type config.$key) == "sequence" ]]; then
echo "$variable"
else
sed -i '' -e 's/@'$variable'@/'"$value"'/g' Makefile
fi
done
# This Makefile has been generated by the configure script. DO NOT
# modify it manually. If you want to modify the Makefile model, modify the
# Makefile.in file and run ./configure again.
NAME=@PACKAGENAME@
VERSION=@VERSION@
MAINTAINER=@MAINTAINER@
PACKAGENAME=@PACKAGENAME@
PACKAGETYPE=@PACKAGETYPE@
URL=@URL@
ARCH=@ARCH@
DEPENDS=@DEPENDS@
MAINTAINER=@MAINTAINER@
DESCRIPTION=@DESCRIPTION@
POSTINST=@POSTINST@
PREINST=@PREINST@
POSTRM=@POSTRM@
PRERM=@PRERM@
DEBCONFCONFIG=@DEBCONFCONFIG@
DEBCONFTEMPLATE=@DEBCONFTEMPLATE@
RPMCONFCONFIG=@RPMCONFCONFIG@
CONFIGFILE=@CONFIGFILE@
TEMPLATEDIR=@TEMPLATEDIR@
TMP=@TMPDIR@
ENV=
PTMP=$(TMP)/$(PACKAGENAME)
all: package
clean:
rm -rf $(PTMP)
structure: clean
mkdir -p $(PTMP)/src $(PTMP)/build $(PTMP)/misc
rsync -rl --exclude packaging --exclude Makefile \
--exclude packaging_config.php --exclude '.git*' --exclude '.svn' \
--exclude '.CVS' --exclude "$(TMP)" . $(PTMP)/src
template: structure
build: template
@INSTALLCMD@
package: build
fpm -s dir -t $(PACKAGETYPE) -n "$(PACKAGENAME)" -v "$(VERSION)" -m "$(MAINTAINER)" --url "$(URL)" \
--description "$(DESCRIPTION)" $(DEPENDS) $(POSTINST) $(PREINST) $(POSTRM) $(PRERM) \
$(DEBCONFCONFIG) \
$(DEBCONFTEMPLATE) \
$(RPMCONFCONFIG) \
$(CONFIGFILE) \
-a $(ARCH) -C $(PTMP)/build -p $(PTMP)/$(PACKAGENAME)_$(VERSION)_$(ARCH).$(PACKAGETYPE) .
./configure
make
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment