Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore packages #13

Open
opensourcestough opened this issue May 21, 2023 · 6 comments
Open

Restore packages #13

opensourcestough opened this issue May 21, 2023 · 6 comments

Comments

@opensourcestough
Copy link

I am trying to restore the packages. I see how on line 157 get the restore file. Would you be able to add the package list as well?

@MrAlpha786
Copy link
Owner

I don't understand, add package list to what? Please be more clear.

@opensourcestough
Copy link
Author

opensourcestough commented May 21, 2023

Sorry, pkglist.out (the list of installed packages). I see on line 157 you accept the filename for the restore file without the package list and corresponding command.

@MrAlpha786
Copy link
Owner

Will you please quote the particular code snippet you referring to? And please elaborate the issue.

@opensourcestough
Copy link
Author

Will you please quote the particular code snippet you referring to? And please elaborate the issue.

function list_packages () {

Grep 'histfile' and create two arrays

one of installed pkgs and one of removed pkgs

while IFS= read -r line; do
line=${line/-y/}
if [[ "$line" =~ ' install ' ]]; then
installed+=(${line##* install })
else
removed+=(${line##* remove })
removed+=(${line##* purge })
fi
done < <(grep -E ' install | remove | purge ' ${TERBR_HISTFILE})

For every removed pkg, if it's also in installed pkgs

remove it from installed pkgs

for pkg in "${removed[@]}";do
for i in "${!installed[@]}";do
if [[ "${installed[$i]}" == "$pkg" ]]; then
unset installed[$i]
break
fi
done
done

Remove any duplicates

And put them in TERBR_PKGS

declare -A tmp_array

for i in "${installed[@]}"; do
[[ $i ]] &amp;&amp; IFS=" " tmp_array["${i:- }"]=1
done

echo -e "${G} Saving installed packages to '${TERBR_PKGS}'\n"

printf '%s\n' "${!tmp_array[@]}" > $TERBR_PKGS

if [ -n "${TERBR_VERBOSE}" ];then
echo -e "$G [*] Installed Packages $N\n"
nl "${TERBR_PKGS}"
fi
}

With that, you create the installer package list. In the restore process, it is never used on its own or during the file restoration.

@MrAlpha786
Copy link
Owner

Script don't restore packages because many packages may need configuration during installation. There can be many different test cases. So, it is better to just save installed packages in a list.

@opensourcestough
Copy link
Author

I feel adding it as an option would be valuable. I used apt-get install -y $(awk '{print $1}' "/storage/emulated/0/pkgliet.out" ) and it allowed approving or examining differences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants