github.com/sijibomii/docker@v0.0.0-20231230191044-5cf6ca554647/hack/make/update-apt-repo (about)

     1  #!/bin/bash
     2  set -e
     3  
     4  # This script updates the apt repo in $DOCKER_RELEASE_DIR/apt/repo.
     5  # This script is a "fix all" for any sort of problems that might have occurred with
     6  # the Release or Package files in the repo.
     7  # It should only be used in the rare case of extreme emergencies to regenerate
     8  # Release and Package files for the apt repo.
     9  #
    10  # NOTE: Always be sure to re-sign the repo with hack/make/sign-repos after running
    11  # this script.
    12  
    13  : ${DOCKER_RELEASE_DIR:=$DEST}
    14  APTDIR=$DOCKER_RELEASE_DIR/apt/repo
    15  
    16  # supported arches/sections
    17  arches=( amd64 i386 )
    18  
    19  # Preserve existing components but don't add any non-existing ones
    20  for component in main testing experimental ; do
    21  	if ls "$APTDIR/dists/*/$component" >/dev/null 2>&1 ; then
    22  		components+=( $component )
    23  	fi
    24  done
    25  
    26  dists=( $(find "${APTDIR}/dists" -maxdepth 1 -mindepth 1 -type d) )
    27  
    28  # override component if it is set
    29  if [ "$COMPONENT" ]; then
    30  	components=( $COMPONENT )
    31  fi
    32  
    33  # release the debs
    34  for version in "${dists[@]}"; do
    35  	for component in "${components[@]}"; do
    36  		codename="${version//debootstrap-}"
    37  
    38  		# update the filelist for this codename/component
    39  		find "$APTDIR/pool/$component" \
    40  			-name *~${codename#*-}*.deb > "$APTDIR/dists/$codename/$component/filelist"
    41  	done
    42  done
    43  
    44  # run the apt-ftparchive commands so we can have pinning
    45  apt-ftparchive generate "$APTDIR/conf/apt-ftparchive.conf"
    46  
    47  for dist in "${dists[@]}"; do
    48  	version=$(basename "$dist")
    49  	for component in "${components[@]}"; do
    50  		codename="${version//debootstrap-}"
    51  
    52  		apt-ftparchive \
    53  			-o "APT::FTPArchive::Release::Codename=$codename" \
    54  			-o "APT::FTPArchive::Release::Suite=$codename" \
    55  			-c "$APTDIR/conf/docker-engine-release.conf" \
    56  			release \
    57  			"$APTDIR/dists/$codename" > "$APTDIR/dists/$codename/Release"
    58  
    59  		for arch in "${arches[@]}"; do
    60  			apt-ftparchive \
    61  				-o "APT::FTPArchive::Release::Codename=$codename" \
    62  				-o "APT::FTPArchive::Release::Suite=$codename" \
    63  				-o "APT::FTPArchive::Release::Component=$component" \
    64  				-o "APT::FTPArchive::Release::Architecture=$arch" \
    65  				-c "$APTDIR/conf/docker-engine-release.conf" \
    66  				release \
    67  				"$APTDIR/dists/$codename/$component/binary-$arch" > "$APTDIR/dists/$codename/$component/binary-$arch/Release"
    68  		done
    69  	done
    70  done