Linux: Acquiring Source Code
Jump to navigation
Jump to search
- 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.
sudo gedit /etc/apt/sources.list
- An example line might look like this:
deb-src http://us.archive.ubuntu.com/ubuntu/ hirsute main restricted
- Update the new package information that was added in step 1.
sudo apt-get update
- 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
- Example for downloading the source code for the grep utility
- 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
- If the directory doesn't exist, run this command on the .dsc file acquired from step 3 above:
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.
- 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
- Example for downloading the source code for the grep utility
- 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
- If the directory doesn't exist, run this command on the .dsc file acquired from step 4 above:
Fedora 34
- Install the rpm dev tools
dnf install rpm-build redhat-rpm-config rpmdevtools
- Download the source code, if this works you will see a new file, packagename.src.rpm
dnf download --source packagename
- Setup the tree, install the packagename.src.rpm
rpmdev-setuptreerpm -ivh mousepad-0.4.1-1.fc28.src.rpm
- Navigate to the home directory, note there should be a new directory named rpmbuild
- (optional) look at the tree
tree rpmbuild
- Go to the SOURCES directory located in the rpmbuild directory
- untar the source code
- Example 1
tar xjf packagename.tar.bz2 -C src
- Example 2
tar -xf packagename.tar.gz
- Example 1
- There should now be a directory with the source code