Răsfoiți Sursa

Do not build .sh scripts from .sh.in

The build process only replaces @@MKLIVE_VERSION@@ with the correct
version string. This can also be done by simply sourcing a version.sh file.
This way it's simpler, avoids one unnecessary build step and people
won't accidentally run an old version of a script.
Michal Vasilek 2 ani în urmă
părinte
comite
6a6caa7b31
13 a modificat fișierele cu 32 adăugiri și 30 ștergeri
  1. 0 1
      .gitignore
  2. 3 13
      Makefile
  3. 1 8
      README.md
  4. 5 1
      build-x86-images.sh
  5. 2 0
      installer.sh
  6. 0 0
      lib.sh
  7. 3 1
      mkimage.sh
  8. 4 1
      mklive.sh
  9. 4 1
      mknet.sh
  10. 3 1
      mkplatformfs.sh
  11. 3 1
      mkrootfs.sh
  12. 0 2
      release.sh
  13. 4 0
      version.sh

+ 0 - 1
.gitignore

@@ -1,4 +1,3 @@
-*.sh
 *.img
 *.xz
 *.iso

+ 3 - 13
Makefile

@@ -1,7 +1,4 @@
-GITVER := $(shell git rev-parse --short HEAD)
-VERSION = 0.23
-SHIN    += $(shell find -type f -name '*.sh.in')
-SCRIPTS += $(SHIN:.sh.in=.sh)
+SCRIPTS += $(shell find -type f -name '*.sh')
 DATECODE=$(shell date "+%Y%m%d")
 SHELL=/bin/bash
 
@@ -30,14 +27,7 @@ SUDO := sudo
 XBPS_REPOSITORY := -r https://repo-default.voidlinux.org/current -r https://repo-default.voidlinux.org/current/musl -r https://repo-default.voidlinux.org/current/aarch64
 COMPRESSOR_THREADS=2
 
-%.sh: %.sh.in
-	 sed -e "s|@@MKLIVE_VERSION@@|$(VERSION) $(GITVER)|g" $^ > $@
-	 chmod +x $@
-
-all: $(SCRIPTS)
-
-clean:
-	-rm -f *.sh
+all:
 
 distdir-$(DATECODE):
 	mkdir -p distdir-$(DATECODE)
@@ -89,4 +79,4 @@ pxe-all-print:
 void-%-NETBOOT-$(DATECODE).tar.gz: $(SCRIPTS) void-%-ROOTFS-$(DATECODE).tar.xz
 	$(SUDO) ./mknet.sh void-$*-ROOTFS-$(DATECODE).tar.xz
 
-.PHONY: clean dist rootfs-all-print rootfs-all platformfs-all-print platformfs-all pxe-all-print pxe-all
+.PHONY: all dist rootfs-all-print rootfs-all platformfs-all-print platformfs-all pxe-all-print pxe-all

+ 1 - 8
README.md

@@ -10,9 +10,6 @@ This repository contains utilities for Void Linux:
  * mkrootfs  (The Void Linux rootfs maker for ARM platforms)
  * mknet (Script to generate netboot tarballs for Void)
 
-## Build Dependencies
- * make
-
 ## Dependencies
  * Compression type for the initramfs image
    * liblz4 (for lz4, xz) (default)
@@ -22,11 +19,7 @@ This repository contains utilities for Void Linux:
 
 ## Usage
 
-Type
-
-    $ make
-
-and then see the usage output:
+See the usage output:
 
     $ ./mklive.sh -h
     $ ./mkrootfs.sh -h

+ 5 - 1
build-x86-images.sh.in → build-x86-images.sh

@@ -90,7 +90,11 @@ if [ ! -x mklive.sh ]; then
 fi
 
 if [ -x installer.sh ]; then
-    install -Dm755 installer.sh "$INCLUDEDIR"/usr/bin/void-installer
+    . ./version.sh
+    installer=$(mktemp)
+    sed "s/@@MKLIVE_VERSION@@/${MKLIVE_VERSION}/" installer.sh > "$installer"
+    install -Dm755 "$installer" "$INCLUDEDIR"/usr/bin/void-installer
+    rm "$installer"
 else
     echo installer.sh not found >&2
     exit 1

+ 2 - 0
installer.sh.in → installer.sh

@@ -25,6 +25,8 @@
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #-
 
+. ./version.sh
+
 # Make sure we don't inherit these from env.
 SOURCE_DONE=
 HOSTNAME_DONE=

+ 0 - 0
lib.sh.in → lib.sh


+ 3 - 1
mkimage.sh.in → mkimage.sh

@@ -25,6 +25,8 @@
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #-
 
+. ./version.sh
+
 readonly PROGNAME=$(basename "$0")
 readonly ARCH=$(uname -m)
 
@@ -94,7 +96,7 @@ while getopts "b:B:o:r:s:x:h:V" opt; do
         r) ROOT_FSTYPE="$OPTARG";;
         s) IMGSIZE="$OPTARG";;
         x) COMPRESSOR_THREADS="$OPTARG" ;;
-        V) echo "$PROGNAME @@MKLIVE_VERSION@@"; exit 0;;
+        V) echo "$PROGNAME $MKLIVE_VERSION"; exit 0;;
         h) usage;;
     esac
 done

+ 4 - 1
mklive.sh.in → mklive.sh

