diff --git a/Makefile b/Makefile index d70117d..76cbf02 100755 --- a/Makefile +++ b/Makefile @@ -38,11 +38,14 @@ all: build build: deps $(GO) build -ldflags "-X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY} -X main.Version=${SEMVAR_VERSION}" -o bin/${BIN} package: build - cp grub-mkconfig-script bin/ - tar cvzpf bin/darch-${GOARCH}.tar.gz -C bin darch grub-mkconfig-script + mkdir -p bin/etc/grub.d/ + mkdir -p bin/usr/bin/ + cp grub-mkconfig-script bin/etc/grub.d/60_darch + cp bin/darch bin/usr/bin/darch + tar cvzpf bin/darch-${GOARCH}.tar.gz -C bin usr/bin/darch etc/grub.d/60_darch clean: $(GO) clean -i $(PKG) - rm -r bin/ + rm -r -f bin/ deps: $(GO) get -d $(PKG) $(GO) install $(DEPS) diff --git a/grub-mkconfig-script b/grub-mkconfig-script index 33c56b0..fc4ca4c 100755 --- a/grub-mkconfig-script +++ b/grub-mkconfig-script @@ -18,9 +18,10 @@ for i in $(find /boot/darch/ -type d); do linux_root_device_thisversion="${LINUX_ROOT_DEVICE}" initrd=initramfs-linux.img + darch_source_block_device=`df --output=source $i | tail -1` darch_source_uuid=`blkid $darch_source_block_device | sed -n 's/.* UUID=\"\([^\"]*\)\".*/\1/p'` darch_source_absolute=`echo ${i#$(df $i --output=target | tail -1)}` darch_cmdline="darchdir=UUID=$darch_source_uuid:$darch_source_absolute" - linux_entry "Darch - $image_name" "${version}" "simple" "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} $darch_cmdline" + linux_entry "Darch - $rel_dirname" "${version}" "simple" "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} $darch_cmdline" done \ No newline at end of file diff --git a/scripts/arch/PKGBUILD-template b/scripts/arch/PKGBUILD-template index 69e82c9..e545bd5 100644 --- a/scripts/arch/PKGBUILD-template +++ b/scripts/arch/PKGBUILD-template @@ -24,8 +24,6 @@ md5sums=() noextract=() validpgpkeys=() package() { - install -d $pkgdir/usr/bin - install darch $pkgdir/usr/bin - install -d $pkgdir/etc/grub.d/ - install grub-mkconfig-script $pkgdir/etc/grub.d/60_darch + # The tarball has all the directories setup correctly. + cp * -r $pkgdir } diff --git a/scripts/install b/scripts/install new file mode 100755 index 0000000..2969255 --- /dev/null +++ b/scripts/install @@ -0,0 +1,40 @@ +#!/bin/bash +set -e + +if [[ ! $EUID -eq 0 ]]; then + echo "This script should only be run as root user." + exit 1 +fi + + +if [ -z "$DARCH_TAG" ]; then + DARCH_TAG=`curl https://api.github.com/repos/pauldotknopf/darch/releases/latest -s | jq .tag_name -r` + if [ -z "$DARCH_TAG" ]; then + echo Could not get the latest tag from GitHub. + exit 1 + fi +fi + +echo "Installing tag: $DARCH_TAG" + +echo "Checking for previously installed Darch..." + +if [ -f /etc/grub.d/60_darch ]; then + echo "Found /etc/grub.d/60_darch, removing..." + rm /etc/grub.d/60_darch +fi + +if [ -f /usr/bin/darch ]; then + echo "Found /usr/bin/darch, removing..." + rm /usr/bin/darch +fi + +echo "Downloading and extracting darch..." + +wget -O- -q https://github.com/pauldotknopf/darch/releases/download/$DARCH_TAG/darch-amd64.tar.gz | tar xpz -C / + +echo "Verifying installation..." + +darch version + +echo "Darch is now installed!" \ No newline at end of file