Skip to content

Commit

Permalink
Create build script for Arch
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-eriksson committed Jan 6, 2021
1 parent be1330d commit 9b5824c
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
35 changes: 35 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,40 @@ build_tar() {
cd $original_dir
}

build_arch() {
root="$1"
target="$2"
version="$3"
conf_files="$4"
launcher="$5"

target_dir="$target/blubee_${version}_all"
mkdir $target_dir

cp $conf_files "$target_dir"
cp $launcher "$target_dir"

set_info_version "$version" "$target_dir"

files="$conf_files $launcher"
sha256sums=""
for file in $files; do
[ -f "$target_dir/$file" ] || continue
sha256sums="${sha256sums} '$(sha256sum "$target_dir/$file" | cut -d' ' -f1)'"
done
sha256sums="${sha256sums#?}"

arch_dir="package/arch"
sed -e "s/pkgver=-/pkgver=$version/" \
-e "s/sha256sums=(-)/sha256sums=($sha256sums)/" \
-e "s/source=(-)/source=($files)/" \
$arch_dir/PKGBUILD > $target_dir/PKGBUILD
sed -i -e "/sha256sums=(/ s/ /\n /g" \
-e "/source=(/ s/ /\n /g" $target_dir/PKGBUILD

cp $arch_dir/blubee.install $target_dir
}

config_files="blubee backup.sh restore.sh json_utils.sh string_utils.sh file_utils.sh blubee.info blubee.conf"
launch_file="launcher"
dirs=$(create_file_tree "$package_root" "$build_version" "$config_files" "$launch_file")
Expand All @@ -78,4 +112,5 @@ set_info_version "$build_version" "$conf_dir"

build_debian "$package_root" "$target_root" "$build_version"
build_tar "$package_root" "$target_root" "$build_version"
build_arch "$package_root" "$target_root" "$build_version" "$config_files" "$launch_file"

30 changes: 30 additions & 0 deletions package/arch/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Maintainer: Christian Eriksson <christian.eriksson@live.se>

pkgname=blubee
pkgver=-
pkgrel=1
pkgdesc="Simple json based backup utility"
arch=('any')
url="https://github.com/christian-eriksson/blubee"
license=('GPL3')
depends=('rsync' 'jq')
backup=('etc/blubee/blubee.conf')
options=('!emptydirs')
install='blubee.install'
source=(-)

sha256sums=(-)

package() {
conf_dir="${pkgdir}/etc/blubee"
install -D -m 755 "${srcdir}/blubee" "$conf_dir/blubee"
install -D -m 755 "${srcdir}/backup.sh" "$conf_dir/backup.sh"
install -D -m 755 "${srcdir}/restore.sh" "$conf_dir/restore.sh"
install -D -m 755 "${srcdir}/json_utils.sh" "$conf_dir/json_utils.sh"
install -D -m 755 "${srcdir}/string_utils.sh" "$conf_dir/string_utils.sh"
install -D -m 755 "${srcdir}/file_utils.sh" "$conf_dir/file_utils.sh"
install -D -m 644 "${srcdir}/blubee.conf" "$conf_dir/blubee.conf"
install -D -m 644 "${srcdir}/blubee.info" "$conf_dir/blubee.info"
install -D -m 755 "${srcdir}/launcher" "${pkgdir}/usr/local/bin/blubee"
}

16 changes: 16 additions & 0 deletions package/arch/blubee.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
post_install() {
restore_backup_path=/var/lib/blubee/backups

[ ! -e $restore_backup_path ] && mkdir -p $restore_backup_path

exit 0
}

post_remove() {
restore_backup_path=/var/lib/blubee

[ -e $restore_backup_path ] && rm -r $restore_backup_path

exit 0
}

0 comments on commit 9b5824c

Please sign in to comment.