@@ -29,6 +29,8 @@
 trap 'error_out $? $LINENO' INT TERM 0
 umask 022
 
+. ./version.sh
+
 readonly REQUIRED_PKGS="base-files libgcc dash coreutils sed tar gawk syslinux grub-i386-efi grub-x86_64-efi squashfs-tools xorriso"
 readonly INITRAMFS_PKGS="binutils xz device-mapper dhclient dracut-network openresolv"
 readonly PROGNAME=$(basename "$0")
@@ -292,7 +294,7 @@ generate_iso_image() {
 #
 # main()
 #
-while getopts "a:b:r:c:C:T:Kk:l:i:I:S:s:o:p:v:h" opt; do
+while getopts "a:b:r:c:C:T:Kk:l:i:I:S:s:o:p:v:Vh" opt; do
     case $opt in
         a) BASE_ARCH="$OPTARG";;
         b) BASE_SYSTEM_PKG="$OPTARG";;
@@ -310,6 +312,7 @@ while getopts "a:b:r:c:C:T:Kk:l:i:I:S:s:o:p:v:h" opt; do
         C) BOOT_CMDLINE="$OPTARG";;
         T) BOOT_TITLE="$OPTARG";;
         v) LINUX_VERSION="$OPTARG";;
+        V) echo "$PROGNAME $MKLIVE_VERSION"; exit 0 ;;
         h) usage;;
 	*) usage;;
     esac

+ 4 - 1
mknet.sh.in → mknet.sh

@@ -27,6 +27,8 @@
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #-
 
+. ./version.sh
+
 readonly PROGNAME=$(basename "$0")
 readonly REQTOOLS="xbps-install tar"
 
@@ -77,7 +79,7 @@ _EOF
 #      SCRIPT EXECUTION STARTS HERE
 # ########################################
 
-while getopts "r:c:C:T:K:i:o:k:l:h" opt; do
+while getopts "r:c:C:T:K:i:o:k:l:Vh" opt; do
     case $opt in
         r) XBPS_REPOSITORY="--repository=$OPTARG $XBPS_REPOSITORY";;
         c) XBPS_CACHEDIR="--cachedir=$OPTARG";;
@@ -89,6 +91,7 @@ while getopts "r:c:C:T:K:i:o:k:l:h" opt; do
         C) BOOT_CMDLINE="$OPTARG";;
         T) BOOT_TITLE="$OPTARG";;
         S) SPLASH_IMAGE="OPTARG";;
+        V) echo "$PROGNAME $MKLIVE_VERSION"; exit 0 ;;
         h) usage;;
     esac
 done

+ 3 - 1
mkplatformfs.sh.in → mkplatformfs.sh

@@ -24,6 +24,8 @@
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #-
 
+. ./version.sh
+
 readonly PROGNAME=$(basename "$0")
 readonly ARCH=$(uname -m)
 readonly REQTOOLS="xbps-install xbps-reconfigure tar xz"
@@ -87,7 +89,7 @@ while getopts "b:p:k:c:C:r:x:o:nhV" opt; do
         o) FILENAME="$OPTARG" ;;
         n) COMPRESSION="n" ;;
         h) usage; exit 0 ;;
-        V) echo "$PROGNAME @@MKLIVE_VERSION@@"; exit 0 ;;
+        V) echo "$PROGNAME $MKLIVE_VERSION"; exit 0 ;;
     esac
 done
 shift $((OPTIND - 1))

+ 3 - 1
mkrootfs.sh.in → mkrootfs.sh

@@ -25,6 +25,8 @@
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #-
 
+. ./version.sh
+
 readonly PROGNAME=$(basename "$0")
 readonly ARCH=$(uname -m)
 readonly REQTOOLS="xbps-install xbps-reconfigure tar xz"
@@ -87,7 +89,7 @@ while getopts "b:C:c:hr:x:o:V" opt; do
         r) XBPS_REPOSITORY="$XBPS_REPOSITORY --repository=$OPTARG";;
         x) COMPRESSOR_THREADS="$OPTARG" ;;
         o) FILENAME="$OPTARG" ;;
-        V) echo "$PROGNAME @@MKLIVE_VERSION@@"; exit 0;;
+        V) echo "$PROGNAME $MKLIVE_VERSION"; exit 0;;
     esac
 done
 shift $((OPTIND - 1))

+ 0 - 2
release.sh.in → release.sh

@@ -3,8 +3,6 @@
 XBPS_REPOSITORY="-r /hostdir/binpkgs -r /hostdir/binpkgs/musl -r /hostdir/binpkgs/aarch64"
 DATECODE=$(date "+%Y%m%d")
 
-make
-
 ARCHS="$(echo x86_64{,-musl} i686 armv{6,7}l{,-musl} aarch64{,-musl})"
 PLATFORMS="$(echo rpi-{armv{6,7}l,aarch64}{,-musl})"
 SBC_IMGS="$(echo rpi-{armv{6,7}l,aarch64}{,-musl})"

+ 4 - 0
version.sh

@@ -0,0 +1,4 @@
+if [ -z "${MKLIVE_REV}" ]; then
+	MKLIVE_REV="$(git rev-parse --short HEAD || echo "unknown")"
+fi
+MKLIVE_VERSION="0.23-$MKLIVE_REV"