• R/O
  • HTTP
  • SSH
  • HTTPS

aptpac: コミット

GitHubのミラーです
https://github.com/FascodeNet/aptpac


コミットメタ情報

リビジョン1900c7bacaeb1be2292b8c2ace8040a8c8d9e5b8 (tree)
日時2021-04-24 16:48:12
作者hayao <hayao@fasc...>
コミッターhayao

ログメッセージ

[update] : Supported deb file

変更サマリ

差分

--- a/aptpac
+++ b/aptpac
@@ -21,8 +21,15 @@
2121 set -e
2222
2323
24+# APTPAC Version
2425 APTPAC_VERSION="3.3.0"
25-PACMAN_OPTIONS=()
26+
27+# Initilize List
28+PACMAN_PACKAGE_FILE=()
29+PACMAN_PACKAGE=()
30+DEB_PACKAGE_FILE=()
31+
32+# PACMAN Config
2633 HELPERS=(
2734 "/usr/bin/yay"
2835 "/usr/bin/paru"
@@ -33,14 +40,18 @@ HELPERS=(
3340 "/usr/bin/aura"
3441 "/usr/bin/wfa"
3542 )
43+PACMAN_OPTIONS=()
3644 DEFAULT_PACMAN_COMMAND="/usr/bin/pacman"
3745 PACMAN_COMMAND="${DEFAULT_PACMAN_COMMAND}"
3846 PACMAN_CONFIG="/etc/pacman.conf"
47+
48+# APTPAC Config
49+DEBTAP_WORK="/tmp/aptpac-debtap"
3950 DEBUG=false
4051 RUN_WITH_SUDO=false
41-
4252 DIRECT_PACMAN=false
4353 AUTOREMOVE=false
54+INSTALL=false
4455
4556 _msg_error () {
4657 echo -e "${@}" >&2
@@ -54,7 +65,7 @@ _msg_debug () {
5465
5566
5667 # List option
57-installed=false
68+INSTALLED_PKGLIST=false
5869
5970 _usage () {
6071 echo "usage ${0} [options] [command] [packages]"
@@ -118,6 +129,10 @@ _sudo(){
118129 fi
119130 }
120131
132+_pacman(){
133+ _sudo "${PACMAN_COMMAND}" "${PACMAN_OPTIONS[@]}" --config "${PACMAN_CONFIG}" "${@}"
134+}
135+
121136 _run_detect_aur_helper(){
122137 if [[ ! "${UID}" = 0 ]]; then
123138 if [[ -z "${AURHELPER+SET}" ]]; then
@@ -162,8 +177,52 @@ _run_autoremove(){
162177 fi
163178 }
164179
180+_run_distinguish_package(){
181+ local pkg
182+ for pkg in "${PACKAGE[@]}"; do
183+ if [[ ! -f "${pkg}" ]]; then
184+ PACMAN_PACKAGE+=("${pkg}")
185+ elif [[ "$(file -b --mime-type "${pkg}" 2> /dev/null)" = "application/vnd.debian.binary-package" ]]; then
186+ DEB_PACKAGE_FILE+=("${pkg}")
187+ else
188+ PACMAN_PACKAGE_FILE+=("${pkg}")
189+ fi
190+ done
191+}
192+
165193 _run_pacman(){
166- _sudo "${PACMAN_COMMAND}" "${PACMAN_OPTIONS[@]}" --config "${PACMAN_CONFIG}" "${PACKAGE[@]}"
194+ if [[ "${INSTALL}" = true ]]; then
195+ _pacman -S "${PACMAN_PACKAGE[@]}"
196+ else
197+ _pacman "${PACMAN_PACKAGE[@]}"
198+ fi
199+}
200+
201+_run_debtap(){
202+ if (( "${#DEB_PACKAGE_FILE[@]}" != 0 )) && ! hash "debtap"; then
203+ _msg_error "debtap was not found"
204+ exit 1
205+ fi
206+
207+ if [[ -z "$(find "/var/cache/pkgfile" -maxdepth 1 -mindepth 1 -name "*.files" 2> /dev/null)" ]] || [[ -z "$(find "/var/cache/debtap" -maxdepth 1 -mindepth 1 -name "*-packages" 2> /dev/null)" ]] || [[ -z "$(find "/var/cache/debtap" -maxdepth 1 -mindepth 1 -name "*-files" 2> /dev/null)" ]]; then
208+ sudo debtap -u
209+ fi
210+
211+ (
212+ sudo mkdir -p "${DEBTAP_WORK}"
213+ local pkg work
214+ for pkg in "${DEB_PACKAGE_FILE[@]}"; do
215+ work="${DEBTAP_WORK}/$(basename "${pkg}")/"
216+ file="${work}/$(basename "${pkg}")"
217+ sudo mkdir -p "${work}"
218+ cd "${work}"
219+ sudo cp "${pkg}" "${file}"
220+ sudo debtap --Quiet "${file}"
221+ while read -r archpkg; do
222+ _pacman -U "${archpkg}"
223+ done < <(find "${work}" -maxdepth 1 -mindepth 1 -type f -name "*.pkg.tar.*")
224+ done
225+ )
167226 }
168227
169228
@@ -204,7 +263,7 @@ while true; do
204263 shift 1
205264 ;;
206265 --installed)
207- installed=true
266+ INSTALLED_PKGLIST=true
208267 shift 1
209268 ;;
210269 --debug)
@@ -269,7 +328,8 @@ if [[ "${DIRECT_PACMAN}" = false ]]; then
269328
270329 case "${COMMAND}" in
271330 install)
272- ADD_OPTION "-S"
331+ #ADD_OPTION "-S"
332+ INSTALL=true
273333 ;;
274334 remove)
275335 ADD_OPTION "-Rsc"
@@ -334,7 +394,7 @@ if [[ "${DIRECT_PACMAN}" = false ]]; then
334394 fi
335395 ;;
336396 list)
337- if ${installed}; then
397+ if [[ "${INSTALLED_PKGLIST}" = true ]]; then
338398 ADD_OPTION "-Q | grep"
339399 else
340400 ADD_OPTION "-Ss"
@@ -368,5 +428,9 @@ fi
368428
369429 _run_detect_aur_helper
370430 _run_aur_message
431+_run_distinguish_package
371432 _run_pacman
433+if [[ "${INSTALL}" = true ]]; then
434+ _run_debtap
435+fi
372436 _run_autoremove
旧リポジトリブラウザで表示