]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-build.git/commitdiff
scripts/build_utils: use -security and -updates repo 1792/head
authorKefu Chai <kchai@redhat.com>
Fri, 2 Apr 2021 05:09:50 +0000 (13:09 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 2 Apr 2021 06:04:45 +0000 (14:04 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
scripts/build_utils.sh

index 9246e52a54fc0ad6679eb96ec5dec432177f2c5d..2b00e701bb44a4f1456f74e6591bb67156eea1c3 100644 (file)
@@ -461,6 +461,48 @@ get_distro_and_target() {
     esac
 }
 
+setup_updates_repo() {
+    local hookdir=$1
+
+    if [[ $DISTRO != ubuntu ]]; then
+        return
+    fi
+    if [[ "$ARCH" == "x86_64" ]]; then
+        cat > $hookdir/D04install-updates-repo <<EOF
+echo "deb [arch=amd64] http://us.archive.ubuntu.com/ubuntu/ $DIST-updates main restricted universe multiverse" >>
+    /etc/apt/sources.list
+echo "deb [arch=amd64] http://us.archive.ubuntu.com/ubuntu/ $DIST-backports main restricted universe multiverse" >>
+    /etc/apt/sources.list
+echo "deb [arch=amd64] http://security.ubuntu.com/ubuntu $DIST-security main restricted universe multiverse" >>
+    /etc/apt/sources.list
+env DEBIAN_FRONTEND=noninteractive apt-get update -y -o Acquire::Languages=none -o Acquire::Translation=none || true
+env DEBIAN_FRONTEND=noninteractive apt-get install -y gnupg
+EOF
+    elif [[ "$ARCH" == "arm64" ]]; then
+        cat > $hookdir/D04install-updates-repo <<EOF
+echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ $DIST-updates main restricted universe multiverse" >>
+    /etc/apt/sources.list
+echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ $DIST-backports main restricted universe multiverse" >>
+    /etc/apt/sources.list
+echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ $DIST-security main restricted universe multiverse" >>
+    /etc/apt/sources.list
+env DEBIAN_FRONTEND=noninteractive apt-get update -y -o Acquire::Languages=none -o Acquire::Translation=none || true
+env DEBIAN_FRONTEND=noninteractive apt-get install -y gnupg
+EOF
+    fi
+}
+
+recreate_hookdir() {
+    local hookdir
+    if use_ppa; then
+        hookdir=$HOME/.pbuilder/hook.d
+    else
+        hookdir=$HOME/.pbuilder/hook-old-gcc.d
+    fi
+    rm -rf $hookdir
+    mkdir -p $hookdir
+    echo $hookdir
+}
 
 setup_pbuilder() {
     local use_gcc=$1
@@ -553,10 +595,16 @@ setup_pbuilder() {
         echo "$extrapackages" >> ~/.pbuilderrc
     fi
 
+    local hookdir
+    hookdir=$(recreate_hookdir)
+
     local opts
     opts+=" --basetgz $basedir/$DIST.tgz"
     opts+=" --distribution $DIST"
     opts+=" --mirror $mirror"
+    opts+=" --hookdir $hookdir"
+
+    setup_updates_repo $hookdir
     if [ -n "$use_gcc" ]; then
         # Newer pbuilder versions set $HOME to /nonexistent which breaks all kinds of
         # things that rely on a proper (writable) path. Setting this to the system user's $HOME is not enough
@@ -568,7 +616,7 @@ setup_pbuilder() {
         # in newer versions. This ticket solves the specific issue in 8.1.1 (which vendors urllib3):
         # https://github.com/shazow/urllib3/issues/567
         echo "USENETWORK=yes" >> ~/.pbuilderrc
-        setup_pbuilder_for_ppa >> ~/.pbuilderrc
+        setup_pbuilder_for_ppa $hookdir
     fi
     sudo cp ~/.pbuilderrc /root/.pbuilderrc
     sudo pbuilder clean
@@ -729,23 +777,16 @@ setup_pbuilder_for_old_gcc() {
 }
 
 setup_pbuilder_for_ppa() {
-    local hookdir
+    local hookdir=$1
     if use_ppa; then
-        hookdir=$HOME/.pbuilder/hook.d
-        rm -rf $hookdir
-        mkdir -p $hookdir
         local gcc_ver=7
         if [ "$DIST" = "bionic" ]; then
             gcc_ver=9
         fi
         setup_pbuilder_for_new_gcc $hookdir $gcc_ver
     else
-        hookdir=$HOME/.pbuilder/hook-old-gcc.d
-        rm -rf $hookdir
-        mkdir -p $hookdir
         setup_pbuilder_for_old_gcc $hookdir
     fi
-    echo "HOOKDIR=$hookdir"
 }
 
 get_bptag() {