Skip to content

Commit 1e9e13c

Browse files
committed
pushpkg: add option -v, -d and all use getopts
1 parent c0b2419 commit 1e9e13c

File tree

1 file changed

+63
-17
lines changed

1 file changed

+63
-17
lines changed

pushpkg/pushpkg

Lines changed: 63 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,81 @@
1-
#!/bin/bash
1+
#!/bin/bash
2+
3+
ARGS_SSH=""
4+
ARGS_RSYNC=""
5+
AFTER_CLEAN_DIRECTORY=0
6+
USERNAME=""
7+
BRANCH=""
8+
COMPOMENT=""
9+
10+
while getopts "hvdb:u:c:" arg ; do
11+
case $arg in
12+
h)
13+
_help_message
14+
exit 0
15+
;;
16+
v)
17+
ARGS_SSH+=" -vvv"
18+
ARGS_RSYNC+=" -v"
19+
;;
20+
d)
21+
AFTER_CLEAN_DIRECTORY=1
22+
;;
23+
b)
24+
BRANCH=${OPTARG}
25+
;;
26+
u)
27+
USERNAME=${OPTARG}
28+
;;
29+
c)
30+
COMPOMENT=${OPTARG}
31+
;;
32+
?)
33+
_help_message
34+
exit 1
35+
;;
36+
esac
37+
done
38+
39+
240
_help_message() {
341
printf "\
442
Usage:
543
6-
pushpkg LDAP_USERNAME BRANCH [COMPONENT]
44+
pushpkg -u LDAP_USERNAME -b BRANCH -c [COMPONENT]
45+
46+
-u LDAP_USERNAME: Your LDAP username.
47+
-b BRANCH: AOSC OS update branch (stable, stable-proposed, testing, etc.)
748
8-
- LDAP_USERNAME: Your LDAP username.
9-
- BRANCH: AOSC OS update branch (stable, stable-proposed, testing, etc.)
10-
- [COMPONENT]: (Optional) Repository component (main, bsp-sunxi, etc.)
49+
Options:
50+
51+
-c: [COMPONENT]: (Optional) Repository component (main, bsp-sunxi, etc.)
1152
Falls back to "main" if not specified.
53+
-d: pushpkg after clean OUTPUT directory
54+
-v: ssh and rsync verbose
1255
1356
"
1457
}
1558

16-
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
59+
if [ -z $USERNAME ]; then
60+
echo -e "[!!!] Please specify a LDAP user!\n"
1761
_help_message
18-
exit 0
62+
exit 1
1963
fi
2064

21-
if [ -z "$1" ]; then
22-
echo -e "[!!!] Please specify a LDAP user!\n"
23-
_help_message
24-
exit 1
65+
if [ -z $BRANCH ]; then
66+
echo -e "[!!!] Please specify a branch!\n"
67+
_help_message
68+
exit 1
2569
fi
2670

27-
if [ -z "$2" ]; then
28-
echo -e "[!!!] Please specify a branch!\n"
29-
_help_message
30-
exit 1
71+
if [ -z $COMPOMENT ]; then
72+
COMPOMENT="main"
3173
fi
3274

3375
sudo rm -fv debs/*
34-
ssh ${1}@repo.aosc.io "mkdir -p /mirror/debs/pool/${2}/${3:-main}"
35-
rsync -rlOvhze ssh --progress debs/* ${1}@repo.aosc.io:/mirror/debs/pool/${2}/${3:-main}
76+
ssh ${ARGS_SSH} ${USERNAME}@repo.aosc.io "mkdir -p /mirror/debs/pool/${BRANCH}/${COMPOMENT}"
77+
rsync ${ARGS_RSYNC} -rlOvhze ssh --progress debs/* ${USERNAME}@repo.aosc.io:/mirror/debs/pool/${BRANCH}/${COMPOMENT}
78+
79+
if [ $AFTER_CLEAN_DIRECTORY = 1 ]; then
80+
rm -rfv ./*
81+
fi

0 commit comments

Comments
 (0)