Linux: Acquiring Source Code: Difference between revisions

From BS Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(29 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Acquiring Source Code in Ubuntu (Hirsute) ==
__TOC__


:See [[Linux: Compiling and Installing Source Code from the Terminal]] for compiling and installing.
== Ubuntu (Hirsute) ==
# Update/enable the source package URLs. Note that in Ubuntu, these should already be in the sources.list file and just need to be uncommented. i.e. remove the "#" from the deb-src lines.
# Update/enable the source package URLs. Note that in Ubuntu, these should already be in the sources.list file and just need to be uncommented. i.e. remove the "#" from the deb-src lines.
#:::<code>sudo gedit /etc/apt/sources.list</code>
#::An example line might look like this:
#:::<code>deb-src <nowiki>http://us.archive.ubuntu.com/ubuntu/</nowiki> hirsute main restricted</code>
# Update the new package information that was added in step 1.
# Update the new package information that was added in step 1.
#:::<code>sudo apt-get update</code>
# Navigate to the directory that the source code will reside in, and download it.
#::Example for downloading the source code for the grep utility
#:::<code>sudo apt-get source grep</code>
#::Example for downloading the source code for bash
#:::<code>sudo apt-get source bash</code>
# There should be a directory with the source code along with some other files. Move to the new directory to view the downloaded source code.
#:::If the directory doesn't exist, run this command on the .dsc file acquired from step 3 above:
#::::<code>dpkg-source -x yourfile.dsc</code>
#:::If you get an error message that dpkg-source can not be found, install the package:
#::::<code>sudo apt install dpkg-dev</code>
== Mint 20.1 Cinnamon ==
# Bring up the Software Sources
#:::Menu Button -> Administration -> Software Sources
# Toggle the "Source code repositories" button to enabled state, under Optional Sources
# Press the OK button
# Navigate to the directory that the source code will reside in, and download it.
# Navigate to the directory that the source code will reside in, and download it.
#::Example for downloading the source code for the grep utility
#:::<code>sudo apt-get source grep</code>
#::Example for downloading the source code for bash
#:::<code>sudo apt-get source bash</code>
# There should be a directory with the source code along with some other files. Move to the new directory to view the downloaded source code.
# There should be a directory with the source code along with some other files. Move to the new directory to view the downloaded source code.
#:::If the directory doesn't exist, run this command on the .dsc file acquired from step 4 above:
#::::<code>dpkg-source -x yourfile.dsc</code>
#:::If you get an error message that dpkg-source can not be found, install the package:
#::::<code>sudo apt install dpkg-dev</code>
== Fedora 34 ==
# Install the rpm dev tools
#:::<code>dnf install rpm-build redhat-rpm-config rpmdevtools</code>
# Download the source code, if this works you will see a new file, packagename.src.rpm
#:::<code>dnf download --source packagename</code>
# Setup the tree, install the packagename.src.rpm
#:::<code>rpmdev-setuptree</code>
#:::<code>rpm -ivh mousepad-0.4.1-1.fc28.src.rpm</code>
# Navigate to the home directory, note there should be a new directory named rpmbuild
# (optional) look at the tree
#:::<code>tree rpmbuild</code>
# Go to the SOURCES directory located in the rpmbuild directory
# untar the source code
#:: Example 1
#:::<code>tar xjf packagename.tar.bz2 -C src</code>
#:: Example 2
#:::<code>tar -xf packagename.tar.gz</code>
# There should now be a directory with the source code




See [[Linux: Compiling and Installing Source Code from the Terminal]] for compiling and installing.
== openSUSE Tumbleweed ==
# If the source repo was not enabled when openSUSE was installed, enable it.
#:: List all of the repos and look for the sources repo
#:::<code>zypper repos</code>
#:: Assuming the sources repo is named "repo-source", enable it
#:::<code>sudo zypper modifyrepo -er 'repo-source'</code>
# Install the source, "bash" in this example
#:::<code>sudo zypper source-install bash</code>
# Navigate to /usr/src/packages/SOURCES/ and find a tar of the packages source code
# Copy the tar'd file to the desired location and untar it
#:::<code>tar -xf packagename.tar.gz</code>
# Find a directory of the source code wherever it was untar'd

Latest revision as of 22:08, 31 May 2021


See Linux: Compiling and Installing Source Code from the Terminal for compiling and installing.

Ubuntu (Hirsute)

  1. Update/enable the source package URLs. Note that in Ubuntu, these should already be in the sources.list file and just need to be uncommented. i.e. remove the "#" from the deb-src lines.
    sudo gedit /etc/apt/sources.list
    An example line might look like this:
    deb-src http://us.archive.ubuntu.com/ubuntu/ hirsute main restricted
  2. Update the new package information that was added in step 1.
    sudo apt-get update
  3. Navigate to the directory that the source code will reside in, and download it.
    Example for downloading the source code for the grep utility
    sudo apt-get source grep
    Example for downloading the source code for bash
    sudo apt-get source bash
  4. There should be a directory with the source code along with some other files. Move to the new directory to view the downloaded source code.
    If the directory doesn't exist, run this command on the .dsc file acquired from step 3 above:
    dpkg-source -x yourfile.dsc
    If you get an error message that dpkg-source can not be found, install the package:
    sudo apt install dpkg-dev


Mint 20.1 Cinnamon

  1. Bring up the Software Sources
    Menu Button -> Administration -> Software Sources
  2. Toggle the "Source code repositories" button to enabled state, under Optional Sources
  3. Press the OK button
  4. Navigate to the directory that the source code will reside in, and download it.
    Example for downloading the source code for the grep utility
    sudo apt-get source grep
    Example for downloading the source code for bash
    sudo apt-get source bash
  5. There should be a directory with the source code along with some other files. Move to the new directory to view the downloaded source code.
    If the directory doesn't exist, run this command on the .dsc file acquired from step 4 above:
    dpkg-source -x yourfile.dsc
    If you get an error message that dpkg-source can not be found, install the package:
    sudo apt install dpkg-dev


Fedora 34

  1. Install the rpm dev tools
    dnf install rpm-build redhat-rpm-config rpmdevtools
  2. Download the source code, if this works you will see a new file, packagename.src.rpm
    dnf download --source packagename
  3. Setup the tree, install the packagename.src.rpm
    rpmdev-setuptree
    rpm -ivh mousepad-0.4.1-1.fc28.src.rpm
  4. Navigate to the home directory, note there should be a new directory named rpmbuild
  5. (optional) look at the tree
    tree rpmbuild
  6. Go to the SOURCES directory located in the rpmbuild directory
  7. untar the source code
    Example 1
    tar xjf packagename.tar.bz2 -C src
    Example 2
    tar -xf packagename.tar.gz
  8. There should now be a directory with the source code


openSUSE Tumbleweed

  1. If the source repo was not enabled when openSUSE was installed, enable it.
    List all of the repos and look for the sources repo
    zypper repos
    Assuming the sources repo is named "repo-source", enable it
    sudo zypper modifyrepo -er 'repo-source'
  2. Install the source, "bash" in this example
    sudo zypper source-install bash
  3. Navigate to /usr/src/packages/SOURCES/ and find a tar of the packages source code
  4. Copy the tar'd file to the desired location and untar it
    tar -xf packagename.tar.gz
  5. Find a directory of the source code wherever it was untar'd