Skip to content

Instantly share code, notes, and snippets.

@InvisibleRasta
Created November 18, 2018 10:33
Show Gist options
  • Save InvisibleRasta/031b7a22cb3a79bb4f21f6d94c7982c1 to your computer and use it in GitHub Desktop.
Save InvisibleRasta/031b7a22cb3a79bb4f21f6d94c7982c1 to your computer and use it in GitHub Desktop.
Gentoo add ebuild to custom repo
#!/bin/bash
# each item you want to prompt about in order
order=(mkdir cp chown pushd manifest popd)
# prompt string hash for each item
declare -A prompts=(
[mkdir]="Run 'mkdir -p /usr/local/portage/$1'"
[cp]="Run 'cp $3 /usr/local/portage/$1/$2'"
[chown]="Run 'chown -R portage:portage /usr/local/portage'"
[pushd]="Run 'pushd /usr/local/portage/$1/$2'"
[manifest]="Run 'repoman manifest'"
[popd]="Run popd"
)
# the command for each item
mkdir=(mkdir -p /usr/local/portage/$1/$2)
cp=(cp $3 /usr/local/portage/$1/$2/ )
chown=(chown -R portage:portage /usr/local/portage)
pushd=(pushd /usr/local/portage/$1/$2)
manifest=(repoman manifest)
popd=(popd)
for item in "${order[@]}" ; do
prompt="${prompts[$item]}"
# don't try this at home
eval "command=(\"\${$item[@]}\")"
while read -n 1 -r -p "$prompt: (Y/n): " ; do
case "$REPLY" in
# permit the user to hit enter to get the default behavior
[Yy]|'')
"${command[@]}"
break
;;
[Nn])
echo
break
;;
*)
printf '\nUnrecognized response "%s". please use Y or N\n' "$REPLY"
;;
esac
done
done
@InvisibleRasta
Copy link
Author

Example:
addRepoV2.sh grub2-themes gutsblack-archlinux gutsblack-archlinux-0_p20120706.ebuild

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment