فهرست منبع

my_debootstrap2.sh

侠义书生 3 سال پیش
والد
کامیت
cb36224d29
2فایلهای تغییر یافته به همراه120 افزوده شده و 107 حذف شده
  1. 0 77
      debootstrap/apt_list/down_indices.sh
  2. 120 30
      debootstrap/apt_list/my_debootstrap2.sh

+ 0 - 77
debootstrap/apt_list/down_indices.sh

@@ -1,77 +0,0 @@
-#!/bin/bash
-function config_kylin() {
-    MIRRORS="http://172.29.220.242/launchpad/kylin http://172.29.220.242/launchpad/kylin-desktop"
-    SUITES="v101"
-    COMPONENTS="main restricted universe multiverse"
-    ARCH="amd64"
-}
-
-function config_ubuntu() {
-    MIRRORS="http://mirrors.aliyun.com/ubuntu"
-    SUITES="focal focal-updates focal-security"
-    COMPONENTS="main restricted universe multiverse"
-    ARCH="amd64"
-}
-
-function config_my() {
-    MIRRORS="http://172.29.220.242/mirror/kylin"
-    SUITES="v101"
-    COMPONENTS="main"
-    ARCH="amd64"
-}
-
-function do_wget() {
-    wget -P ${TARGET_DIR} -r -np $1
-    # wget -r -np $1
-}
-
-function wgetfile() {
-    # echo "$1"
-    filepath="${TARGET_DIR}/${1#*//}"
-    if [ ! -f "${filepath}" ]; then
-        do_wget $1
-    else
-        md5sum "${filepath}"
-    fi
-
-    if [ "${filepath##*.}" == "gz" ]; then
-        if [ ! -f "${filepath%.*}" ]; then
-            gunzip -k ${filepath}
-        else
-            md5sum "${filepath%.*}"
-        fi
-    fi
-}
-
-TARGET_DIR="/var/tmp/indices"
-if [ ! -d "${TARGET_DIR}" ]; then
-    mkdir -p "${TARGET_DIR}"
-fi
-
-function get_indices() {
-    # ${MIRRORS%% *}
-    for m in ${MIRRORS}; do
-        for s in ${SUITES}; do
-            sInRelease="${m}/dists/${s}/InRelease"
-            sRelease="${m}/dists/${s}/Release"
-            sRelease_gpg="${m}/dists/${s}/Release.gpg"
-
-            wgetfile ${sInRelease}
-            wgetfile ${sRelease}
-            wgetfile ${sRelease_gpg}
-
-            for c in ${COMPONENTS}; do
-                path="${m}/dists/$s/$c/binary-$ARCH/Packages.gz"
-                # echo ${path}
-                wgetfile ${path}
-            done
-        done
-    done
-}
-
-config_ubuntu
-get_indices
-config_kylin
-get_indices
-config_my
-get_indices

+ 120 - 30
debootstrap/apt_list/test2.sh → debootstrap/apt_list/my_debootstrap2.sh

@@ -1,4 +1,7 @@
-############################################################### mylog
+#!/bin/bash
+
+########## functions ##########
+# log
 MY_LOG_FILE=/var/tmp/my_analysis.log
 : >${MY_LOG_FILE}
 
@@ -12,6 +15,51 @@ mylog() {
     fi
 }
 
+mylog2() {
+    echo "---> $@" >>${MY_LOG_FILE}
+}
+
+function do_wget() {
+    wget -P ${TARGET_DIR} -r -np $1
+    # wget -r -np $1
+}
+
+function wgetfile() {
+    # echo "$1"
+    filepath="${TARGET_DIR}/${1#*//}"
+    if [ ! -f "${filepath}" ]; then
+        do_wget $1
+    else
+        mylog2 $(md5sum "${filepath}")
+    fi
+
+    if [ "${filepath##*.}" == "gz" ]; then
+        if [ ! -f "${filepath%.*}" ]; then
+            gunzip -k ${filepath}
+        else
+            mylog2 $(md5sum "${filepath%.*}")
+        fi
+    fi
+}
+
+without() {
+    # usage:  without "a b c" "a d" -> "b" "c"
+    (
+        echo "$1" | tr ' ' '\n' | sort | uniq
+        echo "$2" "$2" | tr ' ' '\n'
+    ) | sort | uniq -u | tr '\n' ' '
+    echo
+}
+
+# 从 文件1 中排除 文件2
+without2() {
+    (
+        cat $1
+        cat $2
+        cat $2
+    ) | sort | uniq -u | tr '\n' ' '
+}
+
 # 查找依赖 pkgname 的包
 function find_who_depend() {
     pkgname="bash"
@@ -42,22 +90,51 @@ function get_pkg_deps() {
         tr ',' '\n' | sed 's/|.*//' | sed 's#(.*)##g' | xargs | tr ' ' '\n' | sort | uniq
 }
 
-without() {
-    # usage:  without "a b c" "a d" -> "b" "c"
-    (
-        echo "$1" | tr ' ' '\n' | sort | uniq
-        echo "$2" "$2" | tr ' ' '\n'
-    ) | sort | uniq -u | tr '\n' ' '
-    echo
+# bash包依赖
+# resolve_deps bash
+
+########## functions ##########
+
+function config_kylin() {
+    MIRRORS="http://172.29.220.242/launchpad/kylin http://172.29.220.242/launchpad/kylin-desktop"
+    SUITES="v101"
+    COMPONENTS="main restricted universe multiverse"
+    ARCH="amd64"
 }
 
-# 从 文件1 中排除 文件2
-without2() {
-    (
-        cat $1
-        cat $2
-        cat $2
-    ) | sort | uniq -u | tr '\n' ' '
+function config_ubuntu() {
+    MIRRORS="http://mirrors.aliyun.com/ubuntu"
+    SUITES="focal focal-updates focal-security"
+    COMPONENTS="main restricted universe multiverse"
+    ARCH="amd64"
+}
+
+function config_my() {
+    MIRRORS="http://172.29.220.242/mirror/kylin"
+    SUITES="v101"
+    COMPONENTS="main"
+    ARCH="amd64"
+}
+
+function download_indices() {
+    # ${MIRRORS%% *}
+    for m in ${MIRRORS}; do
+        for s in ${SUITES}; do
+            sInRelease="${m}/dists/${s}/InRelease"
+            sRelease="${m}/dists/${s}/Release"
+            sRelease_gpg="${m}/dists/${s}/Release.gpg"
+
+            wgetfile ${sInRelease}
+            wgetfile ${sRelease}
+            wgetfile ${sRelease_gpg}
+
+            for c in ${COMPONENTS}; do
+                path="${m}/dists/$s/$c/binary-$ARCH/Packages.gz"
+                # echo ${path}
+                wgetfile ${path}
+            done
+        done
+    done
 }
 
 resolve_deps() {
@@ -100,24 +177,37 @@ resolve_deps() {
     echo "$ALLPKGS"
 }
 
-TARGET_DIR="/var/tmp/indices"
-SHELL_DIR=$(dirname $(readlink -f $0))
+function work_out_debs() {
+    PRIO="required"
+    required=$(awk -v SEARCH_STR="${PRIO}" -f ${SHELL_DIR}/analysis.awk ${TARGET_DIR}/172.29.220.242/mirror/kylin/dists/v101/main/binary-amd64/Packages)
+    mylog "01-required.txt2" "${required}"
 
-# bash包依赖
-# resolve_deps bash
+    required_deps=$(resolve_deps "${required}")
+    mylog "01-required@deps.txt2" "$(echo ${required_deps} | xargs | tr ' ' '\n')"
 
-PRIO="required"
-required=$(awk -v SEARCH_STR="${PRIO}" -f ${SHELL_DIR}/analysis.awk ${TARGET_DIR}/172.29.220.242/mirror/kylin/dists/v101/main/binary-amd64/Packages)
-mylog "01-required.txt2" "${required}"
+    PRIO="important"
+    important=$(awk -v SEARCH_STR="${PRIO}" -f ${SHELL_DIR}/analysis.awk ${TARGET_DIR}/172.29.220.242/mirror/kylin/dists/v101/main/binary-amd64/Packages)
+    mylog "02-important.txt2" "${important}"
 
-required_deps=$(resolve_deps "${required}")
-mylog "01-required@deps.txt2" "$(echo ${required_deps} | xargs | tr ' ' '\n')"
+    important_deps=$(resolve_deps "${important}")
+    mylog "02-important@deps.txt2" "$(echo ${important_deps} | xargs | tr ' ' '\n')"
+    important_deps=$(without "$important_deps" "$required_deps")
+    mylog "02-important@deps@without@required.txt2" "$(echo ${important_deps} | xargs | tr ' ' '\n')"
+}
+
+TARGET_DIR="/var/tmp/indices"
+if [ ! -d "${TARGET_DIR}" ]; then
+    mkdir -p "${TARGET_DIR}"
+fi
+SHELL_DIR=$(dirname $(readlink -f $0))
 
-PRIO="important"
-important=$(awk -v SEARCH_STR="${PRIO}" -f ${SHELL_DIR}/analysis.awk ${TARGET_DIR}/172.29.220.242/mirror/kylin/dists/v101/main/binary-amd64/Packages)
-mylog "02-important.txt2" "${important}"
+# config_ubuntu
+# config_kylin
+config_my
+download_indices
+work_out_debs
 
-important_deps=$(resolve_deps "${important}")
-mylog "02-important@deps.txt2" "$(echo ${important_deps} | xargs | tr ' ' '\n')"
+all_debs=$(echo "${required_deps} ${important_deps}" | xargs | tr ' ' '\n' | sort | uniq)
+echo "${all_debs}"
 
-echo "${required_deps} ${important_deps}"
+# TODO: download_deb