├── .gitignore ├── .gitmodules ├── COPYING ├── Makefile ├── PKGBUILD ├── PKGBUILD-git ├── README.md ├── confs ├── newpkg.conf └── spec2arch.conf ├── doc ├── spec2arch.1 └── spec2arch.conf.5 ├── other ├── functions ├── functions.newpkg └── newpkg_presets │ ├── auto_pkgname.action │ ├── default.preset │ ├── install.action │ ├── pkgbuild.action │ ├── rcd.action │ └── sf.action ├── pkgtools.install ├── scripts ├── .gitignore ├── maintpkg ├── newpkg ├── pkgclean ├── pkgconflict.py ├── spec2arch ├── upgpkg └── whoneeds.bash └── specfiles ├── PKGBUILD.eject └── eject.spec /.gitignore: -------------------------------------------------------------------------------- 1 | src 2 | pkg 3 | *pkg.tar.* 4 | pkgtools.tar.gz 5 | .*.swp 6 | *.files.* 7 | scripts/*.pyc 8 | tags 9 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "scripts/pip2arch"] 2 | path = scripts/pip2arch 3 | url = https://github.com/bluepeppers/pip2arch 4 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | INSTALL = install 2 | INSTALL_DATA = $(INSTALL) -Dm644 3 | INSTALL_PROGRAM = $(INSTALL) -Dm755 4 | prefix = /usr 5 | exec_prefix = $(prefix) 6 | confdir = /etc 7 | bindir = $(exec_prefix)/bin 8 | libdir = $(prefix)/lib 9 | sharedir = $(prefix)/share/pkgtools 10 | profiledir = $(confdir)/profile.d 11 | mandir = $(prefix)/share/man 12 | 13 | .PHONY: all 14 | 15 | all: install 16 | 17 | install: 18 | # Common functions needed by all scripts 19 | $(INSTALL_DATA) other/functions $(DESTDIR)$(sharedir)/functions 20 | 21 | # newpkg 22 | $(INSTALL_PROGRAM) scripts/newpkg $(DESTDIR)$(bindir)/newpkg 23 | $(INSTALL_DATA) other/functions.newpkg $(DESTDIR)$(sharedir)/functions.newpkg 24 | $(INSTALL_DATA) confs/newpkg.conf $(DESTDIR)$(confdir)/pkgtools/newpkg.conf 25 | $(INSTALL) -d $(DESTDIR)$(sharedir)/newpkg/presets/ 26 | $(INSTALL) -m644 other/newpkg_presets/* $(DESTDIR)$(sharedir)/newpkg/presets/ 27 | 28 | # spec2arch 29 | $(INSTALL_PROGRAM) scripts/spec2arch $(DESTDIR)$(bindir)/spec2arch 30 | $(INSTALL_DATA) confs/spec2arch.conf $(DESTDIR)$(confdir)/pkgtools/spec2arch.conf 31 | $(INSTALL_DATA) doc/spec2arch.1 $(DESTDIR)$(mandir)/man1/spec2arch.1 32 | $(INSTALL_DATA) doc/spec2arch.conf.5 $(DESTDIR)$(mandir)/man5/spec2arch.conf.5 33 | 34 | # pkgconflict 35 | $(INSTALL_PROGRAM) scripts/pkgconflict.py $(DESTDIR)$(bindir)/pkgconflict 36 | 37 | # whoneeds 38 | $(INSTALL_PROGRAM) scripts/whoneeds.bash $(DESTDIR)$(bindir)/whoneeds 39 | 40 | # pkgclean 41 | $(INSTALL_PROGRAM) scripts/pkgclean $(DESTDIR)$(bindir)/pkgclean 42 | 43 | # maintpkg 44 | $(INSTALL_PROGRAM) scripts/maintpkg $(DESTDIR)$(bindir)/maintpkg 45 | 46 | # pip2arch 47 | $(INSTALL_PROGRAM) scripts/pip2arch/pip2arch.py $(DESTDIR)$(bindir)/pip2arch 48 | 49 | uninstall: 50 | rm -Rf $(DESTDIR)$(sharedir) 51 | rm $(DESTDIR)$(bindir)/{newpkg,spec2arch,pkgconflict,whoneeds,pkgclean,pip2arch} 52 | rm -Rf $(DESTDIR)$(confdir)/pkgtools 53 | rm $(DESTDIR)$(mandir)/man8/spec2arch.8 54 | rm $(DESTDIR)$(mandir)/man5/spec2arch.conf.5 55 | -------------------------------------------------------------------------------- /PKGBUILD: -------------------------------------------------------------------------------- 1 | # Maintainer: Daenyth 2 | # Contributor: Daenyth 3 | pkgname=pkgtools 4 | pkgver=25 5 | pkgrel=1 6 | pkgdesc="A collection of scripts for Arch Linux packages" 7 | arch=('any') 8 | url="https://bbs.archlinux.org/viewtopic.php?pid=384196" 9 | license=('GPL') 10 | depends=('bash>=4' 'pcre' 'libarchive' 'python' 'namcap' 'pkgfile' 'gem2arch') 11 | optdepends=('abs: Provides PKGBUILD prototypes for newpkg') 12 | provides=('newpkg') 13 | backup=('etc/pkgtools/newpkg.conf' 'etc/pkgtools/pkgfile.conf' 'etc/pkgtools/spec2arch.conf') 14 | install=pkgtools.install 15 | source=("${pkgname}-v${pkgver}.tar.gz::https://github.com/Daenyth/pkgtools/tarball/v$pkgver") 16 | md5sums=('9e9d7aad5ba8ecee1b798c3ed4e0a0a7') 17 | 18 | package() { 19 | cd "Daenyth-$pkgname"-* 20 | 21 | make DESTDIR="$pkgdir" install 22 | } 23 | -------------------------------------------------------------------------------- /PKGBUILD-git: -------------------------------------------------------------------------------- 1 | # Contributor: Daenyth 2 | pkgname=pkgtools-git 3 | _pkgname=pkgtools 4 | pkgver=20140211.bc854ae 5 | pkgrel=1 6 | pkgdesc="A collection of scripts for Arch Linux packages" 7 | arch=('any') 8 | url="https://github.com/Daenyth/pkgtools" 9 | license=('GPL') 10 | depends=('bash>=4' 'libarchive' 'pcre' 'python' 'namcap' 'pkgfile' 'gem2arch') 11 | makedepends=('git') 12 | optdepends=('abs: Provides PKGBUILD prototypes for newpkg') 13 | provides=('pkgtools' 'newpkg') 14 | conflicts=('pkgtools') 15 | backup=('etc/pkgtools/newpkg.conf' 'etc/pkgtools/pkgfile.conf' 'etc/pkgtools/spec2arch.conf') 16 | options=('!strip') 17 | install=pkgtools.install 18 | source=("git+https://github.com/Daenyth/${_pkgname}.git") 19 | sha1sums=('SKIP') 20 | 21 | pkgver() { 22 | cd "${_pkgname%-git}" 23 | echo "$(date +%Y%m%d).$(git rev-list --count master).$(git rev-parse --short master)" 24 | } 25 | 26 | package() { 27 | cd "${_pkgname%-git}" 28 | git submodule update --init 29 | make DESTDIR="${pkgdir}" install 30 | } 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is a collection of scripts for Arch Linux packages. 2 | 3 | This repository contains the following scripts: 4 | - newpkg 5 | - spec2arch 6 | - pkgconflict 7 | - whoneeds 8 | - pkgclean 9 | - maintpkg 10 | - pip2arch 11 | -------------------------------------------------------------------------------- /confs/newpkg.conf: -------------------------------------------------------------------------------- 1 | # newpkg.conf 2 | 3 | # Add in your email here if you want a # Contributor line in the PKGBUILD 4 | #CONTRIB_INFO='Your Name ' 5 | 6 | # Where newpkg will create the package 7 | BASEDIR="${HOME}/builds" 8 | 9 | # vim: set filetype=sh : 10 | -------------------------------------------------------------------------------- /confs/spec2arch.conf: -------------------------------------------------------------------------------- 1 | #==========================================================[ Configuration ]=== 2 | #------------------------------------------------------------------[ Basic ]--- 3 | # This is what will be put in front of the "source" lines content: 4 | #SRC_BASEURL="http://projects.izzysoft.de/ftp/net/div/izzysoft/\$pkgname" 5 | SRC_BASEURL="" 6 | # Shall we include a warning with the generated PKGBUILD? 7 | USE_WARNING=1 8 | # Shall we overwrite the target PKGBUILD file if it exists? 9 | OVERWRITE_TARGET=0 10 | 11 | #----------------------------------------------------[ build() adjustments ]--- 12 | # Replacements to be made in the build() section. The RPM .spec file has some 13 | # pre-defined variables and conditional scripting which we may need to replace. 14 | # Since the replace is done using "sed", all statements need to comply to regexp 15 | # (i.e. escape certain characters). 16 | # For the replace, we set up two arrays which need to correspond to each other: 17 | # BUILD_REPLACE holds the strings to be replaced, BUILD_REPLACED the replacement. 18 | BUILD_REPLACE[0]="%if %{REDHAT}" 19 | BUILD_REPLACED[0]="if \[ 0 -eq 1 \]; then" 20 | BUILD_REPLACE[1]="RPM_BUILD_ROOT" 21 | BUILD_REPLACED[1]="pkgdir" 22 | 23 | # Lines to remove 24 | BUILD_REMOVE[0]="\[ \"\$RPM_BUILD_ROOT\" != \"\/\" \] && rm -rf \$RPM_BUILD_ROOT" 25 | 26 | # Shall the above changes be applied to the build() block? 27 | DO_BUILD_REPLACE=1 28 | 29 | # Shall we invoke the editor after creating the PKGBUILD files to apply 30 | # manual changes? 31 | EDIT_PKGBUILD=1 32 | 33 | # Which editor shall be used? 34 | EDITOR=${EDITOR} 35 | 36 | # Shall namcap.py be used (if found) to verify the PKGBUILD files? 37 | USE_NAMCAP=1 38 | -------------------------------------------------------------------------------- /doc/spec2arch.1: -------------------------------------------------------------------------------- 1 | .TH spec2arch 1 "14 July 2008" 2 | .IX spec2arch 3 | .SH NAME 4 | RPM SpecFile to Arch Linux PKGBUILD converter 5 | 6 | .SH SYNOPSIS 7 | .B spec2arch 8 | .RB "\fIRPMSpecFile\fR" 9 | .RB "\fIPKGBUILDFile\fR" 10 | .RB [ options ] 11 | 12 | .SH DESCRIPTION 13 | spec2arch does a raw "convert" from a given .spec file to an Arch Linux 14 | PKGBUILD file. The resulting file will rarely be that perfect to use it 15 | straight ahead, and will at least need to be reviewed if not even corrected - 16 | but it will make it much easier to get started with it. For these corrections, 17 | you can specify to call the editor after the auto-create has been finished 18 | (default) - and additionally, namcap.py will be called to verify after that, 19 | if it's found in the $PATH. 20 | 21 | spec2arch will most probably fail with too complex .spec files. But for "easy 22 | packages", you may successfully use it in conjunction with \fBpkgmake\fR, and 23 | may even be as lucky again as to only maintain the one .spec file, but create 24 | packages for even one more distribution. 25 | 26 | .SH OPTIONS 27 | .IP "\fBRPMSpecFile\fR" 28 | This is the input file to read, which obviously has to be a RPM .spec file. The 29 | templates used for pkgmake will not work for obvious reasons: They contain 30 | placeholders instead of the real values... 31 | 32 | .IP "\fBPKGBUILDFile\fR" 33 | The output file to generate. It will most likely be named PKGBUILD, but this 34 | way you can provide the directory and name where to store it. 35 | 36 | .IP "\fB-b\fR" 37 | Don't apply corrections to the build() block. Overwrites the 38 | \fIDO_BUILD_REPLACE\fR configuration parameter. 39 | 40 | .IP "\fB+b\fR" 41 | Apply corrections to the build() block. Overwrites the \fIDO_BUILD_REPLACE\fR 42 | configuration parameter. 43 | 44 | .IP "\fB-e\fR" 45 | Do not invoke the editor with the PKGBUILD file once it is created 46 | (overwrites EDIT_PKGBUILD setting) 47 | 48 | .IP "\fB+e\fR" 49 | Invoke the editor with the PKGBUILD file once it is created 50 | (overwrites EDIT_PKGBUILD setting) 51 | 52 | .IP "\fB-n\fR" 53 | Don't check the generated PKGBUILD file with namcap.py - even if the config 54 | says USE_NAMCAP=1 and namcap.py is found in the $PATH 55 | 56 | .IP "\fB+n\fR" 57 | Check the generated PKGBUILD file with namcap.py - even if the config says 58 | USE_NAMCAP=0. Does only have effect if namcap.py can be found in the $PATH 59 | 60 | .IP "\fB-o\fR" 61 | Don't overwrite target if exists (overwrites config setting 62 | \fIOVERWRITE_TARGET\fR) 63 | 64 | .IP "\fB+o\fR" 65 | Overwrite target if exists (overwrites config setting 66 | \fIOVERWRITE_TARGET\fR) 67 | 68 | .IP "\fB-w\fR" 69 | Do not put the warning in the PKGBUILD file (overwrites config setting 70 | \fIUSE_WARNING\fR) 71 | 72 | .IP "\fB+w\fR" 73 | Put the warning in the PKGBUILD file (overwrites config setting 74 | \fIUSE_WARNING\fR) 75 | 76 | .IP "\fB--baseurl \fR" 77 | Set SRC_BASEURL to (overwrites config setting 78 | \fISRC_BASEURL\fR) 79 | 80 | .IP "\fB--editor \fR" 81 | Define the editor to use to edit the created PKGBUILD file for manual control 82 | (overwrites the EDITOR config setting) 83 | 84 | .IP "\fB--md5of \fR" 85 | Calculate md5sums of the given file(s). If you need to specify multiple files, 86 | you must separate them by colons (e.g. "file1.ext:file2.ext"). 87 | 88 | .SH "EXAMPLES" 89 | # Simple call - use settings from the config only 90 | .br 91 | spec2arch sample.spec /usr/local/src/sample/PKGBUILD 92 | 93 | # Same as above, but overwrite existing output and skip build() 94 | .br 95 | spec2arch sample.spec /usr/local/src/sample/PKGBUILD +o -b 96 | 97 | # Same as first, but put no warning and use vi to edit PKGBUILD file 98 | .br 99 | spec2arch sample.spec /usr/local/src/sample/PKGBUILD -w --editor vi 100 | 101 | .SH "CONFIGURATION" 102 | Not that much to configure - for now it's just one line at the top of the 103 | script itself, where you may configure the URL path for the source tarball. 104 | 105 | .SH "FILES" 106 | /usr/bin/spec2arch 107 | 108 | .SH "SEE ALSO" 109 | .PP 110 | spec2arch.conf(5) 111 | 112 | .SH "AUTHOR" 113 | .PP 114 | This manual page was written by Andreas Itzchak Rehberg (devel@izzysoft.de), 115 | the author of the program. Credit should be given also to Daenyth who added a lot concerning the Arch Linux specials - so if you 117 | are using Arch Linux, you may also want to have a look at his pkgtools: 118 | 119 | https://aur.archlinux.org/packages/pkgtools/ 120 | https://aur.archlinux.org/packages/pkgtools-git/ 121 | 122 | which may already ship with a copy of this script. 123 | 124 | Permission is granted to copy, distribute and/or modify this document under the 125 | terms of the GNU General Public License, Version 2. 126 | 127 | More information may be found on the authors website, http://www.izzysoft.de/ 128 | -------------------------------------------------------------------------------- /doc/spec2arch.conf.5: -------------------------------------------------------------------------------- 1 | .TH "SPEC2ARCH.CONF" "5" "01 July 2008" 2 | .SH "NAME" 3 | spec2arch.conf.conf \- Configuration file for \fBspec2arch\fR, which creates 4 | ArchLinux PKGBUILD files from RPM spec files 5 | .SH "DESCRIPTION" 6 | .PP 7 | This manual page documents the options that can be set in the spec2arch.conf 8 | configuration file. For a description of what spec2arch does, see the 9 | spec2arch(8) manpage. 10 | 11 | .SH "SETTINGS" 12 | .PP 13 | The syntax of options is OPTION=value - Bash syntax, since it will be sourced 14 | by the pkgmake executable, which is written in Bash script. 15 | 16 | .PP 17 | The following settings are available in spec2arch.conf: 18 | 19 | .IP "\fBSRC_BASEURL\fP" 10 20 | Here you can define a base URL where the source is available for download. 21 | The string from this setting will be put in front of the source file name 22 | defined in the RPM .spec file. 23 | 24 | .IP "\fBUSE_WARNING\fP" 10 25 | Since the automatic creation of the PKGBUILD file may result in invalid 26 | settings and thus need a review, spec2arch can add a warning hint to that 27 | fact. You should only ommit it if you are really sure the created PKGBUILD 28 | file will be 100% correct. Valid settings are: 0 (no warning) or 1 (default 29 | - place a warning). 30 | 31 | .IP "\fBOVERWRITE_TARGET\fP" 10 32 | What shall be done if the target PKGBUILD file specified on the command line 33 | does already exist - shall it be overwritten without a warning (1), or shall 34 | spec2arch better exit with a warning (0 - default)? 35 | 36 | .IP "\fBBUILD_REPLACE\fR / \fBBUILD_REPLACED\fR" 37 | Replacements to be made in the build() section. The RPM .spec file has some 38 | pre-defined variables and conditional scripting which we may need to replace. 39 | Since the replace is done using "sed", all statements need to comply to regexp 40 | (i.e. escape certain characters). 41 | 42 | For the replace, we set up two arrays which need to correspond to each other: 43 | BUILD_REPLACE holds the strings to be replaced, BUILD_REPLACED the replacement. 44 | There are no defaults. 45 | 46 | .IP "\fBBUILD_REMOVE\fR" 47 | Similiar to above explained \fIBUILD_REPLACE\fR, this is an array of regular 48 | expressions describing lines to be completely removed (or, better said: 49 | ignored) from the RPM .spec file - i.e. they will not be considered for the 50 | PKGBUILD file at all. 51 | 52 | .IP "\fBDO_BUILD_REPLACE\fR" 53 | Whether we should apply the changes defined by \fIBUILD_REPLACE\fR, 54 | \fIBUILD_REPLACED\fR and \fIBUILD_REMOVE\fR (1) or not (0 - default). 55 | 56 | .IP "\fBEDIT_PKGBUILD\fR" 57 | Shall we invoke the editor after creating the PKGBUILD files to apply manual 58 | changes (1, default) or not (0)? Unless you are sure the resulting file will 59 | be fine (or adjustments should be done later), you should manually 60 | post-process the created PKGBUILD file to make sure it is OK. 61 | 62 | .IP "\fBEDITOR\fR" 63 | Which editor shall be used (to edit the PKGBUILD file if EDIT_PKGBUILD=1)? By 64 | default, spec2arch will use the editor defined by the system variable $EDITOR. 65 | 66 | .IP "\fBUSE_NAMCAP\fR" 67 | If namcap.py is found in the $PATH, shall it be used to verify the generated 68 | PKGBUILD file (1 - default) or not (0)? It is recommended to use this tool 69 | to detect possible problems. 70 | 71 | .SH "SEE ALSO" 72 | .PP 73 | spec2arch(8) 74 | 75 | .SH "AUTHOR" 76 | .PP 77 | This manual page was written by Andreas Itzchak Rehberg (devel@izzysoft.de), 78 | the author of the program. Permission is granted to copy, distribute and/or 79 | modify this document under the terms of the GNU General Public License, 80 | Version 2. 81 | 82 | More information may be found on the authors website, http://www.izzysoft.de/ 83 | 84 | -------------------------------------------------------------------------------- /other/functions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | die () { 4 | local ret=$1; 5 | local warning="$2"; shift 2 6 | warn "${warning:-Unknown error}" "$@" 7 | quit ${ret:-1} 8 | } 9 | 10 | warn () { 11 | local message="$1"; shift 12 | printf "$message" "$@" 1>&2 13 | } 14 | 15 | quit () { 16 | exit ${1:-0} 17 | } 18 | 19 | msg () { 20 | local message="$1" 21 | shift 22 | printf "$message" $@ 23 | } 24 | 25 | vmsg () { 26 | [ $VERBOSE -ge 1 ] && msg "$@" 27 | } 28 | 29 | in_array() { 30 | [ $# -lt 2 ] && return 1 31 | needle=$1 32 | shift 33 | for item 34 | do 35 | [ "$item" = "$needle" ] && return 0 36 | done 37 | return 1 38 | } 39 | 40 | load_config() { 41 | local conffile="$1" 42 | 43 | if [[ -r $CONFIG_DIR/$conffile ]]; then 44 | source "$CONFIG_DIR/$conffile" 45 | fi 46 | if [[ -r ${XDG_CONFIG_HOME}/pkgtools/$conffile ]]; then 47 | source "${XDG_CONFIG_HOME}/pkgtools/$conffile" 48 | elif [[ -r ${HOME}/.pkgtools/$conffile ]]; then 49 | source "${HOME}/.pkgtools/$conffile" 50 | warn 'Your %s is located in ~/.pkgtools. Pkgtools now uses $XDG_CONFIG_HOME.\n' "$conffile" 51 | warn 'Make sure $XDG_CONFIG_DIR is set, then mv ~/.pkgtools into it\n' 52 | warn ' mv ~/.pkgtools "$XDG_CONFIG_HOME/pkgtools"\n\n' 53 | fi 54 | } 55 | 56 | # vim: set ts=4 sw=4 et: 57 | -------------------------------------------------------------------------------- /other/functions.newpkg: -------------------------------------------------------------------------------- 1 | # add_action {{{ 2 | add_action() { 3 | ACTIONS=(${ACTIONS[@]} $1) 4 | } 5 | # }}} 6 | 7 | # add_copy {{{ 8 | add_copy() { 9 | local from="$1" 10 | local to="$2" 11 | if [[ ! -r $from ]]; then 12 | warn "Can't read %s, cancelling copy!\n" "$from" 13 | fi 14 | COPIES[$to]="$from" 15 | } 16 | # }}} 17 | 18 | # add_mod() {{{ 19 | add_mod() { 20 | local mod="$1" 21 | MODIFICATIONS=("${MODIFICATIONS[@]}" "$1") 22 | } 23 | # }}} 24 | 25 | # setpkgbuild() {{{ 26 | setpkgbuild () { 27 | if [ -z "$1" ]; then 28 | die 1 "setpkgbuild() requires an argument!" 29 | fi 30 | case "$1" in 31 | /*) 32 | PROTO_PKGBUILD="$1" 33 | ;; 34 | *) 35 | PROTO_PKGBUILD="${PROTODIR}/$1" 36 | ;; 37 | esac 38 | } 39 | # }}} 40 | 41 | # setpkginstall() {{{ 42 | setpkginstall () { 43 | if [ -z "$1" ]; then 44 | die 1 "setpkginstall() requires an argument!" 45 | fi 46 | case "$1" in 47 | /*) 48 | PROTO_INSTALL="$1" 49 | ;; 50 | *) 51 | PROTO_INSTALL="${PROTODIR}/$1" 52 | ;; 53 | esac 54 | } 55 | # }}} 56 | 57 | # setrcd() {{{ 58 | setrcd() { 59 | if [ -z "$1" ]; then 60 | die 1 "setrcd() requires an argument!" 61 | fi 62 | case "$1" in 63 | /*) 64 | PROTO_RC="$1" 65 | ;; 66 | *) 67 | PROTO_RC="${PROTODIR}/$1" 68 | ;; 69 | esac 70 | } 71 | # }}} 72 | 73 | # set_url {{{ 74 | set_url() { 75 | local url=$1 76 | sed -i "s#url=.*#url=\"$1\"#" PKGBUILD 77 | } 78 | # }}} 79 | 80 | -------------------------------------------------------------------------------- /other/newpkg_presets/auto_pkgname.action: -------------------------------------------------------------------------------- 1 | # If the pkgname has a -vcs suffix, set the PKGBUILD proto to the right one automatically 2 | 3 | case "$pkgname" in 4 | *-git) 5 | setpkgbuild 'PKGBUILD-git.proto' 6 | ;; 7 | *-svn) 8 | setpkgbuild 'PKGBUILD-svn.proto' 9 | ;; 10 | *-cvs) 11 | setpkgbuild 'PKGBUILD-cvs.proto' 12 | ;; 13 | *-darcs) 14 | setpkgbuild 'PKGBUILD-darcs.proto' 15 | ;; 16 | *-hg) 17 | setpkgbuild 'PKGBUILD-hg.proto' 18 | ;; 19 | esac 20 | -------------------------------------------------------------------------------- /other/newpkg_presets/default.preset: -------------------------------------------------------------------------------- 1 | # Default newpkg preset. Equivalent to running "newpkg fooname" in v4.0 2 | 3 | [[ -z $PROTO_PKGBUILD ]] && setpkgbuild 'PKGBUILD.proto' 4 | add_action auto_pkgname 5 | add_action pkgbuild 6 | -------------------------------------------------------------------------------- /other/newpkg_presets/install.action: -------------------------------------------------------------------------------- 1 | [[ -z $PROTO_INSTALL ]] && setpkginstall 'proto.install' 2 | add_copy "$PROTO_INSTALL" "$pkgname.install" 3 | add_mod _set_install 4 | 5 | _set_install() { 6 | sed -i "s#^install=.*#install='${pkgname}.install'#" PKGBUILD 7 | } 8 | -------------------------------------------------------------------------------- /other/newpkg_presets/pkgbuild.action: -------------------------------------------------------------------------------- 1 | add_copy "$PROTO_PKGBUILD" PKGBUILD 2 | add_mod _strip_proto_comments 3 | add_mod _set_contributor 4 | add_mod _set_pkgname 5 | 6 | _strip_proto_comments() { 7 | sed -i '/^# This is an example PKGBUILD/d' PKGBUILD 8 | sed -i '/^# and remove these comments/d' PKGBUILD 9 | sed -i '/^# NOTE: Please fill out/d' PKGBUILD 10 | sed -i '/^# then please put/d' PKGBUILD 11 | sed -i '/^# This is an example of a/d' PKGBUILD 12 | sed -i '/^# start to creating your/d' PKGBUILD 13 | sed -i "/^# see 'man PKGBUILD'. NOTE/d" PKGBUILD 14 | sed -i '/^# If it is unknown, then/d' PKGBUILD 15 | sed -i '1{/^$/d;}' PKGBUILD # Delete line 1, if it's empty 16 | } 17 | 18 | _set_contributor() { 19 | [ -n "$CONTRIB_INFO" ] && sed -i "s/^# Contributor: .*/# Contributor: $CONTRIB_INFO/" PKGBUILD 20 | } 21 | 22 | _set_pkgname() { 23 | sed -i "s#^pkgname=.*#pkgname=$pkgname#" PKGBUILD 24 | } 25 | -------------------------------------------------------------------------------- /other/newpkg_presets/rcd.action: -------------------------------------------------------------------------------- 1 | setrcd 'rc-script.proto' 2 | 3 | if [[ ! -r $PROTO_RC ]]; then 4 | msg "Unable to read rc.d proto file at %s\n" "$PROTO_RC" 5 | msg "You may need to install the abs package\n" 6 | fi 7 | 8 | add_copy "$PROTO_RC" "$pkgname.rc.d" 9 | add_mod _set_rcd 10 | 11 | _set_rcd() { 12 | sed -i "s#daemon_name=.*#daemon_name=$pkgname#" "${pkgname}.rc.d" 13 | sed -i "s#^source=(\(.*\))#source=(\1 ${pkgname}.rc.d)#" PKGBUILD 14 | } 15 | -------------------------------------------------------------------------------- /other/newpkg_presets/sf.action: -------------------------------------------------------------------------------- 1 | add_mod _sourceforge_url 2 | 3 | _sourceforge_url() { 4 | sed -i 's#$pkgname-$pkgver.tar.gz#http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz#' PKGBUILD 5 | set_url "http://$pkgname.sourceforge.net" 6 | } 7 | -------------------------------------------------------------------------------- /pkgtools.install: -------------------------------------------------------------------------------- 1 | is_update_from() { 2 | res="$(vercmp $1 $2)" 3 | case "$res" in 4 | '-1'|'0') return 0;; 5 | '1') return 1;; 6 | esac 7 | } 8 | 9 | ## arg 1: the new package version 10 | ## arg 2: the old package version 11 | post_upgrade() { 12 | if is_update_from $2 15-1; then 13 | echo " - pkgtools now uses \$XDG_CONFIG_HOME for all user-specific configuration." 14 | echo " run «mv ~/.pkgtools \"\$XDG_CONFIG_HOME/pkgtools\"»" 15 | fi 16 | if is_update_from $2 18-1; then 17 | echo " - newpkg has been rewritten to be completely modular. See here for more info: https://github.com/Daenyth/pkgtools/commit/2d37197" 18 | fi 19 | if is_update_from $2 19-1; then 20 | echo " - This version of pkgtools contains a new tool called 'maintpkg'" 21 | echo " It sets the Maintainer in a PKGBUILD to your PACKAGER while preserving old Contributors" 22 | fi 23 | if is_update_from $2 22-1; then 24 | echo " - This is the largest release in a long time. This updates all Python scripts to Python 3." 25 | fi 26 | if is_update_from $2 24-1; then 27 | echo " - This update removes the gem2arch and pkgfile scripts. This update also updates pkgconflict to work with pkgfile from [extra] and other minor fixes." 28 | echo " - You may want to remove /var/cache/pkgtools/lists, which is no longer used." 29 | fi 30 | } 31 | 32 | ## arg 1: the old package version 33 | post_remove() { 34 | cat << _EOM 35 | - You may want to clean /var/cache/pkgtools/lists 36 | _EOM 37 | } 38 | 39 | # vim:set ts=2 sw=2 et filetype=sh: 40 | -------------------------------------------------------------------------------- /scripts/.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__/ 2 | -------------------------------------------------------------------------------- /scripts/maintpkg: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### 3 | # maintpkg - set a PKGBUILD's Maintainer line to yours 4 | # This program is a part of pkgtools 5 | 6 | # Copyright (C) 2010-2011 Daenyth 7 | # 8 | # Pkgtools is free software; you can redistribute it and/or 9 | # modify it under the terms of the GNU General Public License 10 | # as published by the Free Software Foundation; either version 2 11 | # of the License, or (at your option) any later version. 12 | # 13 | # Pkgtools is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | ## 22 | 23 | PKGTOOLS_DIR='/usr/share/pkgtools/' 24 | CONFIG_DIR='/etc/pkgtools/' 25 | 26 | if [ -r "$PKGTOOLS_DIR/functions" ]; then 27 | source "$PKGTOOLS_DIR/functions" 28 | else 29 | printf "Unable to source function file!\n" >&2 30 | exit 1 31 | fi 32 | VERBOSE=0 33 | readonly MYVERSION=1.0 34 | 35 | # usage() {{{ 36 | usage () { 37 | # |--------------------------------------------------------------------------------| 80 Characters 38 | msg "%s version %s -- Set maintainer information in a PKGBUILD\n" "$PROGNAME" "$MYVERSION" 39 | msg "Usage: %s [OPTIONS]\n" "$PROGNAME" 40 | msg " -h --help - Print this help.\n" 41 | msg " -v --verbose - Enable verbose output.\n" 42 | # |--------------------------------------------------------------------------------| 80 Characters 43 | quit "${1:-0}" 44 | } 45 | # }}} 46 | 47 | get_maint_line() { 48 | line=$(grep -m1 -nF '# Maintainer:' PKGBUILD | cut -d: -f1) 49 | if [[ -z "$line" ]]; then 50 | line=$(grep -m1 -nF '# Contributor:' PKGBUILD | cut -d: -f1) 51 | if [[ -z "$line" ]]; then 52 | line=1 53 | fi 54 | fi 55 | echo "$line" 56 | } 57 | 58 | while [[ $# > 0 ]]; do 59 | case "$1" in 60 | -h|--help) 61 | usage 62 | ;; 63 | -v|--verbose) 64 | VERBOSE=1 65 | ;; 66 | esac 67 | shift 68 | done 69 | 70 | if [[ ! -r PKGBUILD ]]; then 71 | die 1 "Can't read PKGBUILD file!\n" 72 | fi 73 | 74 | vmsg "Getting packager setting... " 75 | PACKAGER=$(. /etc/makepkg.conf; echo "$PACKAGER") 76 | vmsg "$PACKAGER\n" 77 | 78 | if grep -q "^# Maintainer: $PACKAGER" PKGBUILD; then 79 | msg "PKGBUILD maintainer already set.\n" 80 | quit 0 81 | fi 82 | 83 | new_maint_line=$(get_maint_line) 84 | 85 | vmsg "Changing old maintainers to contributors\n" 86 | sed -i 's/Maintainer:/Contributor:/' PKGBUILD 87 | 88 | vmsg "Inserting new maintainer line\n" 89 | sed -i "${new_maint_line}i\\ 90 | # Maintainer: $PACKAGER" PKGBUILD 91 | msg "Maintainer set!\n" 92 | 93 | # vim: set ts=4 sw=4 fdm=marker et : 94 | -------------------------------------------------------------------------------- /scripts/newpkg: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ### 4 | # newpkg -- A script to speed up creating Arch Linux PKGBUILDS 5 | # This program is a part of pkgtools 6 | 7 | # Copyright (C) 2008-2011 Daenyth 8 | # 9 | # Pkgtools is free software; you can redistribute it and/or 10 | # modify it under the terms of the GNU General Public License 11 | # as published by the Free Software Foundation; either version 2 12 | # of the License, or (at your option) any later version. 13 | # 14 | # Pkgtools is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | ## 23 | 24 | CONTRIB_INFO= 25 | BASEDIR="${HOME}/builds" 26 | CONFIG_DIR='/etc/pkgtools/' 27 | PKGTOOLS_DIR='/usr/share/pkgtools' 28 | PRESET_DIR="$PKGTOOLS_DIR/newpkg/presets" 29 | VERBOSE=0 30 | 31 | if [[ -r "$PKGTOOLS_DIR/functions" ]]; then 32 | . "$PKGTOOLS_DIR/functions" 33 | else 34 | printf "Unable to source function file!\n" >&2 35 | exit 1 36 | fi 37 | if [[ -r "$PKGTOOLS_DIR/functions.newpkg" ]]; then 38 | . "$PKGTOOLS_DIR/functions.newpkg" 39 | else 40 | printf "Unable to source newpkg function file!\n" >&2 41 | exit 1 42 | fi 43 | 44 | ### 45 | # Lines below this point should not need to be edited. 46 | ## 47 | MYVERSION=5.0 48 | PROGNAME="$(basename $0)" 49 | 50 | PROTODIR='/usr/share/pacman' 51 | 52 | declare -a ACTIONS 53 | declare -a MODIFICATIONS 54 | declare -A COPIES 55 | PRESET=default 56 | DOABS=0 # Copy from ABS instead of normal operation TODO 57 | ABSROOT='/var/abs' 58 | EDIT=0 59 | 60 | load_config 'newpkg.conf' 61 | 62 | # {{{ usage() 63 | function usage { 64 | msg "%s version %s -- A script to speed up creating new PKGBUILDs\n" "$PROGNAME" "$MYVERSION" 65 | msg "Usage: %s [options] PKGNAME\n" "$PROGNAME" 66 | msg "Options:\n" 67 | msg " -a --action - Add a modular action to the creation.\n" 68 | msg " Call multiple times for multiple actions\n" 69 | msg " -e --edit - Call \$EDITOR on the PKGBUILD at the end\n" 70 | msg " -h --help - Print this usage\n" 71 | msg " -i --install-file - Copy the prototype .install file\n" 72 | msg " --rc - Copy the protype for an rc.d script\n" 73 | msg " -p --pkgbuild - Specify the PKGBUILD file. If not absolute, the\n" 74 | msg " filename is relative to %s.\n" "$PROGNAME" 75 | msg " -P --preset - Use the specified modular preset\n" 76 | msg " --sf --sourceforge - Set url and source to common Sourceforge urls\n" 77 | msg " --split - Create a split PKGBUILD\n" 78 | msg " -v --verbose - Print more verbose messages\n" 79 | exit 0 80 | } 81 | # }}} 82 | 83 | # make_pkgdir() {{{ 84 | make_pkgdir () { 85 | mkdir -p "$pkgdir" || die 1 "Unable to create directory %s" "$pkgdir" 86 | vmsg "Creating package dir for %s\n" "$pkgname" 87 | 88 | cd "$pkgdir" || die 1 "Can't cd to %s!\n" "$pkgdir" 89 | } 90 | # }}} 91 | 92 | # copy_files() {{{ 93 | copy_files() { 94 | vmsg "Copying files to pkgdir\n" 95 | for file in "${!COPIES[@]}"; do 96 | cp "${COPIES[$file]}" "$file" 97 | done 98 | } 99 | # }}} 100 | 101 | # modify_files() {{{ 102 | modify_files() { 103 | vmsg "Running modifications\n" 104 | for mod in "${MODIFICATIONS[@]}"; do 105 | [[ $(type -t $mod) == 'function' ]] || continue 106 | "$mod" 107 | done 108 | } 109 | # }}} 110 | 111 | 112 | if [[ -z "$1" ]]; then 113 | usage 114 | fi 115 | 116 | while (( $# != 0 )); do 117 | case "$1" in 118 | -a|--action) 119 | if [[ -z "$2" ]]; then 120 | die 1 "%s %s option requires a parameter!\n" "$PROGNAME" "$1" 121 | fi 122 | add_action "$2" 123 | shift 124 | ;; 125 | -e|--edit) 126 | EDIT=1 127 | ;; 128 | -h|--help) 129 | usage 130 | ;; 131 | -i|--install-file) 132 | add_action install 133 | ;; 134 | --rc) 135 | add_action rcd 136 | ;; 137 | -p|--pkgbuild) 138 | if [[ -z "$2" ]]; then 139 | die 1 "%s %s option requires a parameter!\n" "$PROGNAME" "$1" 140 | fi 141 | setpkgbuild "$2"; shift 142 | ;; 143 | -P|--preset) 144 | if [[ -z "$2" ]]; then 145 | die 1 "%s %s option requires a parameter!\n" "$PROGNAME" "$1" 146 | fi 147 | PRESET="$2"; shift 148 | ;; 149 | --sf|--sourceforge) 150 | add_action sf 151 | ;; 152 | --split) 153 | setpkgbuild "PKGBUILD-split.proto" 154 | ;; 155 | -v|--verbose) 156 | VERBOSE=1 157 | ;; 158 | -*) 159 | die 1 "Unrecognized option %s\n" "$1" 160 | ;; 161 | *) 162 | pkgname=$(echo $1 | sed 's; ;;g' | sed 's;/$;;') 163 | ;; 164 | esac 165 | shift 166 | done 167 | 168 | [[ -z "$pkgname" ]] && die 1 "No package name supplied\n" 169 | pkgdir="${BASEDIR}/${pkgname}" 170 | 171 | if [[ -r "$PRESET_DIR/${PRESET}.preset" ]]; then 172 | . "$PRESET_DIR/${PRESET}.preset" 173 | else 174 | die 1 "Can't read preset '%s' in '%s'\n" "$PRESET" "$PRESET_DIR" 175 | fi 176 | 177 | for act in "${ACTIONS[@]}"; do 178 | if [[ -r "$PRESET_DIR/${act}.action" ]]; then 179 | . "$PRESET_DIR/${act}.action" 180 | else 181 | die 1 "Can't read action '%s' in '%s'\n" "$act" "$PRESET_DIR" 182 | fi 183 | done 184 | 185 | make_pkgdir 186 | copy_files 187 | modify_files 188 | (( EDIT )) && "${EDITOR:-${VISUAL:-vi}}" PKGBUILD 189 | 190 | msg "All done! New package prepared in %s\n" "$pkgdir" 191 | quit 0 192 | # vim: set ts=4 sw=4 fdm=marker et: 193 | -------------------------------------------------------------------------------- /scripts/pkgclean: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### 3 | # pkgclean - Tidy up a PKGBUILD directory 4 | # This program is a part of pkgtools 5 | 6 | # Copyright (C) 2010-2011 Daenyth 7 | # 8 | # Pkgtools is free software; you can redistribute it and/or 9 | # modify it under the terms of the GNU General Public License 10 | # as published by the Free Software Foundation; either version 2 11 | # of the License, or (at your option) any later version. 12 | # 13 | # Pkgtools is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | ## 22 | 23 | PKGTOOLS_DIR='/usr/share/pkgtools/' 24 | CONFIG_DIR='/etc/pkgtools/' 25 | readonly MYVERSION=1.1 26 | readonly PROGNAME=$(basename $0) 27 | 28 | if [ -r "$PKGTOOLS_DIR/functions" ]; then 29 | source "$PKGTOOLS_DIR/functions" 30 | else 31 | printf "Unable to source function file!\n" >&2 32 | exit 1 33 | fi 34 | VERBOSE=0 35 | LIST=1 36 | 37 | clean_makedirs () { 38 | vmsg "Cleaning leftover makepkg directories... " 39 | for dir in pkg src; do 40 | if [[ -d "$dir" ]]; then 41 | if (( LIST )); then 42 | echo "$dir/" 43 | else 44 | rm -rf "$dir" 45 | fi 46 | fi 47 | done 48 | vmsg "Done.\n" 49 | } 50 | 51 | clean_srcpkgs () { 52 | . /etc/makepkg.conf 53 | vmsg "Cleaning source packages... " 54 | SRCPKGS=(*"$SRCEXT") 55 | if [[ ! -f "${SRCPKGS[0]}" ]]; then 56 | vmsg "Empty.\n" 57 | return 0 58 | fi 59 | if (( LIST )); then 60 | printf '%s\n' "${SRCPKGS[@]}" 61 | return 0 62 | fi 63 | if [[ -n "$SRCDEST" ]]; then 64 | vmsg "Moving to \$SRCDEST... " 65 | mv -f "${SRCPKGS[@]}" "$SRCDEST" 66 | elif [[ "$PURGE" ]]; then 67 | vmsg "Purging... " 68 | rm -f "${SRCPKGS[@]}" 69 | else 70 | vmsg "Aborted.\n" 71 | return 1 72 | fi 73 | vmsg "Done.\n" 74 | } 75 | 76 | clean_pkgs () { 77 | . /etc/makepkg.conf 78 | vmsg "Cleaning built packages... " 79 | PKGS=(*"$PKGEXT") 80 | if [[ ! -f "${PKGS[0]}" ]]; then 81 | vmsg "Empty.\n" 82 | return 0 83 | fi 84 | if (( LIST )); then 85 | printf '%s\n' "${PKGS[@]}" 86 | return 0 87 | fi 88 | if [[ -n "$PKGDEST" ]]; then 89 | vmsg "Moving to \$PKGDEST... " 90 | mv -f "${PKGS[@]}" "$PKGDEST" 91 | elif [[ "$PURGE" ]]; then 92 | vmsg "Purging... " 93 | rm -f "${PKGS[@]}" 94 | else 95 | vmsg "Aborted.\n" 96 | return 1 97 | fi 98 | vmsg "Done.\n" 99 | } 100 | 101 | clean_downloads () { 102 | . PKGBUILD 103 | vmsg "Cleaning downloaded source files... " 104 | for file in "${source[@]}" "$install"; do 105 | if echo "$file" | grep -q '://'; then 106 | file=$(get_filename "$file") 107 | if [[ -f "$file" ]]; then 108 | if (( LIST )); then 109 | echo "$file" 110 | else 111 | rm -f "$file" 112 | fi 113 | fi 114 | fi 115 | done 116 | vmsg "Done.\n" 117 | } 118 | 119 | clean_cruft () { 120 | [[ "$PURGE" ]] || return 1 121 | vmsg "Purging all non-required files... " 122 | 123 | . PKGBUILD 124 | declare -A noremove 125 | for file in "${source[@]}" "$install" "$changelog" PKGBUILD; do 126 | [[ -z "$file" ]] && continue 127 | file=$(get_filename "$file") 128 | noremove["$file"]=1 129 | done 130 | 131 | for file in *; do 132 | if [[ "${noremove["$file"]}" != 1 ]]; then 133 | if (( LIST )); then 134 | echo "$file" 135 | else 136 | rm -f "$file" 137 | fi 138 | fi 139 | done 140 | vmsg "Done.\n" 141 | } 142 | 143 | clean_all () { 144 | clean_makedirs 145 | clean_pkgs 146 | clean_srcpkgs 147 | clean_downloads 148 | clean_cruft 149 | } 150 | 151 | # Copied from makepkg 152 | # extract the filename from a source entry 153 | get_filename() { 154 | # if a filename is specified, use it 155 | local filename="${1%%::*}" 156 | # if it is just an URL, we only keep the last component 157 | echo "${filename##*/}" 158 | } 159 | 160 | usage () { 161 | 162 | # |--------------------------------------------------------------------------------| 80 Characters 163 | msg "%s version %s -- Clean files from a PKGBUILD directory\n" "$PROGNAME" "$MYVERSION" 164 | msg "Usage: %s [OPTIONS]\n" "$PROGNAME" 165 | msg " -c --clean - Clean the directory of unneeded files.\n" 166 | msg " The default is to list files to be cleaned.\n" 167 | msg " -h --help - Print this help.\n" 168 | msg " --purge - Delete *ALL* non-required files.\n" 169 | msg " -v --verbose - Enable verbose output.\n" 170 | msg "\nWARNING: This tool can be very destructive. Use at your own risk!\n" 171 | # |--------------------------------------------------------------------------------| 80 Characters 172 | quit "${1:-0}" 173 | } 174 | 175 | 176 | while [[ $# > 0 ]]; do 177 | case "$1" in 178 | -c|--clean) LIST=0 ;; 179 | -h|--help) usage ;; 180 | --purge) PURGE=1 ;; 181 | -v|--verbose) 182 | VERBOSE=1 183 | ;; 184 | esac 185 | shift 186 | done 187 | 188 | [[ -f PKGBUILD ]] || die 1 "Not a PKGBUILD dir!\n" 189 | 190 | clean_all 191 | 192 | # vim: set ts=4 sw=4 et : 193 | -------------------------------------------------------------------------------- /scripts/pkgconflict.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | ### 4 | # pkgconflict.py -- check a binary .pkg.tar.gz file for conflicts with 5 | # existing packages. 6 | # This program is a part of pkgtools 7 | 8 | # Copyright (C) 2009-2010 Chris Brannon 9 | # 10 | # Pkgtools is free software; you can redistribute it and/or 11 | # modify it under the terms of the GNU General Public License 12 | # as published by the Free Software Foundation; either version 2 13 | # of the License, or (at your option) any later version. 14 | # 15 | # Pkgtools is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this program; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 23 | ## 24 | 25 | import os 26 | import sys 27 | import tarfile 28 | import gzip 29 | 30 | def chomp(x): return x[0:-1] 31 | def isfilename(x): return not x.endswith('/') 32 | 33 | def read_file_lists(list_base): 34 | """Snarf filelists into memory; return hash mapping filenames to 35 | (repo, package) tuples.""" 36 | known_files = {} 37 | repos = (p for p in os.listdir(list_base)) 38 | for repo in repos: 39 | repopath = os.path.join(FILELIST_DIR, repo) 40 | magic = '070707' # cpio magic (old binary format) 41 | header = 6+6+6+6+6+6+6+6+11+6+11 # portable ASCII header 42 | end = 'TRAILER!!!' # end of cpio archive 43 | try: 44 | fp = open(repopath, 'r') 45 | lines = fp.readlines() 46 | except UnicodeDecodeError: # if it's a gzip file 47 | fp = gzip.open(repopath, 'rt') 48 | lines = fp.readlines() 49 | for l in range(0, len(lines)-1): 50 | file = lines[l][:-1] 51 | if file[0:1] != '/': # if it's a package 52 | package = file[header:-6-2] 53 | while True: # find files 54 | l += 1 55 | file = lines[l][:-1] 56 | if file[:6] == magic or file[-10:] == end: # go to next package 57 | break 58 | else: 59 | if file[-1:] != '/': 60 | known_files[file[1:]] = (repo[:-6], package[:package.find('-')]) 61 | return known_files 62 | 63 | def list_package_contents(package): 64 | """Return a list containing the names of the files in the tarball. 65 | Removes the entries .INSTALL and .PKGINFO.""" 66 | tarball = tarfile.open(package, 'r:xz') 67 | names = tarball.getnames() 68 | tarball.close() 69 | try: 70 | del names[names.index('.PKGINFO')] 71 | del names[names.index('.INSTALL')] 72 | del names[names.index('.MTREE')] 73 | except ValueError: 74 | pass 75 | return names 76 | 77 | HOME = os.environ['HOME'] 78 | CONFIG_DIR = '/etc/pkgtools' 79 | FILELIST_DIR = '/var/cache/pkgfile' 80 | try: 81 | with open(sys.argv[1]) as f: 82 | pass 83 | except (IndexError, FileNotFoundError): 84 | sys.stderr.write('Usage: %s \n' % (sys.argv[0], )) 85 | sys.exit(1) 86 | known_files = read_file_lists(FILELIST_DIR) 87 | pkg_contents = list_package_contents(sys.argv[1]) 88 | for file in pkg_contents: 89 | if file in known_files: 90 | (repo, package) = known_files[file] 91 | print("%s already provided by the %s package from [%s]" % (file, package, repo)) 92 | -------------------------------------------------------------------------------- /scripts/spec2arch: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | # RPM SpecFile to ArchLinux PKGBUILD converter (c) 2008 by IzzySoft 4 | #------------------------------------------------------------------------------ 5 | # This script does a raw "convert" from a given .spec file to an ArchLinux 6 | # PKGBUILD file. The resulting file still should be reviewed! 7 | #------------------------------------------------------------------------------ 8 | # Syntax: 9 | # spec2arch 10 | ############################################################################### 11 | 12 | #==========================================================[ Configuration ]=== 13 | # Since this script is used in different packages (pkgmake, pkgtools), we need 14 | # to point it to the right directory 15 | CONFNAME="pkgtools" 16 | # These are the internal defaults. Don't change them here - use the 17 | # /etc/${CONFNAME}/spec2arch.conf or $XDG_CONFIG_HOME/.${CONFNAME}/spec2arch.conf instead! 18 | SRC_BASEURL="" 19 | USE_WARNING=1 20 | OVERWRITE_TARGET=0 21 | DO_BUILD_REPLACE=0 22 | EDIT_PKGBUILD=1 23 | USE_NAMCAP=1 24 | 25 | #=========================================================[ Initialization ]=== 26 | #-----------------------------------------------------------[ Syntax Check ]--- 27 | function syntax() { 28 | if [ -n "$1" ]; then 29 | EL="$1" 30 | else 31 | EL=0 32 | fi 33 | echo 34 | echo "Syntax:" 35 | echo " spec2arch [options]" 36 | echo 37 | echo "where is the RPM .spec file to process, and the" 38 | echo "resulting PKGBUILD file. Available options:" 39 | echo 40 | echo "-b don't run the BUILD_REPLACE" 41 | echo "+b force running the BUILD_REPLACE" 42 | echo "-e do not call the editor on the created PKGBUILD file" 43 | echo "+e call the editor on the PKGBUILD file when it's created" 44 | echo "-n don't check with namcap.py" 45 | echo "+n check with namcap.py" 46 | echo "-o don't overwrite target if exists" 47 | echo "+o overwrite target if exists" 48 | echo "-w do not put the warning in the PKGBUILD file" 49 | echo "+w put the warning in the PKGBUILD file" 50 | echo "--baseurl set SRC_BASEURL to " 51 | echo "--editor use to manually edit the PKGBUILD file" 52 | echo "--md5of create md5sum of specified (colon-separated) file(s)" 53 | echo 54 | exit "$EL" 55 | } 56 | 57 | #------------------------------------------------------------[ Read Config ]--- 58 | [ -r "/etc/${CONFNAME}/spec2arch.conf" ] && . "/etc/${CONFNAME}/spec2arch.conf" 59 | if [ -r "$XDG_CONFIG_HOME/${CONFNAME}/spec2arch.conf" ]; then 60 | source "$XDG_CONFIG_HOME/${CONFNAME}/spec2arch.conf" 61 | elif [ -r "${HOME}/.${CONFNAME}/spec2arch.conf" ]; then 62 | source "${HOME}/.${CONFNAME}/spec2arch.conf" 63 | printf 'Your spec2arch.conf is located in ~/.${CONFNAME}. ${CONFNAME} now uses $XDG_CONFIG_HOME.\n' >&2 64 | printf 'Make sure $XDG_CONFIG_DIR is set, then mv ~/.pkgtools into it\n' >&2 65 | printf " mv ~/.${CONFNAME} \"$XDG_CONFIG_HOME/pkgtools\"\n\n" >&2 66 | fi 67 | 68 | #-----------------------------------------------------[ parse command line ]--- 69 | case "$1" in 70 | -h|--help) syntax;; 71 | esac 72 | [ -z "$2" ] && syntax 5 73 | SPECFILE="$1" 74 | OUTFILE="$2" 75 | 76 | while [ "$1" != "" ] ; do 77 | case "$1" in 78 | -b) DO_BUILD_REPLACE=0;; 79 | +b) DO_BUILD_REPLACE=1;; 80 | -e) EDIT_PKGBUILD=0;; 81 | +e) EDIT_PKGBUILD=1;; 82 | -n) USE_NAMCAP=0;; 83 | +n) USE_NAMCAP=1;; 84 | -o) OVERWRITE_TARGET=0;; 85 | +o) OVERWRITE_TARGET=1;; 86 | -w) USE_WARNING=0;; 87 | +w) USE_WARNING=1;; 88 | --baseurl) shift; SRC_BASEURL="$1";; 89 | --editor) shift; EDITOR="$1";; 90 | --md5of) shift; MD5OF="$1";; 91 | esac 92 | shift 93 | done 94 | 95 | [ ! -e "$SPECFILE" ] && { 96 | echo 97 | echo "Sorry, but the specified .spec file '$SPECFILE' does not exist." 98 | echo 99 | exit 2 100 | } 101 | [ -e "$OUTFILE" -a "$OVERWRITE_TARGET" -eq 0 ] && { 102 | echo 103 | echo "WARNING: The specified target PKGBUILD file '$OUTFILE' already exists!" 104 | echo 105 | exit 17 106 | } 107 | 108 | #===================================================[ Pre-Check .spec file ]=== 109 | #--------------------------------------------[ Package unsupported for us? ]--- 110 | #excludeos 111 | EXCLOS=$(cat "$SPECFILE"|tr [:upper:] [:lower:]|sed -n '/^excludeos.*linux/p') 112 | [ -n "$EXCLOS" ] && { 113 | echo "Sorry - but this package seems not to be supported for Arch Linux:" 114 | echo "'$EXCLOS'" 115 | exit 22 116 | } 117 | #exclusiveos 118 | EXCLUS=$(cat "$SPECFILE"|tr [:upper:] [:lower:]|sed -n '/^exclusiveos/p') 119 | [ -n "$EXCLUS" ] && { 120 | EXCLUSLX=$(cat "$SPECFILE"|tr [:upper:] [:lower:]|sed -n '/^exclusiveos.*linux/p') 121 | [ -z "$EXCLUSLX" ] && { 122 | echo "Sorry - but this package seems not to be supported for Arch Linux:" 123 | echo "'$EXCLUS'" 124 | echo "'$EXCLUSLX'" 125 | exit 22 126 | } 127 | } 128 | #excludearch 129 | #exclusivearch 130 | 131 | #===========================================================[ Helper Funcs ]=== 132 | #---------------------------------------------------------[ Read Y/N input ]--- 133 | function readyn() { 134 | read -n 1 rd 135 | echo 136 | rd=$(echo "$rd"|tr [:upper:] [:lower:]) 137 | if [ "$rd" = "y" -o "$rd" = "j" ]; then 138 | rd=1 139 | elif [ "$rd" = "n" ]; then 140 | rd=0 141 | else 142 | echo -n "Please enter 'y' for 'yes', 'n' for 'no' - or press Ctrl-C to abort: " 143 | readyn 144 | fi 145 | } 146 | 147 | #-------------------------------[ Remove leading and trailing white spaces ]--- 148 | function trim() { 149 | echo "$1"|sed 's/^\s*//;s/\s*$//' 150 | } 151 | 152 | #------------------------------------------------[ Output PKGBUILD content ]--- 153 | function output() { 154 | if [ -n "$PACKAGER" ]; then 155 | echo "# Contributor: $PACKAGER" 156 | elif [ -n "$VENDOR" ]; then 157 | echo "# Contributor: $VENDOR" 158 | else 159 | echo "# Contributor: unknown" 160 | fi 161 | [ -n "$VENDOR" ] && echo "# Maintainer: $VENDOR" 162 | [ "$USE_WARNING" -ne 0 ] && echo "# This PKGBUILD file was autogenerated and should be verified before use!" 163 | echo "pkgname=$PKGNAME" 164 | echo "pkgver=$PKGVER" 165 | echo "pkgrel=$PKGREL" 166 | echo "pkgdesc=\"$PKGDESC\"" 167 | echo "arch=$ARCH" 168 | [ -n "$URL" ] && echo "url=\"$URL\"" 169 | [ -n "$LICENSE" ] && echo "license=('$LICENSE')" 170 | echo "groups=('$GROUP')" 171 | [ -n "$DEPENDS" ] && { 172 | DEPENDS=$(echo "$DEPENDS"|sed 's/,/ /g') 173 | echo "depends=($(trim "$DEPENDS"))" 174 | } 175 | [ -n "$PROVIDES" ] && { 176 | PROVIDES=$(echo "$PROVIDES"|sed 's/,/ /g') 177 | echo "provides=($(trim "$PROVIDES"))" 178 | } 179 | [ -n "$CONFLICTS" ] && { 180 | CONFLICTS=$(echo "$CONFLICTS"|sed 's/,/ /g') 181 | echo "conflicts=($(trim "$CONFLICTS"))" 182 | } 183 | [ -n "$REPLACES" ] && { 184 | REPLACES=$(echo "$REPLACES"|sed 's/,/ /g') 185 | echo "replaces=($(trim "$REPLACES"))" 186 | } 187 | [ -n "$BACKUP" ] && echo "backup=($(trim "$BACKUP"))" 188 | [ -n "$SRC_BASEURL" -a "${SRC_BASEURL:${#SRC_BASEURL}-1}" != "/" ] && SRC_BASEURL="${SRC_BASEURL}/" 189 | echo "source=($SRC_BASEURL\$pkgname-\$pkgver.tar.gz)" 190 | if [ -n "$MD5OF" ]; then 191 | MD5OF=$(echo "$MD5OF"|sed 's/:/ /g') 192 | MDSUM="" 193 | for FILEN in "$MD5OF"; do 194 | [ -f "$FILEN" ] && MDSUM="$MDSUM '$(md5sum "$FILEN"|awk '{print $1}')'" 195 | done 196 | echo "md5sums=(${MDSUM:1})" 197 | else 198 | echo "md5sums=()" 199 | fi 200 | [ -n "$BUILD" ] && { 201 | echo 202 | echo "build() {" 203 | echo -e " cd \$startdir/src/\$pkgname-\$pkgver${BUILD}" 204 | echo "}" 205 | } 206 | echo "# vim: set ts=2 sw=2 et:" 207 | } 208 | 209 | #----------------------------------------------------[ Setup BuildReplaces ]--- 210 | function buildPrep() { 211 | local i 212 | typeset -i i=0 213 | BUILD_REP_SED="" 214 | BUILD_REM_SED="" 215 | while [ -n "${BUILD_REPLACE[$i]}" ]; do 216 | BUILD_REP_SED="${BUILD_REP_SED};s/${BUILD_REPLACE[$i]}/${BUILD_REPLACED[$i]}/g" 217 | i+=1 218 | done 219 | i=0 220 | while [ -n "${BUILD_REMOVE[$i]}" ]; do 221 | BUILD_REM_SED="${BUILD_REM_SED};/${BUILD_REMOVE[$i]}/d" 222 | i+=1 223 | done 224 | [ -n "$BUILD_REP_SED" ] && BUILD_REP_SED="${BUILD_REP_SED:1}" 225 | [ -n "$BUILD_REM_SED" ] && BUILD_REM_SED="${BUILD_REM_SED:1}" 226 | } 227 | function buildReplace() { 228 | echo "$1"|sed "$BUILD_REM_SED"|sed "$BUILD_REP_SED" 229 | } 230 | 231 | #---------------------------------------------------[ Check with namcap.py ]--- 232 | function check_namcap() { 233 | local CHECK_OK=0 234 | [ -n "$(which namcap.py)" ] && { 235 | CHECK=$(namcap.py $OUTFILE 2>/dev/null) 236 | RC="$?" 237 | echo 238 | if [ -n "$CHECK" ]; then 239 | cat<"$OUTFILE" 350 | [ "$EDIT_PKGBUILD" -ne 0 ] && "$EDITOR $OUTFILE" 351 | [ "$USE_NAMCAP" -ne 0 ] && check_namcap 352 | 353 | #------------------------------------------------------------------[ Done. ]--- 354 | -------------------------------------------------------------------------------- /scripts/upgpkg: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # upgpkg: Upgrades package versions in PKGBUILD and starts build. 4 | # Author: Abhishek Dasgupta 5 | # Thanks to cactus, profjim and daenyth for all the sed help! 6 | # Requires: pkgtools. 7 | 8 | # I place this script in the public domain. 9 | 10 | MYVERSION=0.1 11 | PROGNAME="upgpkg" 12 | 13 | if [ -r /usr/share/pkgtools/functions ]; then 14 | source /usr/share/pkgtools/functions 15 | else 16 | printf "$(gettext "$PROGNAME: Unable to source function file!\n")" >&2 17 | exit 1 18 | fi 19 | 20 | die() { 21 | local message="$1" 22 | shift 23 | printf "$message" "$@" 24 | exit 1 25 | } 26 | 27 | if [ -r /etc/pkgtools/newpkg.conf ]; then 28 | source /etc/pkgtools/newpkg.conf 29 | fi 30 | if [ -r "${HOME}/.pkgtools/newpkg.conf" ]; then 31 | source "${HOME}/.pkgtools/newpkg.conf" 32 | fi 33 | 34 | if [ -z "$BASEDIR" ]; then 35 | die "$(gettext "$PROGNAME: unable to locate BASEDIR in configuration.")" 36 | fi 37 | 38 | if [ -z "$1" ]; then 39 | printf "%s %s\n" "$PROGNAME" "$MYVERSION" 40 | printf "$(gettext "usage: $PROGNAME package-name newver\n")" 41 | exit 42 | fi 43 | 44 | if [ ! -d "$BASEDIR/$1" ]; then 45 | die "$(gettext "$PROGNAME: package %s not in %s.\n")" "$1" "$BASEDIR" 46 | fi 47 | if [ -z "$2" ]; then 48 | die "$(gettext "$PROGNAME: no new version specified for %s\n")" "$1" 49 | fi 50 | 51 | # Main code follows 52 | 53 | cd "$BASEDIR/$1" 54 | sed -ri '/md5sums[ ]?\=/{:a; /\)/d; N; ba;}' PKGBUILD || die "$PROGNAME: could not bump pkgver of $1\n" 55 | source PKGBUILD 56 | 57 | if [ $(vercmp "$2" "$pkgver") -gt 0 ]; then 58 | sed -i "s/pkgver=.*$/pkgver=$2/g" PKGBUILD 59 | sed -i "s/pkgrel=.*$/pkgrel=1/g" PKGBUILD 60 | makepkg -g >> PKGBUILD 61 | else 62 | die "$(gettext "$PROGNAME: %s - new version (%s) older or equal to current %s\n")" "$1" "$2" "$pkgver" 63 | fi 64 | makepkg -m 65 | if [ "$?" -gt 0 ]; then 66 | sed -i "s/pkgver=.*$/pkgver=$pkgver/g" PKGBUILD 67 | sed -i "s/pkgrel=.*$/pkgrel=$pkgrel/g" PKGBUILD 68 | die "$(gettext "$PROGNAME: %s - build failed for %s, reverting to %s\n")" "$1" "$2" "$pkgver" 69 | fi 70 | -------------------------------------------------------------------------------- /scripts/whoneeds.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # whoneeds package : shows explicitly installed packages that require some package 3 | 4 | # we use associative arrays to get uniqueness for "free" 5 | typeset -A root_packages 6 | typeset -A walked_nodes 7 | query="$1" 8 | 9 | function walk_nodes () { 10 | local package="$1" 11 | 12 | # if we've walked this node before, skip. This drastically 13 | # reduces overhead for a relatively cheap operation 14 | [[ "${walked_nodes[$package]}" -eq 1 ]] && return 0 15 | walked_nodes["$package"]=1 16 | 17 | # we do this so that we can make a single call to pacman 18 | # to get both bits of information that we require 19 | result=( $(LC_ALL=c pacman -Qi "$package" | awk -F':' \ 20 | 'BEGIN { tag = ""; dependents = ""; explicit = 0 } 21 | { 22 | # since the formatting of the pacman output is more for human 23 | # consumption than programmatic, we find ourselves with the following need. 24 | # if we have two fields, then we know we have a proper identifier on the line 25 | # so we store the identifier as a current tag 26 | # All identifier checks are made against the current tag, which allows us 27 | # to deal with instances where "Required By" spans lines 28 | if (NF == 2) { tag = $1 } 29 | if (tag ~ /^Required By[ ]*$/) { dependents = dependents $(NF) } 30 | if ($1 ~ /^Install Reason $/ && $2 ~/^ Explicitly installed/) { explicit = 1 } 31 | } 32 | END { print explicit,dependents}') ) 33 | 34 | # and if we hit an issue retrieving package information 35 | if [[ ${#result[*]} -lt 2 ]]; then 36 | echo "error: could not get information on $package" 1>&2 37 | exit 3 38 | fi 39 | if [[ ${result[0]} -eq 1 ]]; then 40 | # we found an explicitly installed package that relies on 41 | # the original query. Add it to our array, provided it isn't 42 | # the original query, as that would be useless information 43 | [[ "$query" != "$package" ]] && root_packages["$package"]=1 44 | fi 45 | if [[ "${result[1]}" != "None" ]]; then 46 | # iterate over our 'Required By:' packages 47 | dependents="${result[@]:1:${#result[*]}}" 48 | for i in "$dependents"; do 49 | walk_nodes "$i" 50 | done 51 | fi 52 | } 53 | 54 | if [ $# -ne 1 ]; then 55 | echo "error: unexpected number of arguments" 1>&2 56 | echo "Usage: $(basename $0) " 57 | exit 2 58 | fi 59 | 60 | walk_nodes "$1" 61 | echo "Packages that depend on [$query]" 62 | if [[ -n "${!root_packages[*]}" ]]; then 63 | for pkg in "${!root_packages[@]}"; do 64 | echo " $pkg" 65 | done | sort 66 | exit 0 67 | fi 68 | echo " None" 69 | exit 1 70 | 71 | # vim: set ts=4 sw=4 et: 72 | -------------------------------------------------------------------------------- /specfiles/PKGBUILD.eject: -------------------------------------------------------------------------------- 1 | # Contributor: unknown 2 | # This PKGBUILD file was autogenerated and should be verified before use! 3 | pkgname=eject 4 | pkgver=2.1.5 5 | pkgrel=11%{dist} 6 | pkgdesc="A program that ejects removable media using software control." 7 | arch= 8 | url="http://www.pobox.com/~tranter" 9 | license=('GPL') 10 | groups=('') 11 | depends=('gettext' 'automake' 'autoconf' 'libtool') 12 | backup=('ure') 13 | source=($pkgname-$pkgver.tar.gz) 14 | md5sums=() 15 | 16 | build() { 17 | cd $startdir/src/$pkgname-$pkgver 18 | rm -rf ${buildroot} 19 | make DESTDIR=${buildroot} install 20 | install -m 755 -d ${buildroot}/${_sysconfdir}/pam.d 21 | install -m 644 ${SOURCE1} ${buildroot}/${_sysconfdir}/pam.d/${name} 22 | install -m 755 -d ${buildroot}/${_sysconfdir}/security/console.apps/ 23 | echo "FALLBACK=true" > ${buildroot}/${_sysconfdir}/security/console.apps/${name} 24 | install -m 755 -d ${buildroot}/${_sbindir} 25 | pushd ${buildroot}/${_bindir} 26 | mv eject ../sbin 27 | ln -s consolehelper eject 28 | popd 29 | } 30 | # vim: set ts=2 sw=2 et: 31 | -------------------------------------------------------------------------------- /specfiles/eject.spec: -------------------------------------------------------------------------------- 1 | Summary: A program that ejects removable media using software control. 2 | Name: eject 3 | Version: 2.1.5 4 | Release: 11%{dist} 5 | License: GPL 6 | Group: System Environment/Base 7 | Source: http://metalab.unc.edu/pub/Linux/utils/disk-management/%{name}-%{version}.tar.gz 8 | Source1: eject.pam 9 | Patch1: eject-2.1.1-verbose.patch 10 | Patch2: eject-timeout.patch 11 | Patch3: eject-2.1.5-opendevice.patch 12 | Patch4: eject-2.1.5-spaces.patch 13 | Patch5: eject-2.1.5-lock.patch 14 | Patch6: eject-2.1.5-umount.patch 15 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root 16 | URL: http://www.pobox.com/~tranter 17 | ExcludeArch: s390 s390x 18 | BuildRequires: gettext 19 | BuildRequires: automake 20 | BuildRequires: autoconf 21 | BuildRequires: libtool 22 | 23 | %description 24 | The eject program allows the user to eject removable media (typically 25 | CD-ROMs, floppy disks or Iomega Jaz or Zip disks) using software 26 | control. Eject can also control some multi-disk CD changers and even 27 | some devices' auto-eject features. 28 | 29 | Install eject if you'd like to eject removable media using software 30 | control. 31 | 32 | %prep 33 | %setup -q -n %{name} 34 | %patch1 -p1 -b .versbose 35 | %patch2 -p1 -b .timeout 36 | %patch3 -p0 -b .opendevice 37 | %patch4 -p0 -b .spaces 38 | %patch5 -p0 -b .lock 39 | %patch6 -p1 -b .umount 40 | 41 | %build 42 | %configure 43 | make 44 | 45 | %install 46 | rm -rf %{buildroot} 47 | 48 | make DESTDIR=%{buildroot} install 49 | 50 | # pam stuff 51 | install -m 755 -d %{buildroot}/%{_sysconfdir}/pam.d 52 | install -m 644 %{SOURCE1} %{buildroot}/%{_sysconfdir}/pam.d/%{name} 53 | install -m 755 -d %{buildroot}/%{_sysconfdir}/security/console.apps/ 54 | echo "FALLBACK=true" > %{buildroot}/%{_sysconfdir}/security/console.apps/%{name} 55 | 56 | install -m 755 -d %{buildroot}/%{_sbindir} 57 | pushd %{buildroot}/%{_bindir} 58 | mv eject ../sbin 59 | ln -s consolehelper eject 60 | popd 61 | 62 | %find_lang %{name} 63 | 64 | %clean 65 | rm -rf %{buildroot} 66 | 67 | %files -f %{name}.lang 68 | %defattr(-,root,root) 69 | %doc README TODO COPYING ChangeLog 70 | %attr(644,root,root) %{_sysconfdir}/security/console.apps/* 71 | %attr(644,root,root) %{_sysconfdir}/pam.d/* 72 | %{_bindir}/* 73 | %{_sbindir}/* 74 | %{_mandir}/man1/* 75 | 76 | %changelog 77 | * Wed Apr 02 2008 Zdenek Prikryl 2.1.5-11 78 | - Added check if device is hotpluggable 79 | - Resolves #438610 80 | 81 | --------------------------------------------------------------------------------