Skip to content

Commit

Permalink
Move package meta data from create scripts to single files
Browse files Browse the repository at this point in the history
  • Loading branch information
alexreinert committed Jan 5, 2018
1 parent f324937 commit d568968
Show file tree
Hide file tree
Showing 19 changed files with 179 additions and 202 deletions.
31 changes: 4 additions & 27 deletions create_devicetree_armbian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,10 @@ DPkg::Post-Invoke {"if [ -e /var/lib/piVCCU/dts/patch_dts.sh ]; then /var/lib/pi
EOF

mkdir -p $TARGET_DIR/DEBIAN

cat <<EOT >> $TARGET_DIR/DEBIAN/control
Package: pivccu-devicetree-armbian
Version: $PKG_VERSION
Architecture: armhf
Maintainer: Alexander Reinert <[email protected]>
Provides: pivccu-devicetree
Section: misc
Priority: extra
Homepage: https://github.com/alexreinert/piVCCU
Description: piVCCU DeviceTree files for armbian
This package contains piVCCU DeviceTree files for armbian
EOT

cat <<EOT >> $TARGET_DIR/DEBIAN/postinst
#!/bin/sh
/var/lib/piVCCU/dts/patch_dts.sh
EOT

chmod +x $TARGET_DIR/DEBIAN/postinst

cat <<EOT >> $TARGET_DIR/DEBIAN/prerm
#!/bin/sh
/var/lib/piVCCU/dts/revert_dts.sh
EOT

chmod +x $TARGET_DIR/DEBIAN/prerm
cp -p $CURRENT_DIR/package/pivccu-devicetree-armbian/* $TARGET_DIR/DEBIAN
for file in $TARGET_DIR/DEBIAN/*; do
sed -i "s/{PKG_VERSION}/$PKG_VERSION/g" $file
done

cd $WORK_DIR

Expand Down
72 changes: 3 additions & 69 deletions create_modules_dkms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,77 +42,11 @@ mkdir -p $TARGET_DIR/var/lib/piVCCU/dkms
cp -p $CURRENT_DIR/pivccu/dkms/*.sh $TARGET_DIR/var/lib/piVCCU/dkms

mkdir -p $TARGET_DIR/DEBIAN

cat <<EOT >> $TARGET_DIR/DEBIAN/control
Package: pivccu-modules-dkms
Version: $PKG_VERSION
Architecture: armhf
Maintainer: Alexander Reinert <[email protected]>
Provides: pivccu-kernel-modules
Pre-Depends: dkms, build-essential
Recommends: pivccu-devicetree
Section: kernel
Priority: extra
Homepage: https://github.com/alexreinert/piVCCU
Description: DKMS package for kernel modules needed for Homematic
This package contains the a DKMS package for kernel needed for Homematic.
EOT

echo /lib/systemd/system/pivccu-dkms.service >> $TARGET_DIR/DEBIAN/conffiles

for file in preinst postinst prerm postrm; do
echo "#!/bin/sh" > $TARGET_DIR/DEBIAN/$file
chmod 755 $TARGET_DIR/DEBIAN/$file
cp -p $CURRENT_DIR/package/pivccu-modules-dkms/* $TARGET_DIR/DEBIAN
for file in $TARGET_DIR/DEBIAN/*; do
sed -i "s/{PKG_VERSION}/$PKG_VERSION/g" $file
done

cat <<EOF >> $TARGET_DIR/DEBIAN/postinst
set -e
systemctl enable pivccu-dkms.service
DKMS_NAME=pivccu
DKMS_PACKAGE_NAME=\$DKMS_NAME-dkms
DKMS_VERSION=$PKG_VERSION
postinst_found=0
case "\$1" in
configure)
for DKMS_POSTINST in /usr/lib/dkms/common.postinst /usr/share/\$DKMS_PACKAGE_NAME/postinst; do
if [ -f \$DKMS_POSTINST ]; then
\$DKMS_POSTINST \$DKMS_NAME \$DKMS_VERSION /usr/share/\$DKMS_PACKAGE_NAME "" \$2
postinst_found=1
break
fi
done
if [ "\$postinst_found" -eq 0 ]; then
echo "ERROR: DKMS version is too old and \$DKMS_PACKAGE_NAME was not"
echo "built with legacy DKMS support."
echo "You must either rebuild \$DKMS_PACKAGE_NAME with legacy postinst"
echo "support or upgrade DKMS to a more current version."
exit 1
fi
;;
esac
EOF

cat <<EOF >> $TARGET_DIR/DEBIAN/prerm
set -e
systemctl disable pivccu-dkms.service
DKMS_NAME=pivccu
DKMS_VERSION=$PKG_VERSION
case "\$1" in
remove|upgrade|deconfigure)
if [ "\$(dkms status -m \$DKMS_NAME -v \$DKMS_VERSION)" ]; then
dkms remove -m \$DKMS_NAME -v \$DKMS_VERSION --all
fi
;;
esac
EOF

cd $WORK_DIR

dpkg-deb --build pivccu-modules-dkms-$PKG_VERSION
Expand Down
53 changes: 5 additions & 48 deletions create_modules_raspberrypi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,54 +53,11 @@ cd $CURRENT_DIR/dts
dtc -@ -I dts -O dtb -o $TARGET_DIR/boot/overlays/pivccu-bcm2835.dtbo pivccu-bcm2835.dts

mkdir -p $TARGET_DIR/DEBIAN

cat <<EOT >> $TARGET_DIR/DEBIAN/control
Package: pivccu-modules-raspberrypi
Version: $PKG_VERSION
Architecture: armhf
Maintainer: Alexander Reinert <[email protected]>
Provides: pivccu-kernel-modules
Depends: raspberrypi-kernel (= $KERNEL_TAG)
Section: kernel
Priority: extra
Homepage: https://github.com/alexreinert/piVCCU
Description: Raspberry Pi kernel modules needed for Homematic
This package contains the Raspberry Pi kernel needed for Homematic.
EOT

for file in preinst postinst prerm postrm; do
echo "#!/bin/sh" > $TARGET_DIR/DEBIAN/$file
chmod 755 $TARGET_DIR/DEBIAN/$file
done

for file in postinst postrm; do
echo "depmod -a $KERNEL_RELEASE" >> $TARGET_DIR/DEBIAN/$file

cat <<EOF >> $TARGET_DIR/DEBIAN/$file
sed -i /boot/config.txt -e '/dtoverlay=pivccu-bcm2835/d'
EOF

done

cat <<EOF >> $TARGET_DIR/DEBIAN/postinst
echo "dtoverlay=pivccu-bcm2835" >> /boot/config.txt
EOF

cd $TARGET_DIR/boot

for file in $(find * -type f)
do
cat <<EOF >> $TARGET_DIR/DEBIAN/preinst
dpkg-divert --package rpikernelhack --divert /usr/share/rpikernelhack/$file /boot/$file
EOF

cat <<EOF >> $TARGET_DIR/DEBIAN/postinst
if [ -f /usr/share/rpikernelhack/$file ]; then
rm -f /boot/$file
dpkg-divert --package rpikernelhack --remove --rename /boot/$file
sync
fi
EOF
cp -p $CURRENT_DIR/package/pivccu-modules-raspberrypi/* $TARGET_DIR/DEBIAN
for file in $TARGET_DIR/DEBIAN/*; do
sed -i "s/{PKG_VERSION}/$PKG_VERSION/g" $file
sed -i "s/{KERNEL_TAG}/$KERNEL_TAG/g" $file
sed -i "s/{KERNEL_RELEASE}/$KERNEL_RELEASE/g" $file
done

cd $WORK_DIR
Expand Down
62 changes: 4 additions & 58 deletions create_pivccu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,65 +67,11 @@ mkdir -p $TARGET_DIR/lib/systemd/system/
cp -p $CURRENT_DIR/pivccu/host/pivccu.service $TARGET_DIR/lib/systemd/system/

mkdir -p $TARGET_DIR/DEBIAN

cat <<EOT >> $TARGET_DIR/DEBIAN/control
Package: pivccu
Version: $PKG_VERSION
Architecture: armhf
Maintainer: Alexander Reinert <[email protected]>
Depends: pivccu-kernel-modules
Pre-Depends: lxc, bridge-utils, systemd
Section: misc
Priority: extra
Homepage: https://github.com/alexreinert/piVCCU
Description: piVCCU - Homematic CCU LXC container
This package contains piVCCU - a Homematic CCU LXC container
EOT

echo /etc/piVCCU/lxc.config >> $TARGET_DIR/DEBIAN/conffiles
echo /lib/systemd/system/pivccu.service >> $TARGET_DIR/DEBIAN/conffiles

cat <<EOT >> $TARGET_DIR/DEBIAN/postinst
#!/bin/sh
systemctl enable pivccu.service
systemctl start pivccu.service || true
if [ ! -e /usr/sbin/pivccu-attach ]; then
ln -s /var/lib/piVCCU/pivccu-attach.sh /usr/sbin/pivccu-attach
fi
if [ ! -e /usr/sbin/pivccu-info ]; then
ln -s /var/lib/piVCCU/pivccu-info.sh /usr/sbin/pivccu-info
fi
if [ ! -e /usr/sbin/pivccu-device ]; then
ln -s /var/lib/piVCCU/pivccu-device.sh /usr/sbin/pivccu-device
fi
BRIDGE=\`brctl show | sed -n 2p | awk '{print \$1}'\`
if [ -z "\$BRIDGE" ]; then
echo "WARNING: No network bridge could be detected."
fi
sed -i 's/alexreinert.github.io/www.pivccu.de/g' /etc/apt/sources.list
sed -i 's/http:\\/\\/www.pivccu.de/https:\\/\\/www.pivccu.de/g' /etc/apt/sources.list
for file in \`find /etc/apt/sources.list.d/*.list -type f 2>/dev/null\`; do
sed -i 's/alexreinert.github.io/www.pivccu.de/g' \$file
sed -i 's/http:\\/\\/www.pivccu.de/https:\\/\\/www.pivccu.de/g' \$file
cp -p $CURRENT_DIR/package/pivccu/* $TARGET_DIR/DEBIAN
for file in $TARGET_DIR/DEBIAN/*; do
sed -i "s/{PKG_VERSION}/$PKG_VERSION/g" $file
sed -i "s/{CCU_VERSION}/$CCU_VERSION/g" $file
done
EOT

chmod +x $TARGET_DIR/DEBIAN/postinst

cat <<EOT >> $TARGET_DIR/DEBIAN/prerm
#!/bin/sh
systemctl stop pivccu.service
systemctl disable pivccu.service
rm -f /usr/sbin/pivccu-attach
rm -f /usr/sbin/pivccu-info
rm -f /usr/sbin/pivccu-device
EOT

chmod +x $TARGET_DIR/DEBIAN/prerm

cd $WORK_DIR

Expand Down
11 changes: 11 additions & 0 deletions package/pivccu-devicetree-armbian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Package: pivccu-devicetree-armbian
Version: {PKG_VERSION}
Architecture: armhf
Maintainer: Alexander Reinert <[email protected]>
Provides: pivccu-devicetree
Section: misc
Priority: extra
Homepage: https://github.com/alexreinert/piVCCU
Description: piVCCU DeviceTree files for armbian
This package contains piVCCU DeviceTree files for armbian

3 changes: 3 additions & 0 deletions package/pivccu-devicetree-armbian/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
/var/lib/piVCCU/dts/patch_dts.sh

3 changes: 3 additions & 0 deletions package/pivccu-devicetree-armbian/prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
/var/lib/piVCCU/dts/revert_dts.sh

1 change: 1 addition & 0 deletions package/pivccu-modules-dkms/conffiles
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/lib/systemd/system/pivccu-dkms.service
13 changes: 13 additions & 0 deletions package/pivccu-modules-dkms/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Package: pivccu-modules-dkms
Version: {PKG_VERSION}
Architecture: armhf
Maintainer: Alexander Reinert <[email protected]>
Provides: pivccu-kernel-modules
Pre-Depends: dkms, build-essential
Recommends: pivccu-devicetree
Section: kernel
Priority: extra
Homepage: https://github.com/alexreinert/piVCCU
Description: DKMS package for kernel modules needed for Homematic
This package contains the a DKMS package for kernel needed for Homematic.

28 changes: 28 additions & 0 deletions package/pivccu-modules-dkms/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
set -e

systemctl enable pivccu-dkms.service

DKMS_NAME=pivccu
DKMS_PACKAGE_NAME=$DKMS_NAME-dkms
DKMS_VERSION={PKG_VERSION}

postinst_found=0

case "$1" in
configure)
for DKMS_POSTINST in /usr/lib/dkms/common.postinst /usr/share/$DKMS_PACKAGE_NAME/postinst; do
if [ -f $DKMS_POSTINST ]; then
$DKMS_POSTINST $DKMS_NAME $DKMS_VERSION /usr/share/$DKMS_PACKAGE_NAME "" $2
postinst_found=1
break
fi
done
if [ "$postinst_found" -eq 0 ]; then
echo "ERROR: DKMS version is too old and $DKMS_PACKAGE_NAME was not"
echo "built with legacy DKMS support."
echo "You must either rebuild $DKMS_PACKAGE_NAME with legacy postinst"
echo "support or upgrade DKMS to a more current version."
exit 1
fi
;;
esac
14 changes: 14 additions & 0 deletions package/pivccu-modules-dkms/prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
set -e

systemctl disable pivccu-dkms.service

DKMS_NAME=pivccu
DKMS_VERSION={PKG_VERSION}

case "$1" in
remove|upgrade|deconfigure)
if [ "$(dkms status -m $DKMS_NAME -v $DKMS_VERSION)" ]; then
dkms remove -m $DKMS_NAME -v $DKMS_VERSION --all
fi
;;
esac
12 changes: 12 additions & 0 deletions package/pivccu-modules-raspberrypi/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Package: pivccu-modules-raspberrypi
Version: {PKG_VERSION}
Architecture: armhf
Maintainer: Alexander Reinert <[email protected]>
Provides: pivccu-kernel-modules
Depends: raspberrypi-kernel (= {KERNEL_TAG})
Section: kernel
Priority: extra
Homepage: https://github.com/alexreinert/piVCCU
Description: Raspberry Pi kernel modules needed for Homematic
This package contains the Raspberry Pi kernel needed for Homematic.

9 changes: 9 additions & 0 deletions package/pivccu-modules-raspberrypi/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
depmod -a {KERNEL_RELEASE}

if [ -f /usr/share/rpikernelhack/overlays/pivccu-bcm2835.dtbo ]; then
rm -f /boot/overlays/pivccu-bcm2835.dtbo
dpkg-divert --package rpikernelhack --remove --rename /boot/overlays/pivccu-bcm2835.dtbo
sync
fi

3 changes: 3 additions & 0 deletions package/pivccu-modules-raspberrypi/postrm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
depmod -a {KERNEL_RELEASE}

3 changes: 3 additions & 0 deletions package/pivccu-modules-raspberrypi/preinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
dpkg-divert --package rpikernelhack --divert /usr/share/rpikernelhack/overlays/pivccu-bcm2835.dtbo /boot/overlays/pivccu-bcm2835.dtbo

2 changes: 2 additions & 0 deletions package/pivccu/conffiles
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/etc/piVCCU/lxc.config
/lib/systemd/system/pivccu.service
12 changes: 12 additions & 0 deletions package/pivccu/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Package: pivccu
Version: {PKG_VERSION}
Architecture: armhf
Maintainer: Alexander Reinert <[email protected]>
Depends: pivccu-kernel-modules
Pre-Depends: lxc, bridge-utils, systemd
Section: misc
Priority: extra
Homepage: https://github.com/alexreinert/piVCCU
Description: piVCCU - Homematic CCU LXC container
This package contains piVCCU - a Homematic CCU LXC container

Loading

0 comments on commit d568968

Please sign in to comment.