ubuntu uses apt get to make OfflinePackage

Keywords: sudo MySQL shell Ubuntu

ubuntu uses apt get to make offline package (take mysql as an example)

Recently, I am studying the deployment of engineering software. Although this is the work of operation and maintenance, it is quite interesting.

Question: what factors need to be considered in software environment configuration

  • There are two ways to install the software
    1. make installation, you need to solve the dependency problem by yourself
    2. Apt get installation, stable, automatic configuration service
  • How to install the software without a network:
    1. Download files by yourself
    2. Using apt get offline package.

The text adopts the installation method of apt get offline package.

Scenario description

Code description

Scenario description

Install ubuntu, using apt get package manager. Some operations of apt get are not described here.
User is used to configure the installation package path as / home / user / corsface? Install/

Self made offline package take mysql as an example

Download a software

apt-cache search mysql
# Download mysql contains related dependencies but does not install
sudo apt-get install -d mysql-server-5.6

Make offline package

A shell script

# Navigate to your own installation package folder
cd /home/user/CorsFace_install
# Create installation package
mkdir OfflinePackage
# The software downloaded by apt get package manager is placed in / var/cache/apt/archives folder, and the software is stored in its own offline package.
cp -r /var/cache/apt/archives  /home/user/CorsFace_install/OfflinePackage
# Authority to operate
chmod 777 -R /home/user/CorsFace_install/OfflinePackage
sudo apt-get install dpkg-dev
cd /home/user/CorsFace_install/OfflinePackage/
# Generate dependency package relationships
sudo dpkg-scanpackages archives/ /dev/null |gzip > Packages.gz
cp Packages.gz archives/Packages.gz
# Create sources.list to customize the location of offline sources
echo "deb file:///home/user/CorsFace_install/OfflinePackage archives/" > sources.list
# Package the contents of the whole project that need to be packaged to form a dependency installation of the project. Form offline package
tar -cvf CorsFace.tar /home/user/CorsFace_install 

Offline environment installation

In a new machine deployment environment
A shell script

# Copy project dependency package to user
# Extract the file to the directory line of user
tar xvf CorsFace.tar -C ./
cd CorsFace_install 

autoInstall.sh content

# Set not to enter sudo command
sudo cp nopasswdsudo /etc/sudoers.d/nopasswdsudo
# Put the sources.list made above into the new version machine
sudo cp /etc/apt/sources.list /etc/apt/sources.list.back
sudo cp /home/user/CorsFace_install/sources.list /etc/apt/sources.list

#Update source
sudo apt-get update
#Get package locally for installation
sudo apt-get install mysql-server-5.6
#Copy the original sourcelists back
sudo cp /etc/apt/sources.list.back /etc/apt/sources.list

balabala

Knowledge points involved
1. Understanding of apt get package dependency Manager
2. Agree on the installation path
3. Use shell to improve work speed

Posted by CG_dude on Sun, 03 May 2020 20:41:23 -0700