Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
- Installation now copies the whole directory (will separately update PKGBUILD)
- A fix to rollback

Part of Issue #32
  • Loading branch information
hirak99 committed May 8, 2024
1 parent 38b5a44 commit d918107
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
13 changes: 9 additions & 4 deletions scripts/install-to-dest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ cd $MY_PATH/..
readonly PKGNAME=yabsnap

# This mirrors PKGBUILD with slight modifications.
pushd src/
tar -cf - \
$(find -type f -not -name "*_test.py" \( -name "*.py" -o -name "*.conf" \)) |
tar -xf - -C "$PKGDIR"/usr/share/"$PKGNAME"/
pushd "$PKGDIR"/usr/share/"$PKGNAME"/
chown -R root:root .
chmod -R u=rwX,go=rX .
popd
popd

for file in $(ls -A src/code/*.{py,conf} | grep -v "_test.py")
do
install -Dm 644 "$file" "$PKGDIR"/usr/share/"$PKGNAME"/code/"${file##*/}"
done
cd artifacts
install -Dm 644 services/"$PKGNAME".{service,timer} -t "$PKGDIR"/usr/lib/systemd/system/
install -Dm 664 pacman/*.hook -t "$PKGDIR"/usr/share/libalpm/hooks/
Expand Down
24 changes: 10 additions & 14 deletions src/code/rollbacker.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import collections

from . import configs
from . import snap_operator
from .mechanisms import snap_mechanisms
Expand All @@ -20,20 +22,14 @@


def rollback(configs_iter: Iterable[configs.Config], path_suffix: str):
source_dests: list[tuple[str, str]] = []
source_dests_by_snaptype: dict[snap_mechanisms.SnapType, list[tuple[str, str]]] = (
collections.defaultdict(list)
)
for config in configs_iter:
snap = snap_operator.find_target(config, path_suffix)
if snap:
if snap.metadata.snap_type == snap_mechanisms.SnapType.BTRFS:
source_dests.append((snap.metadata.source, snap.target))
else:
raise RuntimeError(
f"Cannot rollback snap of type {snap.metadata.snap_type} yet"
)
print("\n".join(_rollback_btrfs_snapshots(source_dests)))


def _rollback_btrfs_snapshots(source_dests: list[tuple[str, str]]) -> list[str]:
return snap_mechanisms.get(snap_mechanisms.SnapType.BTRFS).rollback_gen(
source_dests
)
source_dests_by_snaptype[config.snap_type].append(
(snap.metadata.source, snap.target)
)
for snap_type, source_dests in sorted(source_dests_by_snaptype.items()):
print("\n".join(snap_mechanisms.get(snap_type).rollback_gen(source_dests)))

0 comments on commit d918107

Please sign in to comment.