Create a yum source using shell

Source: Internet
Author: User
When using the Redhat system LinuxOS (RHEL, CentOS, Fedora, etc.), it is necessary to use the yum tool to manage software packages. When managing many systems or Connecting External yum sources is not convenient, it is also important to create an internal yum source. There are many operating systems using the RHEL series at ordinary times (currently RHEL6.4). Two years ago, yum sources for internal use were established and occasionally need to be updated to the latest version, therefore, repeat the steps to create a yum source. Here is a simple record of how

When Linux OS (RHEL, CentOS, and Fedora) of the Redhat system are used, it is necessary to use the yum tool to manage software packages. When many systems are managed or it is not convenient to connect to external yum sources, it is also important to create an internal yum source. There are many operating systems using the RHEL series at ordinary times (currently RHEL6.4). Two years ago, yum sources for internal use were established and occasionally need to be updated to the latest version, therefore, repeat the steps to create a yum source. Here is a simple record of how to create a yum source.

1. Preparation: Install Required Software(Such as createrepo), prepare the RPM package used by the yum Source
2. Copy the RPM package to a specific directory.
3. Run the createrepo command in the directory
4. Expose the yum source directory as an http or ftp service
5. Configure the yum source on the client systemGenerally, create a file such as test. repo in the/etc/yum. repo. d/directory and configure the yum source URL in it.
6. After configuring the yum source, Run "yum repolist" to check the effect.You can also use "yum install $ your-software.

Write a simple script to create the yum source, as shown below:

#!/bin/bash# set up YUM repository# yum install createrepo # install 'createrepo' toolbase_dir=/home/yum/pub/6Server# mkdir -p $base_dir/{SRPMS,i386,x86_64} # create dir if neededfor i in "SRPMS i386 x86_64"do# cp /your-src/*.rpm $base_dir/$i/ # you may copy RPMs to the destinationpushd $base_dir/$i > /dev/null 2>&1createrepo .popd >/dev/null 2>&1done

The configuration file of the yum source is as follows:

# put this .repo file into /etc/yum.repo.d/ directory.[rhel$releasever]name=Red Hat Enterprise Linux $releaseverbaseurl=http://mydomain.com/yum/$releasever/$basearchenabled=1gpgcheck=0[rhel6_optional]name=Red Hat Enterprise Linux rhel6_optionalbaseurl=http://mydomain.com/yum/$releasever_optional/$basearchenabled=1gpgcheck=0

Note: On my 64-bit RHEL6.4, $ releasever is parsed as 6 Server, and $ basearch is parsed as x86_64.

Some netizens asked: how do I maintain or create a group to associate it with and install some column RPM packages (which can be viewed by the yum grouplist command) when creating a repo )?
The method is to add the-g parameter when createrepo is used to specify the prepared XML file about group information. The command is:
[User @ machine] createrepo-g comps. xml MyRepo
The following is an example of the comps. xml file:

   
     
   
    mygroup
      
   
    False
      
   
    True
      
   
    1024
      
   
    My group
      
       
         
    
     glibc
          
    
     rpm
          
    
     yum
        
     
  
 

The comps. xml file can be generated using commands:

Yum-groups-manager-n "My Group "? Id = mygroup? Save = mygroups. xml? Mandatory yum glibc rpm

References:

Http://ramblings.narrabilis.com/creating-a-yum-repository-repo-and-creating-a-yum-group-to-install-kickstart

Http://yum.baseurl.org/wiki/YumGroups


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.