Skip to content

Commit 7b31e4c

Browse files
committed
pushpkg: revert to old argument habbit
1 parent 9af5924 commit 7b31e4c

File tree

1 file changed

+24
-34
lines changed

1 file changed

+24
-34
lines changed

pushpkg/pushpkg

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33
ARGS_SSH=""
44
ARGS_RSYNC=""
55
AFTER_CLEAN_DIRECTORY=0
6-
USERNAME=""
7-
BRANCH=""
8-
COMPOMENT=""
96

10-
while getopts "hvdb:u:c:" arg ; do
7+
while getopts "hvd" arg ; do
118
case $arg in
129
h)
1310
_help_message
@@ -20,62 +17,55 @@ while getopts "hvdb:u:c:" arg ; do
2017
d)
2118
AFTER_CLEAN_DIRECTORY=1
2219
;;
23-
b)
24-
BRANCH=${OPTARG}
25-
;;
26-
u)
27-
USERNAME=${OPTARG}
28-
;;
29-
c)
30-
COMPOMENT=${OPTARG}
31-
;;
3220
?)
3321
_help_message
3422
exit 1
3523
;;
3624
esac
3725
done
3826

27+
shift "$((OPTIND-1))"
28+
29+
USERNAME="$1"
30+
BRANCH="$2"
31+
COMPOMENT="${3:-main}"
3932

4033
_help_message() {
41-
printf "\
34+
cat << EOF
4235
Usage:
4336
44-
pushpkg -u LDAP_USERNAME -b BRANCH -c [COMPONENT]
37+
pushpkg <LDAP_USERNAME> <BRANCH> [COMPONENT]
4538
46-
-u LDAP_USERNAME: Your LDAP username.
47-
-b BRANCH: AOSC OS update branch (stable, stable-proposed, testing, etc.)
39+
LDAP_USERNAME: Your LDAP username.
40+
BRANCH: AOSC OS update branch (stable, stable-proposed, testing, etc.)
4841
4942
Options:
5043
51-
-c [COMPONENT]: (Optional) Repository component (main, bsp-sunxi, etc.)
52-
Falls back to "main" if not specified.
53-
-d: pushpkg after clean OUTPUT directory
54-
-v: ssh and rsync verbose
44+
[COMPONENT]: (Optional) Repository component (main, bsp-sunxi, etc.)
45+
Falls back to \"main\" if not specified.
46+
-d: Clean OUTPUT directory after finishing uploading.
47+
-v: Enable verbose logging for ssh and rsync
5548
56-
"
49+
EOF
5750
}
5851

5952
if [[ -z $USERNAME || -z $BRANCH ]]; then
60-
echo -e "[!!!] Please specify a LDAP user and specify a branch!\n"
53+
echo "[!!!] Please specify a LDAP user and specify a branch!"
6154
_help_message
6255
exit 1
6356
fi
6457

65-
if [ -z $COMPOMENT ]; then
66-
COMPOMENT="main"
58+
if [[ ! -d 'debs' ]]; then
59+
echo "[!!!] debs is not a directory."
60+
exit 1
6761
fi
6862

69-
ssh ${ARGS_SSH} ${USERNAME}@repo.aosc.io "mkdir -p /mirror/debs/pool/${BRANCH}/${COMPOMENT}"
63+
OUTPUT_DIR="$(readlink -f debs)"
64+
find "${OUTPUT_DIR}" -maxdepth 1 -type f -delete -print
7065

71-
for i in debs/*/*; do
72-
if [ $i = "*_noarch.deb" ]; then
73-
rsync ${ARGS_RSYNC} --ignore-existing -rlOvhze ssh --progress $i ${USERNAME}@repo.aosc.io:/mirror/debs/pool/${BRANCH}/${COMPOMENT}
74-
else
75-
rsync ${ARGS_RSYNC} -rlOvhze ssh --progress $i ${USERNAME}@repo.aosc.io:/mirror/debs/pool/${BRANCH}/${COMPOMENT}
76-
fi
77-
done
66+
ssh ${ARGS_SSH} "${USERNAME}@repo.aosc.io" "mkdir -p '/mirror/debs/pool/${BRANCH}/${COMPOMENT}'"
67+
rsync -rlOvhze ssh --progress "${OUTPUT_DIR}"/* "${USERNAME}@repo.aosc.io:/mirror/debs/pool/${BRANCH}/${COMPOMENT}"
7868

7969
if [ $AFTER_CLEAN_DIRECTORY = 1 ]; then
80-
sudo rm -rv $(pwd)/debs
70+
sudo rm -rv "$(pwd)/debs"
8171
fi

0 commit comments

Comments
 (0)