summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/chroot-tools/librechroot20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot
index 9e98126..e353206 100755
--- a/src/chroot-tools/librechroot
+++ b/src/chroot-tools/librechroot
@@ -20,6 +20,11 @@
# You should have received a copy of the GNU General Public License
# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
+# HACKING: if a command is added or removed, it must be changed in 3 places:
+# - the usage() text
+# - the commands=() array
+# - the case statement in main()
+
. $(librelib conf.sh)
load_files chroot
@@ -109,6 +114,11 @@ usage() {
echo ' clean-repo Clean /repo in the chroot copy'
echo ' help Show this message'
}
+commands=(
+ noop make sync delete
+ install-file install-name update clean-pkgs
+ run enter clean-repo help
+)
# set $rootdir and $copydir; blank them on error
calculate_directories() {
@@ -159,6 +169,11 @@ main() {
return 1
fi
mode=$1
+ if ! in_array "$mode" "${commands[@]}"; then
+ error "Unrecognized command: \`$mode'"
+ usage >/dev/stderr
+ return 1
+ fi
shift
if [[ $mode == help ]]; then
@@ -253,11 +268,6 @@ main() {
rm -rf "${copydir}/repo/*"
make_empty_repo "$copydir"
;;
- *)
- error "Unrecognized command: \`$mode'"
- usage >/dev/stderr
- return 1
- ;;
esac
}