]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - builder.sh
- help
[packages/rpm-build-tools.git] / builder.sh
index b509e8b637960558fc34cef6c84f3728219068bd..b58d75e6dc4fca0cc23c12393e4bf571d7561482 100644 (file)
@@ -42,6 +42,7 @@ NOCVS=""
 NOCVSSPEC=""
 NODIST=""
 NOINIT=""
+PREFMIRRORS=""
 UPDATE=""
 ADD5=""
 NO5=""
@@ -79,6 +80,7 @@ ICONS=""
 PACKAGE_RELEASE=""
 PACKAGE_VERSION=""
 PACKAGE_NAME=""
+ASSUMED_NAME=""
 PROTOCOL="ftp"
 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
@@ -130,8 +132,10 @@ fi
 SU_SUDO=""
 if [ -n "$HOME_ETC" ]; then
        USER_CFG="$HOME_ETC/.builderrc"
+       BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros"
 else
        USER_CFG=~/.builderrc
+       BUILDER_MACROS=~/.builder-rpmmacros
 fi
 
 [ -f "$USER_CFG" ] && . "$USER_CFG"
@@ -256,6 +260,7 @@ Usage: builder [-D|--debug] [-V|--version] [--short-version] [-a|--as_anon] [-b|
 -ns, --no-srcs      - don't download Sources
 -ns0, --no-source0  - don't download Source0
 -nn, --no-net       - don't download anything from the net
+-pm, --prefer-mirrors - prefer mirrors (if any) over distfiles for SOURCES
 --no-init           - don't initialize builder paths (SPECS and SOURCES)
 -ske,
 --skip-existing-files - skip existing files in get_files
@@ -383,7 +388,7 @@ minirpm() {
        safe_macrofiles=$(rpm --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
 
        # TODO: move these to /usr/lib/rpm/macros
-       cat > .builder-rpmmacros <<'EOF'
+       cat > $BUILDER_MACROS <<'EOF'
 %x8664 x86_64 amd64 ia32e
 %alt_kernel %{nil}
 %_alt_kernel %{nil}
@@ -423,12 +428,12 @@ minirpm() {
 %{nil}
 EOF
        if [ "$NOINIT" = "yes" ] ; then
-               cat >> .builder-rpmmacros <<'EOF'
+               cat >> $BUILDER_MACROS <<'EOF'
 %_specdir ./
 %_sourcedir ./
 EOF
        fi
-       eval $RPMBUILD --macros "$safe_macrofiles:.builder-rpmmacros" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $* 2>&1
+       eval $RPMBUILD --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $* 2>&1
 }
 
 cache_rpm_dump() {
@@ -515,6 +520,10 @@ parse_spec()
        PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
        PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
 
+       if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
+               echo "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
+       fi
+
        if [ -n "$BE_VERBOSE" ]; then
                echo "- Sources :  `nourl $SOURCES`"
                if [ -n "$PATCHES" ]; then
@@ -597,8 +606,8 @@ init_builder()
        fi
 
        if [ "$NOINIT" != "yes" ] ; then
-               SOURCE_DIR="`eval $RPM $RPMOPTS --eval '%{_sourcedir}'`"
-               SPECS_DIR="`eval $RPM $RPMOPTS --eval '%{_specdir}'`"
+               SOURCE_DIR="`eval $RPM $RPMOPTS --define '"name $ASSUMED_NAME"' --eval '%{_sourcedir}'`"
+               SPECS_DIR="`eval $RPM $RPMOPTS --define '"name $ASSUMED_NAME"' --eval '%{_specdir}'`"
        else
                SOURCE_DIR="."
                SPECS_DIR="."
@@ -936,9 +945,9 @@ get_files()
                                        fi
                                        target="$fp"
 
-                                       # prefer mirror over distfiles if there's mirror
+                                       # optionally prefer mirror over distfiles if there's mirror
                                        # TODO: build url list and then try each url from the list
-                                       if [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
+                                       if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
                                                url="$im"
                                        else
                                                url=$(distfiles_url "$i")
@@ -1911,6 +1920,9 @@ while [ $# -gt 0 ]; do
                        NOSRCS="yes"
                        ALWAYS_CVSUP="no"
                        shift;;
+               -pm | --prefer-mirrors )
+                       PREFMIRRORS="yes"
+                       shift;;
                --no-init )
                        NOINIT="yes"
                        shift;;
@@ -2068,6 +2080,7 @@ while [ $# -gt 0 ]; do
                                CVSTAG="${SPECFILE##*:}"
                                SPECFILE="${SPECFILE%%:*}"
                        fi
+                       ASSUMED_NAME="$(basename ${SPECFILE%%.spec})"
                        shift
        esac
 done
This page took 0.048679 seconds and 4 git commands to generate.