All pastes #2101531 Raw Edit

voldial

public text v1 · immutable
#2101531 ·published 2012-01-09 11:03 UTC
rendered paste body
#!/bin/sh
apppath="${1}"

#this code is in the Public Domain.

#Goal: a command that gets you to the source code for any binary on a fedora system.
#example: /cfg/fedora_yum_edit_source_for_command.sh /bin/hostname

#almost working, see TODO below

ls -alh "${apppath}"
test -e "${apppath}" || exit 1

package=$(repoquery -qf --qf %{name} "${apppath}")

echo "package=${package}"
test -n "${package}" || exit 1

echo "making first folder"
mkdir "${package}" && cd "${package}" || exit 1

yumdownloader --source "${package}" || exit 1

rpmname=`ls *.src.rpm`
test -n "${rpmname}" || exit 1

echo "making second folder"
mkdir "${rpmname}_dir" || exit 1
cd "${rpmname}_dir" || exit 1

rpm2cpio ../*.src.rpm | cpio -idmv
ls --color -alh .


# TODO:
# example:
# /cfg/fedora_yum_edit_source_for_command.sh /bin/readlink
#
# after getting the rpm decompressed, we still
# need to decompress (for example coreutils-8.12.tar.xz)
# and open readlink.c


# for example:
# /cfg/fedora_yum_edit_source_for_command.sh /bin/fgrep
# we need %{version} to know what file name to decompress
# cat grep/grep-2.9-3.fc16.src.rpm_dir/grep.spec | grep xz
# Source: ftp://ftp.gnu.org/pub/gnu/grep/grep-%{version}.tar.xz