*.sh: refactor new version method into lib.sh
no need to create a second file just for the version when it can be set in lib.sh git -c safe.directory is needed to be able to run rev-parse as root also contains some minor refactors to arg parsing etc
This commit is contained in:
parent
3c75acb212
commit
8871805dc5
|
@ -2,21 +2,25 @@
|
|||
|
||||
set -eu
|
||||
|
||||
. ./lib.sh
|
||||
|
||||
PROGNAME=$(basename "$0")
|
||||
ARCH=$(uname -m)
|
||||
IMAGES="base enlightenment xfce mate cinnamon gnome kde lxde lxqt"
|
||||
REPO=
|
||||
DATE=$(date +%Y%m%d)
|
||||
|
||||
help() {
|
||||
echo "${0#/*}: [-a arch] [-b base|enlightenment|xfce|mate|cinnamon|gnome|kde|lxde|lxqt] [-r repo]" >&2
|
||||
echo "$PROGNAME: [-a arch] [-b base|enlightenment|xfce|mate|cinnamon|gnome|kde|lxde|lxqt] [-r repo]" >&2
|
||||
}
|
||||
|
||||
while getopts "a:b:hr:" opt; do
|
||||
while getopts "a:b:hr:V" opt; do
|
||||
case $opt in
|
||||
a) ARCH="$OPTARG";;
|
||||
b) IMAGES="$OPTARG";;
|
||||
h) help; exit 0;;
|
||||
r) REPO="-r $OPTARG $REPO";;
|
||||
V) version; exit 0;;
|
||||
*) help; exit 1;;
|
||||
esac
|
||||
done
|
||||
|
@ -90,7 +94,7 @@ if [ ! -x mklive.sh ]; then
|
|||
fi
|
||||
|
||||
if [ -x installer.sh ]; then
|
||||
. ./version.sh
|
||||
MKLIVE_VERSION="$(PROGNAME='' version)"
|
||||
installer=$(mktemp)
|
||||
sed "s/@@MKLIVE_VERSION@@/${MKLIVE_VERSION}/" installer.sh > "$installer"
|
||||
install -Dm755 "$installer" "$INCLUDEDIR"/usr/bin/void-installer
|
||||
|
|
6
lib.sh
6
lib.sh
|
@ -33,6 +33,12 @@ is_target_native() {
|
|||
return $?
|
||||
}
|
||||
|
||||
version() (
|
||||
set +u
|
||||
[ -n "$PROGNAME" ] && printf "%s " "$PROGNAME"
|
||||
echo "$(cat ./version) ${MKLIVE_REV:-"$(git -c safe.directory="$(pwd)" rev-parse --short HEAD 2> /dev/null)"}"
|
||||
)
|
||||
|
||||
info_msg() {
|
||||
# This function handles the printing that is bold within all
|
||||
# scripts. This is a convenience function so that the rather ugly
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#-
|
||||
|
||||
. ./version.sh
|
||||
|
||||
readonly PROGNAME=$(basename "$0")
|
||||
readonly ARCH=$(uname -m)
|
||||
|
||||
|
@ -96,8 +94,8 @@ 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;;
|
||||
h) usage;;
|
||||
V) version; exit 0;;
|
||||
*) usage;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
trap 'error_out $? $LINENO' INT TERM 0
|
||||
umask 022
|
||||
|
||||
. ./version.sh
|
||||
. ./lib.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"
|
||||
|
@ -312,9 +312,8 @@ while getopts "a:b:r:c:C:T:Kk:l:i:I:S:s:o:p:v:Vh" opt; do
|
|||
C) BOOT_CMDLINE="$OPTARG";;
|
||||
T) BOOT_TITLE="$OPTARG";;
|
||||
v) LINUX_VERSION="$OPTARG";;
|
||||
V) echo "$PROGNAME $MKLIVE_VERSION"; exit 0 ;;
|
||||
h) usage;;
|
||||
*) usage;;
|
||||
V) version; exit 0;;
|
||||
*) usage;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
|
|
6
mknet.sh
6
mknet.sh
|
@ -27,8 +27,6 @@
|
|||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#-
|
||||
|
||||
. ./version.sh
|
||||
|
||||
readonly PROGNAME=$(basename "$0")
|
||||
readonly REQTOOLS="xbps-install tar"
|
||||
|
||||
|
@ -91,8 +89,8 @@ while getopts "r:c:C:T:K:i:o:k:l:Vh" opt; do
|
|||
C) BOOT_CMDLINE="$OPTARG";;
|
||||
T) BOOT_TITLE="$OPTARG";;
|
||||
S) SPLASH_IMAGE="OPTARG";;
|
||||
V) echo "$PROGNAME $MKLIVE_VERSION"; exit 0 ;;
|
||||
h) usage;;
|
||||
V) version; exit 0;;
|
||||
*) usage;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
# 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"
|
||||
|
@ -88,8 +86,8 @@ while getopts "b:p:k:c:C:r:x:o:nhV" opt; do
|
|||
x) COMPRESSOR_THREADS="$OPTARG" ;;
|
||||
o) FILENAME="$OPTARG" ;;
|
||||
n) COMPRESSION="n" ;;
|
||||
h) usage; exit 0 ;;
|
||||
V) echo "$PROGNAME $MKLIVE_VERSION"; exit 0 ;;
|
||||
V) version; exit 0;;
|
||||
*) usage; exit 0 ;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
# 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"
|
||||
|
@ -85,11 +83,11 @@ while getopts "b:C:c:hr:x:o:V" opt; do
|
|||
b) SYSPKG="$OPTARG";;
|
||||
C) XBPS_CONFFILE="-C $OPTARG";;
|
||||
c) XBPS_CACHEDIR="--cachedir=$OPTARG";;
|
||||
h) usage; exit 0;;
|
||||
r) XBPS_REPOSITORY="$XBPS_REPOSITORY --repository=$OPTARG";;
|
||||
x) COMPRESSOR_THREADS="$OPTARG" ;;
|
||||
o) FILENAME="$OPTARG" ;;
|
||||
V) echo "$PROGNAME $MKLIVE_VERSION"; exit 0;;
|
||||
V) version; exit 0;;
|
||||
*) usage; exit 0;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
if [ -z "${MKLIVE_REV}" ]; then
|
||||
MKLIVE_REV="$(git rev-parse --short HEAD || echo "unknown")"
|
||||
fi
|
||||
MKLIVE_VERSION="0.23-$MKLIVE_REV"
|
Loading…
Reference in New Issue