Skip to content

Commit 6a6caa7

Browse files
paper42classabbyamp
authored andcommitted
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.
1 parent b28b64f commit 6a6caa7

13 files changed

Lines changed: 32 additions & 30 deletions

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
*.sh
21
*.img
32
*.xz
43
*.iso

Makefile

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
GITVER := $(shell git rev-parse --short HEAD)
2-
VERSION = 0.23
3-
SHIN += $(shell find -type f -name '*.sh.in')
4-
SCRIPTS += $(SHIN:.sh.in=.sh)
1+
SCRIPTS += $(shell find -type f -name '*.sh')
52
DATECODE=$(shell date "+%Y%m%d")
63
SHELL=/bin/bash
74

@@ -30,14 +27,7 @@ SUDO := sudo
3027
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
3128
COMPRESSOR_THREADS=2
3229

33-
%.sh: %.sh.in
34-
sed -e "s|@@MKLIVE_VERSION@@|$(VERSION) $(GITVER)|g" $^ > $@
35-
chmod +x $@
36-
37-
all: $(SCRIPTS)
38-
39-
clean:
40-
-rm -f *.sh
30+
all:
4131

4232
distdir-$(DATECODE):
4333
mkdir -p distdir-$(DATECODE)
@@ -89,4 +79,4 @@ pxe-all-print:
8979
void-%-NETBOOT-$(DATECODE).tar.gz: $(SCRIPTS) void-%-ROOTFS-$(DATECODE).tar.xz
9080
$(SUDO) ./mknet.sh void-$*-ROOTFS-$(DATECODE).tar.xz
9181

92-
.PHONY: clean dist rootfs-all-print rootfs-all platformfs-all-print platformfs-all pxe-all-print pxe-all
82+
.PHONY: all dist rootfs-all-print rootfs-all platformfs-all-print platformfs-all pxe-all-print pxe-all

README.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ This repository contains utilities for Void Linux:
1010
* mkrootfs (The Void Linux rootfs maker for ARM platforms)
1111
* mknet (Script to generate netboot tarballs for Void)
1212

13-
## Build Dependencies
14-
* make
15-
1613
## Dependencies
1714
* Compression type for the initramfs image
1815
* liblz4 (for lz4, xz) (default)
@@ -22,11 +19,7 @@ This repository contains utilities for Void Linux:
2219

2320
## Usage
2421

25-
Type
26-
27-
$ make
28-
29-
and then see the usage output:
22+
See the usage output:
3023

3124
$ ./mklive.sh -h
3225
$ ./mkrootfs.sh -h
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ if [ ! -x mklive.sh ]; then
9090
fi
9191

9292
if [ -x installer.sh ]; then
93-
install -Dm755 installer.sh "$INCLUDEDIR"/usr/bin/void-installer
93+
. ./version.sh
94+
installer=$(mktemp)
95+
sed "s/@@MKLIVE_VERSION@@/${MKLIVE_VERSION}/" installer.sh > "$installer"
96+
install -Dm755 "$installer" "$INCLUDEDIR"/usr/bin/void-installer
97+
rm "$installer"
9498
else
9599
echo installer.sh not found >&2
96100
exit 1

installer.sh.in renamed to installer.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2626
#-
2727

28+
. ./version.sh
29+
2830
# Make sure we don't inherit these from env.
2931
SOURCE_DONE=
3032
HOSTNAME_DONE=
File renamed without changes.

mkimage.sh.in renamed to mkimage.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2626
#-
2727

28+
. ./version.sh
29+
2830
readonly PROGNAME=$(basename "$0")
2931
readonly ARCH=$(uname -m)
3032

@@ -94,7 +96,7 @@ while getopts "b:B:o:r:s:x:h:V" opt; do
9496
r) ROOT_FSTYPE="$OPTARG";;
9597
s) IMGSIZE="$OPTARG";;
9698
x) COMPRESSOR_THREADS="$OPTARG" ;;
97-
V) echo "$PROGNAME @@MKLIVE_VERSION@@"; exit 0;;
99+
V) echo "$PROGNAME $MKLIVE_VERSION"; exit 0;;
98100
h) usage;;
99101
esac
100102
done

mklive.sh.in renamed to mklive.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
trap 'error_out $? $LINENO' INT TERM 0
3030
umask 022
3131

32+
. ./version.sh
33+
3234
readonly REQUIRED_PKGS="base-files libgcc dash coreutils sed tar gawk syslinux grub-i386-efi grub-x86_64-efi squashfs-tools xorriso"
3335
readonly INITRAMFS_PKGS="binutils xz device-mapper dhclient dracut-network openresolv"
3436
readonly PROGNAME=$(basename "$0")
@@ -292,7 +294,7 @@ generate_iso_image() {
292294
#
293295
# main()
294296
#
295-
while getopts "a:b:r:c:C:T:Kk:l:i:I:S:s:o:p:v:h" opt; do
297+
while getopts "a:b:r:c:C:T:Kk:l:i:I:S:s:o:p:v:Vh" opt; do
296298
case $opt in
297299
a) BASE_ARCH="$OPTARG";;
298300
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
310312
C) BOOT_CMDLINE="$OPTARG";;
311313
T) BOOT_TITLE="$OPTARG";;
312314
v) LINUX_VERSION="$OPTARG";;
315+
V) echo "$PROGNAME $MKLIVE_VERSION"; exit 0 ;;
313316
h) usage;;
314317
*) usage;;
315318
esac

mknet.sh.in renamed to mknet.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828
#-
2929

30+
. ./version.sh
31+
3032
readonly PROGNAME=$(basename "$0")
3133
readonly REQTOOLS="xbps-install tar"
3234

@@ -77,7 +79,7 @@ _EOF
7779
# SCRIPT EXECUTION STARTS HERE
7880
# ########################################
7981

80-
while getopts "r:c:C:T:K:i:o:k:l:h" opt; do
82+
while getopts "r:c:C:T:K:i:o:k:l:Vh" opt; do
8183
case $opt in
8284
r) XBPS_REPOSITORY="--repository=$OPTARG $XBPS_REPOSITORY";;
8385
c) XBPS_CACHEDIR="--cachedir=$OPTARG";;
@@ -89,6 +91,7 @@ while getopts "r:c:C:T:K:i:o:k:l:h" opt; do
8991
C) BOOT_CMDLINE="$OPTARG";;
9092
T) BOOT_TITLE="$OPTARG";;
9193
S) SPLASH_IMAGE="OPTARG";;
94+
V) echo "$PROGNAME $MKLIVE_VERSION"; exit 0 ;;
9295
h) usage;;
9396
esac
9497
done
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2525
#-
2626

27+
. ./version.sh
28+
2729
readonly PROGNAME=$(basename "$0")
2830
readonly ARCH=$(uname -m)
2931
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
8789
o) FILENAME="$OPTARG" ;;
8890
n) COMPRESSION="n" ;;
8991
h) usage; exit 0 ;;
90-
V) echo "$PROGNAME @@MKLIVE_VERSION@@"; exit 0 ;;
92+
V) echo "$PROGNAME $MKLIVE_VERSION"; exit 0 ;;
9193
esac
9294
done
9395
shift $((OPTIND - 1))

0 commit comments

Comments
 (0)