From 1e9f944b714bff2e10cf3e5b002f6436de6471da Mon Sep 17 00:00:00 2001 From: Penelope Gwen Date: Tue, 9 Apr 2024 01:13:52 -0600 Subject: [PATCH] minor tweak --- .../sapphrc/dh_installchangelogs.dch.trimmed | 24 ++++ .../generated/sapphrc/installed-by-dh_install | 22 ++++ .../sapphrc/installed-by-dh_installdocs | 0 debian/changelog | 6 + debian/debhelper-build-stamp | 1 + debian/files | 2 + debian/sapphrc.substvars | 2 + debian/sapphrc/DEBIAN/control | 12 ++ debian/sapphrc/DEBIAN/md5sums | 23 ++++ debian/sapphrc/lib/sapphrc/sapphrc-font | 4 + debian/sapphrc/lib/sapphrc/sapphrc-functions | 107 ++++++++++++++++++ debian/sapphrc/lib/sapphrc/version | 1 + debian/sapphrc/usr/bin/sapphrc | 68 +++++++++++ debian/sapphrc/usr/bin/sapphrc_backup | 21 ++++ debian/sapphrc/usr/bin/sapphrc_exclude | 36 ++++++ debian/sapphrc/usr/bin/sapphrc_include | 36 ++++++ debian/sapphrc/usr/bin/sapphrc_profile | 74 ++++++++++++ debian/sapphrc/usr/bin/sapphrc_push | 11 ++ debian/sapphrc/usr/bin/sapphrc_restore | 19 ++++ debian/sapphrc/usr/bin/sapphrc_setup | 65 +++++++++++ debian/sapphrc/usr/bin/sapphrc_updown | 18 +++ .../usr/share/doc-base/sapphrc.sapphrc | 20 ++++ .../usr/share/doc/sapphrc/README.Debian | 6 + .../usr/share/doc/sapphrc/changelog.gz | Bin 0 -> 280 bytes .../sapphrc/usr/share/doc/sapphrc/copyright | 43 +++++++ debian/sapphrc/usr/share/doc/sapphrc/sapphrc | 6 + .../usr/share/doc/sapphrc/sapphrc_backup | 3 + .../usr/share/doc/sapphrc/sapphrc_exclude | 3 + .../usr/share/doc/sapphrc/sapphrc_include | 1 + .../usr/share/doc/sapphrc/sapphrc_profile | 8 ++ .../usr/share/doc/sapphrc/sapphrc_restore | 3 + .../usr/share/doc/sapphrc/sapphrc_setup | 0 usr/bin/sapphrc_updown | 8 +- 33 files changed, 646 insertions(+), 7 deletions(-) create mode 100644 debian/.debhelper/generated/sapphrc/dh_installchangelogs.dch.trimmed create mode 100644 debian/.debhelper/generated/sapphrc/installed-by-dh_install create mode 100644 debian/.debhelper/generated/sapphrc/installed-by-dh_installdocs create mode 100644 debian/debhelper-build-stamp create mode 100644 debian/files create mode 100644 debian/sapphrc.substvars create mode 100644 debian/sapphrc/DEBIAN/control create mode 100644 debian/sapphrc/DEBIAN/md5sums create mode 100644 debian/sapphrc/lib/sapphrc/sapphrc-font create mode 100644 debian/sapphrc/lib/sapphrc/sapphrc-functions create mode 100644 debian/sapphrc/lib/sapphrc/version create mode 100755 debian/sapphrc/usr/bin/sapphrc create mode 100755 debian/sapphrc/usr/bin/sapphrc_backup create mode 100755 debian/sapphrc/usr/bin/sapphrc_exclude create mode 100755 debian/sapphrc/usr/bin/sapphrc_include create mode 100755 debian/sapphrc/usr/bin/sapphrc_profile create mode 100755 debian/sapphrc/usr/bin/sapphrc_push create mode 100755 debian/sapphrc/usr/bin/sapphrc_restore create mode 100755 debian/sapphrc/usr/bin/sapphrc_setup create mode 100755 debian/sapphrc/usr/bin/sapphrc_updown create mode 100644 debian/sapphrc/usr/share/doc-base/sapphrc.sapphrc create mode 100644 debian/sapphrc/usr/share/doc/sapphrc/README.Debian create mode 100644 debian/sapphrc/usr/share/doc/sapphrc/changelog.gz create mode 100644 debian/sapphrc/usr/share/doc/sapphrc/copyright create mode 100644 debian/sapphrc/usr/share/doc/sapphrc/sapphrc create mode 100644 debian/sapphrc/usr/share/doc/sapphrc/sapphrc_backup create mode 100644 debian/sapphrc/usr/share/doc/sapphrc/sapphrc_exclude create mode 100644 debian/sapphrc/usr/share/doc/sapphrc/sapphrc_include create mode 100644 debian/sapphrc/usr/share/doc/sapphrc/sapphrc_profile create mode 100644 debian/sapphrc/usr/share/doc/sapphrc/sapphrc_restore create mode 100644 debian/sapphrc/usr/share/doc/sapphrc/sapphrc_setup diff --git a/debian/.debhelper/generated/sapphrc/dh_installchangelogs.dch.trimmed b/debian/.debhelper/generated/sapphrc/dh_installchangelogs.dch.trimmed new file mode 100644 index 0000000..8324edd --- /dev/null +++ b/debian/.debhelper/generated/sapphrc/dh_installchangelogs.dch.trimmed @@ -0,0 +1,24 @@ +sapphrc (1.2.1) UNRELEASED; urgency=medium + + * minor tweak + + -- Penelope Gwen Tue, 09 Apr 2024 01:13:11 -0600 + +sapphrc (1.2) unstable; urgency=medium + + * fix some problematic synchronization (hopefully) + + -- Penelope Gwen Tue, 09 Apr 2024 00:34:22 -0600 + +sapphrc (1.1) unstable; urgency=medium + + * fixed broken updown logic + + -- Penelope Gwen Sun, 31 Mar 2024 19:51:41 -0600 + +sapphrc (1.0) unstable; urgency=medium + + * Initial release. + * + + -- Penelope Gwen Fri, 08 Mar 2024 11:49:45 -0700 diff --git a/debian/.debhelper/generated/sapphrc/installed-by-dh_install b/debian/.debhelper/generated/sapphrc/installed-by-dh_install new file mode 100644 index 0000000..6f9a871 --- /dev/null +++ b/debian/.debhelper/generated/sapphrc/installed-by-dh_install @@ -0,0 +1,22 @@ +./lib/sapphrc/sapphrc-font +./lib/sapphrc/sapphrc-functions +./lib/sapphrc/version +./usr/bin/sapphrc +./usr/bin/sapphrc_backup +./usr/bin/sapphrc_exclude +./usr/bin/sapphrc_include +./usr/bin/sapphrc_profile +./usr/bin/sapphrc_push +./usr/bin/sapphrc_restore +./usr/bin/sapphrc_setup +./usr/bin/sapphrc_updown +./usr/share/doc/sapphrc/sapphrc +./usr/share/doc/sapphrc/sapphrc_backup +./usr/share/doc/sapphrc/sapphrc_exclude +./usr/share/doc/sapphrc/sapphrc_include +./usr/share/doc/sapphrc/sapphrc_profile +./usr/share/doc/sapphrc/sapphrc_restore +./usr/share/doc/sapphrc/sapphrc_setup +./lib/sapphrc/sapphrc-font +./lib/sapphrc/sapphrc-functions +./lib/sapphrc/version diff --git a/debian/.debhelper/generated/sapphrc/installed-by-dh_installdocs b/debian/.debhelper/generated/sapphrc/installed-by-dh_installdocs new file mode 100644 index 0000000..e69de29 diff --git a/debian/changelog b/debian/changelog index 079c1c7..8324edd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +sapphrc (1.2.1) UNRELEASED; urgency=medium + + * minor tweak + + -- Penelope Gwen Tue, 09 Apr 2024 01:13:11 -0600 + sapphrc (1.2) unstable; urgency=medium * fix some problematic synchronization (hopefully) diff --git a/debian/debhelper-build-stamp b/debian/debhelper-build-stamp new file mode 100644 index 0000000..b5cd3f7 --- /dev/null +++ b/debian/debhelper-build-stamp @@ -0,0 +1 @@ +sapphrc diff --git a/debian/files b/debian/files new file mode 100644 index 0000000..7b0c657 --- /dev/null +++ b/debian/files @@ -0,0 +1,2 @@ +sapphrc_1.2.1_all.deb unknown optional +sapphrc_1.2.1_arm64.buildinfo unknown optional diff --git a/debian/sapphrc.substvars b/debian/sapphrc.substvars new file mode 100644 index 0000000..978fc8b --- /dev/null +++ b/debian/sapphrc.substvars @@ -0,0 +1,2 @@ +misc:Depends= +misc:Pre-Depends= diff --git a/debian/sapphrc/DEBIAN/control b/debian/sapphrc/DEBIAN/control new file mode 100644 index 0000000..5798920 --- /dev/null +++ b/debian/sapphrc/DEBIAN/control @@ -0,0 +1,12 @@ +Package: sapphrc +Version: 1.2.1 +Architecture: all +Maintainer: Penelope Gwen +Installed-Size: 38 +Depends: git, rsync +Section: unknown +Priority: optional +Multi-Arch: foreign +Homepage: https://github.com/SapphicLinux/sapphrc +Description: dotfiles backup and profiles + diff --git a/debian/sapphrc/DEBIAN/md5sums b/debian/sapphrc/DEBIAN/md5sums new file mode 100644 index 0000000..39eff6d --- /dev/null +++ b/debian/sapphrc/DEBIAN/md5sums @@ -0,0 +1,23 @@ +17a69f82dbf9ed9c31b76223179ff03c lib/sapphrc/sapphrc-font +887e1cbf1c0827b5fcb122929e6ae668 lib/sapphrc/sapphrc-functions +add9573d0bdbe6b511957d850d7ceb80 lib/sapphrc/version +05b21f1a3b14d31456a5a5a5c392ec70 usr/bin/sapphrc +db74088af111223d722b5ad1815a2033 usr/bin/sapphrc_backup +0c8b60289f3b7336ab643d34cb127e85 usr/bin/sapphrc_exclude +dc574a79564e9fb12e31d568eda9856c usr/bin/sapphrc_include +7f38e9ffdb7114bfa220eb5383ba6edb usr/bin/sapphrc_profile +5a2873ae3f9f4c3aed1f7b12fda4e256 usr/bin/sapphrc_push +d15289bfb96359c624467131cc651075 usr/bin/sapphrc_restore +6df947d6a7698409edbbbd69a1d3cd7b usr/bin/sapphrc_setup +50e4fade076af154b41e223d00460ac5 usr/bin/sapphrc_updown +b794024466f2912a3efe1ce2cd87df90 usr/share/doc-base/sapphrc.sapphrc +d1806ef45b08784cf1d9f9c9aa9fc960 usr/share/doc/sapphrc/README.Debian +d4e264c85217cb206c5c55097abf065e usr/share/doc/sapphrc/changelog.gz +7977b1c333dd7894f4814089d33a2ec7 usr/share/doc/sapphrc/copyright +3c7964357e6b03a50f25f94da5c2892e usr/share/doc/sapphrc/sapphrc +0beb8e7fb8106891c2060ad505d5fa18 usr/share/doc/sapphrc/sapphrc_backup +d7120b1b933403e4c39102cf80e39189 usr/share/doc/sapphrc/sapphrc_exclude +47be009181fb3492c6d5e5469753f6af usr/share/doc/sapphrc/sapphrc_include +9b1e4607b52d1def509eef8de3a3ea7c usr/share/doc/sapphrc/sapphrc_profile +654b2d496019b0d43973f2fea7db5c15 usr/share/doc/sapphrc/sapphrc_restore +d41d8cd98f00b204e9800998ecf8427e usr/share/doc/sapphrc/sapphrc_setup diff --git a/debian/sapphrc/lib/sapphrc/sapphrc-font b/debian/sapphrc/lib/sapphrc/sapphrc-font new file mode 100644 index 0000000..6d046f4 --- /dev/null +++ b/debian/sapphrc/lib/sapphrc/sapphrc-font @@ -0,0 +1,4 @@ +#!/bin/bash + +bold=$(tput bold) +normal=$(tput sgr0) diff --git a/debian/sapphrc/lib/sapphrc/sapphrc-functions b/debian/sapphrc/lib/sapphrc/sapphrc-functions new file mode 100644 index 0000000..911e6c1 --- /dev/null +++ b/debian/sapphrc/lib/sapphrc/sapphrc-functions @@ -0,0 +1,107 @@ +#!/bin/bash + +sapphrc_config="$HOME/.config/sapphrc" + +usage(){ + echo -n "sapphrc " + cat /usr/share/doc/sapphrc/$(basename $0) +} + +check_name(){ + if [ -z "${1}" ];then + $2 || echo "Profile name cannot be blank" + return 0 + fi + if [[ ! "$1" =~ ^[a-zA-Z0-9_-]+$ ]];then + $2 || echo "Profile name can only contain numbers, letters, hyphens, and underscores" + return 0 + fi + return 1 +} + +validate_profile(){ + profile_name="${1}" + first_check=true + while check_name "${profile_name}" "$first_check";do + first_check=false + if [ "$COMMAND" == "create" ];then + read -p "Profile Name: " profile_name + else + backups=( "${sapphrc_config}/backups/"* ) + echo "$backups" + if [ -d "${backups[0]}" ];then + select d in $(ls "${sapphrc_config}/backups/");do test -n "$d" && break; echo ">>> Invalid Selection"; done + profile_name="$d" + else + echo "No backups exist!" + exit 1 + fi + fi + done + sapphrc_profile="${sapphrc_config}/backups/${profile_name}" + sapphrc_profile_rcdir="${sapphrc_profile}/home/.sapphrc" + sapphrc_profile_rc="${sapphrc_profile_rcdir}/${profile_name}" +} + +inex_func(){ + validate_profile "${profile_name}" + [ ${#@} -eq 0 ] && echo "No files selected" && exit 1 + for file in "$@";do + fullpath=$(realpath "${file}") + if ! [[ "$fullpath" =~ ^"$HOME/".* ]];then + echo "file not in home dir" + break + fi + if ! [[ -d "$file" || -f "$file" ]];then + echo "file does not exist" + break + fi + filelist+=(${fullpath#$HOME/}) + done + + for e in ${filelist[@]};do + echo $e + done + + read -p "${bold}Add the listed files/directories to profile '${profile_name}'?${normal} (Y/n)" yn + if ! [[ "${yn}" =~ ^([nN][oO]|[nN])$ ]];then + for e in ${filelist[@]};do + if grep -q ^"${e}"$ "${sapphrc_config}/backups/${profile_name}/${inex}";then + echo "already in file" + else + echo $e|tee -a "${sapphrc_config}/backups/${profile_name}/${inex}" >/dev/null + fi + done + fi +} + +inex_rm(){ + validate_profile "${profile_name}" + i=0 + while read line; do + rmfiles+=("$i");i=$(($i+1)) + rmfiles+=("$line") + rmfiles+=("$line") + done < "${sapphrc_config}/backups/${profile_name}/${inex}" + [ ${#rmfiles[@]} -eq 0 ] && echo "No files in list" && exit 1 + choices=($(dialog --checklist --output-fd 1 "Select options:" 0 0 0 "${rmfiles[@]}")) + if [ $? -ne 0 ]; then + echo "User canceled." + exit 1 + fi + + for choice in "${choices[@]}"; do + rmlines="${rmlines}$((${choice}+1))d;" + done + sed -i "${rmlines}" "${sapphrc_config}/backups/${profile_name}/${inex}" + echo "Removed ${#choices[@]} paths from ${profile_name} ${inex} list" +} + +validate_backupdir(){ + if [ -d "$HOME/.config/sapphrc/backups/.git" ];then + echo "backup folder looks good!" + else + echo "git repo not initialized! Something's gone wrong" + exit 1 + fi +} diff --git a/debian/sapphrc/lib/sapphrc/version b/debian/sapphrc/lib/sapphrc/version new file mode 100644 index 0000000..5625e59 --- /dev/null +++ b/debian/sapphrc/lib/sapphrc/version @@ -0,0 +1 @@ +1.2 diff --git a/debian/sapphrc/usr/bin/sapphrc b/debian/sapphrc/usr/bin/sapphrc new file mode 100755 index 0000000..4d85c74 --- /dev/null +++ b/debian/sapphrc/usr/bin/sapphrc @@ -0,0 +1,68 @@ +#!/bin/bash + +COMMAND="${1}" +VERSION=$(cat /lib/sapphrc/version) + +setup() { + sapphrc_setup $@ +} + +profile() { + sapphrc_profile $@ +} + +backup() { + sapphrc_backup $@ +} + +restore() { + sapphrc_restore $@ +} + +updown() { + sapphrc_updown $@ +} + +push() { + sapphrc_push $@ +} + +include(){ + sapphrc_include $@ +} + +exclude(){ + sapphrc_exclude $@ +} + +usage() { + echo "Sapphic Package Manager v${VERSION}" + cat /usr/share/doc/sapphrc/sapphrc + sed -e 's/^/ /' /usr/share/doc/sapphrc/sapphrc_setup + sed -e 's/^/ /' /usr/share/doc/sapphrc/sapphrc_profile + sed -e 's/^/ /' /usr/share/doc/sapphrc/sapphrc_backup + sed -e 's/^/ /' /usr/share/doc/sapphrc/sapphrc_restore +} + +case $COMMAND in + setup|profile|backup|restore|updown|push|include|exclude ) + shift 1;;& + setup ) + setup $@;; + profile ) + profile $@;; + backup ) + backup $@;; + restore ) + restore $@;; + updown ) + updown $@;; + push ) + push $@;; + include ) + include $@;; + exclude ) + exclude $@;; + *|usage ) + usage;; +esac diff --git a/debian/sapphrc/usr/bin/sapphrc_backup b/debian/sapphrc/usr/bin/sapphrc_backup new file mode 100755 index 0000000..9f65b1a --- /dev/null +++ b/debian/sapphrc/usr/bin/sapphrc_backup @@ -0,0 +1,21 @@ +#!/bin/bash + +source /lib/sapphrc/sapphrc-functions +source /lib/sapphrc/sapphrc-font +validate_backupdir + +sapphrc_config="$HOME/.config/sapphrc" + +cat "${sapphrc_config}/active_profiles" | while read profile_name +do + backup_homedir="$sapphrc_config/backups/${profile_name}/home" + include_list="$sapphrc_config/backups/${profile_name}/include" + exclude_list="$sapphrc_config/backups/${profile_name}/exclude" + echo "${include_list}" + echo "${exclude_list}" + echo "${HOME}" + echo "${backup_homedir}" + rsync -arvSH --files-from="${include_list}" --exclude-from="${exclude_list}" --exclude '.config/sapphrc/' "${HOME}" "${backup_homedir}" +done + +find ${HOME}/.config/sapphrc/backups/ -name *.swp -type f -exec rm {} \; diff --git a/debian/sapphrc/usr/bin/sapphrc_exclude b/debian/sapphrc/usr/bin/sapphrc_exclude new file mode 100755 index 0000000..861073a --- /dev/null +++ b/debian/sapphrc/usr/bin/sapphrc_exclude @@ -0,0 +1,36 @@ +#!/bin/bash + +COMMAND=$1 + +source /lib/sapphrc/sapphrc-functions +source /lib/sapphrc/sapphrc-font + +inex="exclude" + +case $COMMAND in + add|remove ) + shift 1;;& + add ) + action="add";; + remove ) + action="remove";; + * ) + usage + exit 1;; +esac + +while getopts 'hp:' flag; do + case "${flag}" in + p ) echo "${OPTARG}";shift 2;profile_name="${OPTARG}";;& + h ) usage;exit 1 ;; + esac +done + +validate_backupdir + +case "${action}" in + add ) + inex_func "$@";; + remove ) + inex_rm "$@";; +esac diff --git a/debian/sapphrc/usr/bin/sapphrc_include b/debian/sapphrc/usr/bin/sapphrc_include new file mode 100755 index 0000000..7fab557 --- /dev/null +++ b/debian/sapphrc/usr/bin/sapphrc_include @@ -0,0 +1,36 @@ +#!/bin/bash + +COMMAND=$1 + +source /lib/sapphrc/sapphrc-functions +source /lib/sapphrc/sapphrc-font + +inex="include" + +case $COMMAND in + add|remove ) + shift 1;;& + add ) + action="add";; + remove ) + action="remove";; + * ) + usage + exit 1;; +esac + +while getopts 'hp:' flag; do + case "${flag}" in + p ) echo "${OPTARG}";shift 2;profile_name="${OPTARG}";;& + h ) usage;exit 1 ;; + esac +done + +validate_backupdir + +case "${action}" in + add ) + inex_func "$@";; + remove ) + inex_rm "$@";; +esac diff --git a/debian/sapphrc/usr/bin/sapphrc_profile b/debian/sapphrc/usr/bin/sapphrc_profile new file mode 100755 index 0000000..f077143 --- /dev/null +++ b/debian/sapphrc/usr/bin/sapphrc_profile @@ -0,0 +1,74 @@ +#!/bin/bash + +source /lib/sapphrc/sapphrc-functions +source /lib/sapphrc/sapphrc-font + +COMMAND="${1}" + +sapphrc_config="${HOME}/.config/sapphrc" + +create(){ + mkdir -p "${sapphrc_profile_rcdir}" + touch "${sapphrc_profile}/"{include,exclude} + echo '#!/bin/bash'|tee "${sapphrc_profile_rc}" > /dev/null + echo ".sapphrc/${profile_name}"|tee "${sapphrc_profile}/include" > /dev/null + chmod +x "${sapphrc_profile_rc}" + echo "Successfully created '${profile_name}'" + join "${profile_name}" +} + +remove(){ + echo "WARNING: really remove profile '${profile_name}'?" + echo "~${sapphrc_profile#$HOME} and all its contents will be deleted!" + read -p "Confirm removal (y/N): " confirm_remove + if [[ "${confirm_remove}" =~ ^([yY][eE][sS]|[yY])$ ]];then + leave + echo "removing '${profile_name}'" + rm -r "${sapphrc_profile}" + echo "Profile '${profile_name}' has been removed. Be sure to leave the profile on other machines/accounts to avoid synchronization issues." + fi +} + +join(){ + if grep -q ^"${profile_name}"$ "${sapphrc_config}/active_profiles";then + echo "Already joined ${profile_name}, nothing to do." + else + echo "${profile_name}"|tee -a "${sapphrc_config}/active_profiles" > /dev/null + echo "Successfully joined '${profile_name}'!" + fi +} + +leave(){ + if grep -q ^"${profile_name}"$ "${sapphrc_config}/active_profiles";then + sed -i '/^'"${profile_name}"'$/d' "${sapphrc_config}/active_profiles" + [ -e "${HOME}/.sapphrc/${profile_name}" ] && rm "${HOME}/.sapphrc/${profile_name}" + echo "Successfully left '${profile_name}'!" + else + echo "You have not joined '${profile_name}', nothing to do." + fi +} + +list(){ + echo "${bold}Active profiles:${normal}" + cat "${sapphrc_config}/active_profiles" + echo "${bold}Available profiles:${normal}" + ls "${sapphrc_config}/backups/" | cat +} + +case $COMMAND in + create|remove|join|leave ) + validate_backupdir;shift 1; + validate_profile $@;;& + create ) + create $@;; + remove ) + remove $@;; + join ) + join $@;; + leave ) + leave $@;; + list ) + list;; + *|usage ) + usage;; +esac diff --git a/debian/sapphrc/usr/bin/sapphrc_push b/debian/sapphrc/usr/bin/sapphrc_push new file mode 100755 index 0000000..444f5fc --- /dev/null +++ b/debian/sapphrc/usr/bin/sapphrc_push @@ -0,0 +1,11 @@ +#!/bin/bash + +source /lib/sapphrc/sapphrc-functions +source /lib/sapphrc/sapphrc-font +validate_backupdir + +cd "$HOME/.config/sapphrc/backups" +git add .; +git add -u; +git commit -m "New backup `date +'%Y-%m-%d %H:%M:%S'`"; +git push origin main diff --git a/debian/sapphrc/usr/bin/sapphrc_restore b/debian/sapphrc/usr/bin/sapphrc_restore new file mode 100755 index 0000000..d97e318 --- /dev/null +++ b/debian/sapphrc/usr/bin/sapphrc_restore @@ -0,0 +1,19 @@ +#!/bin/bash + +source /lib/sapphrc/sapphrc-functions +source /lib/sapphrc/sapphrc-font +validate_backupdir + +cd "$HOME/.config/sapphrc/backups" +git config pull.rebase false +git pull --no-edit + +sapphrc_config="$HOME/.config/sapphrc" + +cat "${sapphrc_config}/active_profiles" | while read profile_name +do + backup_homedir="$sapphrc_config/backups/${profile_name}/home" + include_list="$sapphrc_config/backups/${profile_name}/include" + exclude_list="$sapphrc_config/backups/${profile_name}/exclude" + rsync -arvSH --files-from="${include_list}" --exclude-from="${exclude_list}" --exclude '.config/sapphrc/' "${backup_homedir}" "${HOME}" +done diff --git a/debian/sapphrc/usr/bin/sapphrc_setup b/debian/sapphrc/usr/bin/sapphrc_setup new file mode 100755 index 0000000..bfe2257 --- /dev/null +++ b/debian/sapphrc/usr/bin/sapphrc_setup @@ -0,0 +1,65 @@ +#!/bin/bash + +sapphrc_config="$HOME/.config/sapphrc" +if [ -f "${aspphic_config}/backups/.init_complete" ];then + echo "already setup" + exit 0 +fi + +mkdir -p "${sapphrc_config}" +mkdir -p "${HOME}/.sapphrc" + +while true;do + read -p "pull from an existing backup repo? (y/n) " gitrepo_exists + case $gitrepo_exists in + [Yy] ) + read -p "Enter YOUR git repo url: " git_url + git clone "${git_url}" "${sapphrc_config}/backups" + touch "${sapphrc_config}/backups/.init_complete" + backup_count="0" + backups=($(ls "${sapphrc_config}/backups/")) + for b in ${backups[@]};do + [ -d "${sapphrc_config}/backups/${b}" ] && backup_count=$(($backup_count+1)) + done + + if [[ backup_count -gt 0 ]];then + read -p "Found existing profile(s). Join one? (Y/n) " yn + [[ "${yn}" =~ ^([nN][oO]|[nN])$ ]] || sapphrc profile join + else + sapphrc profile create default + fi + break + ;; + [Nn] ) + mkdir -p "${sapphrc_config}/backups" + cd "${sapphrc_config}/backups" + git init + touch "${sapphrc_config}/backups/.init_complete" + git add . + git commit -m "first commit" + git branch -M main + read -p "Enter YOUR git repo url: " git_url + git remote add origin "${git_url}" + git push -u origin main + break + ;; + esac +done + +##link ~/.sapphrc/* files to .bashrc +sapphrc_bashrc="$(awk '/.sapphrc/,/done/' ~/.bashrc)" +if [[ "${#sapphrc_bashrc}" -eq 0 ]];then + echo "for file in ~/.sapphrc/* ; do" >> $HOME/.bashrc + echo " if [ -f \""'$file'"\" ] ; then" >> $HOME/.bashrc + echo " source \""'$file'"\"" >> $HOME/.bashrc + echo " fi" >> $HOME/.bashrc + echo "done" >> $HOME/.bashrc +fi + +if [ ! "$(crontab -l | grep -i 'sapphrc_updown')" ];then + mkdir -p $HOME/.cache/sapphrc/ + crontab -l > $HOME/.cache/sapphrc/crontab + echo "*/15 * * * * sapphrc_updown" >> $HOME/.cache/sapphrc/crontab + crontab $HOME/.cache/sapphrc/crontab + rm $HOME/.cache/sapphrc/crontab +fi diff --git a/debian/sapphrc/usr/bin/sapphrc_updown b/debian/sapphrc/usr/bin/sapphrc_updown new file mode 100755 index 0000000..8761f2e --- /dev/null +++ b/debian/sapphrc/usr/bin/sapphrc_updown @@ -0,0 +1,18 @@ +#!/bin/bash + +source /lib/sapphrc/sapphrc-functions +source /lib/sapphrc/sapphrc-font +validate_backupdir + +cd "$HOME/.config/sapphrc/backups" +sapphrc_backup +gs="$(git status | grep -i 'modified')" +git fetch origin +reslog=$(git log HEAD..origin/main --oneline) + +if [[ "${reslog}" == "" ]];then +#remote changes exist + sapphrc_restore +fi + sapphrc_push +exit diff --git a/debian/sapphrc/usr/share/doc-base/sapphrc.sapphrc b/debian/sapphrc/usr/share/doc-base/sapphrc.sapphrc new file mode 100644 index 0000000..b657b32 --- /dev/null +++ b/debian/sapphrc/usr/share/doc-base/sapphrc.sapphrc @@ -0,0 +1,20 @@ +Document: sapphrc +Title: Debian sapphrc Manual +Author: +Abstract: This manual describes what sapphrc is + and how it can be used to + manage online manuals on Debian systems. +Section: unknown + +Format: debiandoc-sgml +Files: /usr/share/doc/sapphrc/sapphrc.sgml.gz + +Format: postscript +Files: /usr/share/doc/sapphrc/sapphrc.ps.gz + +Format: text +Files: /usr/share/doc/sapphrc/sapphrc.text.gz + +Format: HTML +Index: /usr/share/doc/sapphrc/html/index.html +Files: /usr/share/doc/sapphrc/html/*.html diff --git a/debian/sapphrc/usr/share/doc/sapphrc/README.Debian b/debian/sapphrc/usr/share/doc/sapphrc/README.Debian new file mode 100644 index 0000000..83764bf --- /dev/null +++ b/debian/sapphrc/usr/share/doc/sapphrc/README.Debian @@ -0,0 +1,6 @@ +sapphrc for Debian +----------------- + + + + -- Penelope Gwen Fri, 08 Mar 2024 11:49:45 -0700 diff --git a/debian/sapphrc/usr/share/doc/sapphrc/changelog.gz b/debian/sapphrc/usr/share/doc/sapphrc/changelog.gz new file mode 100644 index 0000000000000000000000000000000000000000..7ca13b37ed713b280017d935d025e1d84dc5076b GIT binary patch literal 280 zcmV+z0q6c7iwFP!000021EtW-N&_(z1>pTW#aXt}4#{+?HvVA2DuNZU`T*(lwhhf6 z$%I;;-XJczC^+Eq9xj}Z6Q%dt(4fc5s^ooqyu8hxXVb;({t78<$To)?Lo1a`Q2=K! z%DRAdPjZ)o;SjH6Njpz?+>^z1Oy0ZD-g&n%&Xk63f%ilMunDFUa+vU3CS8i{i-9|N?Ig4Zm7;((yFNaUWn2Y+WQ@#O=zJKvV0ssIP@P +Upstream-Name: sapphrc +Upstream-Contact: + +Files: + * +Copyright: + + +License: GPL-3.0+ + +Files: + debian/* +Copyright: + 2024 Penelope Gwen +License: GPL-3.0+ + +License: GPL-3.0+ + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + . + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program. If not, see . +Comment: + On Debian systems, the complete text of the GNU General + Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". + +# Please also look if there are files or directories which have a +# different copyright/license attached and list them here. +# Please avoid picking licenses with terms that are more restrictive than the +# packaged work, as it may make Debian's contributions unacceptable upstream. +# +# If you need, there are some extra license texts available in two places: +# /usr/share/debhelper/dh_make/licenses/ +# /usr/share/common-licenses/ diff --git a/debian/sapphrc/usr/share/doc/sapphrc/sapphrc b/debian/sapphrc/usr/share/doc/sapphrc/sapphrc new file mode 100644 index 0000000..1330ddd --- /dev/null +++ b/debian/sapphrc/usr/share/doc/sapphrc/sapphrc @@ -0,0 +1,6 @@ +Usage: spm command [options] + +Sapphrc is a dotfiles manager with support for multiple profile and git synchonization + +Commands: + usage: Print this dialogue diff --git a/debian/sapphrc/usr/share/doc/sapphrc/sapphrc_backup b/debian/sapphrc/usr/share/doc/sapphrc/sapphrc_backup new file mode 100644 index 0000000..78d3ebf --- /dev/null +++ b/debian/sapphrc/usr/share/doc/sapphrc/sapphrc_backup @@ -0,0 +1,3 @@ +backup: update profile based on current configuration + usage: + sapphrc backup diff --git a/debian/sapphrc/usr/share/doc/sapphrc/sapphrc_exclude b/debian/sapphrc/usr/share/doc/sapphrc/sapphrc_exclude new file mode 100644 index 0000000..e0ea58b --- /dev/null +++ b/debian/sapphrc/usr/share/doc/sapphrc/sapphrc_exclude @@ -0,0 +1,3 @@ +backup: update profile based on current configuration + usage: + sapphrc exclude [action] (-p ) diff --git a/debian/sapphrc/usr/share/doc/sapphrc/sapphrc_include b/debian/sapphrc/usr/share/doc/sapphrc/sapphrc_include new file mode 100644 index 0000000..a1a869c --- /dev/null +++ b/debian/sapphrc/usr/share/doc/sapphrc/sapphrc_include @@ -0,0 +1 @@ +include diff --git a/debian/sapphrc/usr/share/doc/sapphrc/sapphrc_profile b/debian/sapphrc/usr/share/doc/sapphrc/sapphrc_profile new file mode 100644 index 0000000..f9f7193 --- /dev/null +++ b/debian/sapphrc/usr/share/doc/sapphrc/sapphrc_profile @@ -0,0 +1,8 @@ +profile: manage sapphrc profiles + usage: + sapphrc profile [action] (profile) + actions: + create: creates a new sapphrc profile and joins it + remove: leaves and deletes an existing sapphrc profile + join: joins an existing sapphrc profile + leave: leaves an existing sapphrc profile diff --git a/debian/sapphrc/usr/share/doc/sapphrc/sapphrc_restore b/debian/sapphrc/usr/share/doc/sapphrc/sapphrc_restore new file mode 100644 index 0000000..fd3b8de --- /dev/null +++ b/debian/sapphrc/usr/share/doc/sapphrc/sapphrc_restore @@ -0,0 +1,3 @@ +backup: update current configuration from available profile updates + usage: + sapphrc restore diff --git a/debian/sapphrc/usr/share/doc/sapphrc/sapphrc_setup b/debian/sapphrc/usr/share/doc/sapphrc/sapphrc_setup new file mode 100644 index 0000000..e69de29 diff --git a/usr/bin/sapphrc_updown b/usr/bin/sapphrc_updown index 625e11e..8761f2e 100755 --- a/usr/bin/sapphrc_updown +++ b/usr/bin/sapphrc_updown @@ -10,15 +10,9 @@ gs="$(git status | grep -i 'modified')" git fetch origin reslog=$(git log HEAD..origin/main --oneline) -echo $gs -echo " " -echo $reslog - if [[ "${reslog}" == "" ]];then #remote changes exist sapphrc_restore -elif [[ $gs == *"modified"* ]];then -#local changes exist - sapphrc_push fi + sapphrc_push exit