forked from ublue-os/bluefin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bluefin-cli): Persist State of Cellar
Persist the state of Homebrew's Cellar for ublue-os#768 If the Cellar does not exist. It will be created in the User's home directory. It is then volume mounted into the container making it accessible on any distrobox enter for the container. This also uses the brew_pkgs as a brewfile and brew_script to install/reinstall packages. The brew_script will first try to relink everything in the Cellar. However, just because an item is relink, doesn't mean it will be able to run necessitating a reinstall. Fortunately, any specified reinstalls seem to be quick.
- Loading branch information
Showing
3 changed files
with
33 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,23 @@ | ||
#!/usr/bin/env bash | ||
if [ ! -f /home/linuxbrew/.firstrun ] && [ -n "${BREW_PKGS}" ]; then | ||
touch /home/linuxbrew/.firstrun | ||
|
||
# `brew update-reset` is currently needed | ||
# because somekind of issue with brew | ||
brew update-reset | ||
xargs brew install < "${HOME}"/"${BREW_PKGS}" | ||
# /home/linuxbrew/.linuxbrew/bin/brew update-reset | ||
|
||
# Package Install/Reinstall/Relink | ||
if [ -n "$(ls -A /home/linuxbrew/.linuxbrew/Cellar)" ]; then | ||
echo "Relinking packages. You may still need to reinstall binaries to run them" | ||
/home/linuxbrew/.linuxbrew/bin/brew list -1 | while read line | ||
do | ||
/home/linuxbrew/.linuxbrew/bin/brew unlink $line | ||
/home/linuxbrew/.linuxbrew/bin/brew link $line | ||
done | ||
echo "Reinstalling Packages from brewfile ${HOME}/${BREW_PKGS}" | ||
xargs /home/linuxbrew/.linuxbrew/bin/brew reinstall < "${HOME}"/"${BREW_PKGS}" | ||
else | ||
echo "Installing Packages from brewfile ${HOME}/${BREW_PKGS}" | ||
xargs /home/linuxbrew/.linuxbrew/bin/brew install < "${HOME}"/"${BREW_PKGS}" | ||
fi | ||
fi |