 Today, we are going to compile source code, we're going to compile programs from source code. Something I wish I had done more in the past. I do a lot of scripting, I don't necessarily do a lot of compile languages, and I just don't compile a lot of programs, but something I should at least be familiar with. But the way I've done it in the past has been a headache, you know, you gotta find where the source code is. You go to the project's website or their get page, hoping that you're at the real one and not some malicious one. Download the source code, unpackage it, go into the directory, and then you need to figure out is it a make, do I type in make, make config, do I see make, or do I just GCC something, and I don't know, and then you start compiling it, and it's like you need this library. So then I app search for that library, I install it, hoping that I'm installing the right one, then I go to compile again, it's like oh well now you need this library, and it goes on and on and on. You don't need to do all that. The Debian developers have your back, they have the Debian repositories with all their applications and everything that's in the default Debian repositories that's compiled, they also have a source code repository, and not only will it download the source code for you, but you can get it to download all the required dependencies and applications needed to compile it, and in two commands, you can actually download and compile from source code and not just get it compiled, but it will actually package a deb file for you. And that's what we're gonna do today. Super easy. Let's have a quick look. So first thing you need to do is go into your app source list, which in many cases is going to be in etcappsource.list or in the directory etcappsource.list.d. We're gonna open up that, and by default if you're on Debian system, you may have one line that says something like deb, and then the repositories you're connecting to, the version Debian you're using, and then the repositories you want to be able to connect to. Now you may also have a line that looks like this that might be commented out. If so, just uncomment it. If not, you can type it, or again, you can look in the description of this video for all my notes, and there you can copy and paste it, but it's basically the same as up here. I have sit in there because I run sit, which is Debian unstable. Not necessarily recommending that for everybody, but you do deb source, the URL, and then just main or sit main or whatever version of Debian you're using. Once you do that, you save it, you sudo apt update to make sure you update or all your repositories. Once you have done that, you can just use apt dash get source. Now I'm currently in an empty directory. You don't need to sudo for this because it's just gonna pull the source code down to the current directory you're in. So let's pull down nmap, the source code for nmap. I'm gonna do that. It's gonna pull it down. It shouldn't take too long. I listed out here. I got the tar file that it was, and then they also extract it. I can go into this directory and see all the source code. But now again, I have that same issue of how do I compile this? If you're not familiar with it, you may not know. Again, is it make? Seamake? Something else? What libraries do I need? So let's go back out into my upper directory here. I'm going to remove everything in this directory and start all over again. Okay? So I'm in an empty directory. What we're gonna do now is we're gonna sudo apt install a program called apt dash src for source. I already have it installed. Okay? That's not an issue. Now what I'm gonna do is I'm gonna apt dash src and I'm gonna say install nmap. And it's going to pull down the source code similar to before. But now you can see I can do apt dash src and I'm gonna say build and the program and it will compile that source code for me. And again, not only will it compile it for you, it will compile it for you and also make you a deb file. So let's go ahead. This is gonna take a couple of minutes. So I'm gonna pause the video here and when I come back, it should be compiled. Okay, it's been about two or three minutes and it looks like it's making the deb files now. So I'm assuming it's almost done. I have done this before and it usually only takes three or four minutes on my system. And yeah, once it's done, I'll have a binary. There we go. It tells me it was successfully built and it's in this directory. So let me go ahead and change into that nmap directory. And in here, let's see if I do dot slash nmap. There we go. We have nmap compiled. Perfect. Okay. And also, like I said, if we move back out of here, we can see that it also created some deb files for us. Now let's do a different program. Let's do one that I haven't done before to show you an example of how it pulls down dependencies. Since I had already done this with nmap, it didn't pull down any dependencies. But let me do apt dash source install fcf. Now I didn't do sudo here, but when I run it, it's probably gonna ask me to, oh, well, I probably already run sudo. Now you can see it's pulling down, it's saying unmet dependencies and then it's pulling them down. At this point, it will ask you for a password because it's pulling down dependencies and applications you need to compile it. Now I have not compiled fcf before. So we'll see how this goes. It should run fine. As you can see, if I wasn't using this, I'd have to download, I'd have to know to download all these packages. I don't even know how you know that other than trying to compile it and telling you you need this. So again, we'll run that same command, but instead of install, we will say build and I will let go. I don't know how long this one's gonna take because I haven't done this before, but it's 5.50 right now. I'll pause the video. We'll see what time it is when I get back. And it is still 5.50. It took about 30 seconds for that one to compile. So it says it's in this directory. Let's go ahead and go into that directory and we'll list it down. I say dot slash. And you can see it's not in this main directory and that's something that happens sometimes with Netcat, it put it, or Nmap, it put it right in the main directory. Netcat also does as well. If you build something and it's not in the main directory, of course you've got the DEB files. Again, if I go back up a directory, you can see the DEB files for FCF in here, so you can use those to install. But if you want to test the binary, let's go into FCF. And usually I will go into the Debian directory within that. And then from there, I'll go into the folder for the name of the program. And in here, we'll have usr and the list here been at this point, it's kind of like where it would be on a regular system. And so if I list this out, you can see right there, FCF and FCF dash Tmux is compiled and there we go, it's running. It listed out the two files and was able to filter through it. So if it's not in the main directory, what you can do is, again, you go into the folder for the application, you go into the DEB folder, the folder of the name of the application, and then under there, it's basically the structure that would be installed on your system. So in most cases, it's going to be usr-bin or if it's a game, for example, it's actually going to be under, I think, usr-share-games. Well, let's find out. Oh, one too many dots there. I could have just hit like four and it would have brought me back here. OK, so let's go ahead and we'll say apt-src install prboom-plus, which Debian actually just recently changed. It's not using, oh, what just happened? Oh, that's because I thought I was building it. So I just downloaded it and it's actually not prboom-plus. They actually just switch, I don't know when, but I just noticed this recently, is it switched to a fork of prboom-plus called dsda, but it still recognizes as prboom-plus in the repository. So we will build that and this one will probably take a couple of minutes. So let's see, it's 5.52 right now. I'll pause the video and we'll be right back. OK, it's out. There we go. Yeah, about a minute, less time than I thought. So again, let's go ahead and go into the dsdoom folder and you can see there's no binary right in this main directory, but it made a deb file. And again, that's what this Debian directory is in here. We can go in here and then it's prboom-plus and then in here, it's going to be a USR share docs. Hmm, that doesn't seem right to me. Oh, that's right, because it's not prboom-plus. I am going to assume it's in this directory. Maybe, yep, Debian, USR games. And in here, dsda. So depending on where it's going to be installed on the system, it will be in a subdirectory like that. Go ahead and run that. I already have doom-wads installed, so it should see that. And there we go. I have doom up and running. And let's go ahead and do I need to do any more? Let's actually go back. At this point, let's try modifying some of the source code just to make sure it's compiling from that source, right? I mean, we know it is. But let's go ahead and try anyway. Let's go ahead and go into nmap and then go ahead and run nmap. You see when you run nmap without any commands, you can see this help file and you can see it says see the man page. So what I'm going to say is I'm going to say grep. Just to find what file that is in the source code, I'm going to say grep for this. And we're going to say in .cc file. There we go. So we have our main nmap.cc file here. We're going to go into that. I'll say see. And we'll say see the man. We'll change that to say see the, oops. Cool man, right? We will back back out and I will app dash source, build nmap. And again, it took three or four minutes. So it's 5.56 right now. I'm going to pause this video and check out our compiled application when we get back. OK, it looks like it's building the dev package, which shall only take a moment. Do-ba-do-ba-do. OK. So now, if we go into our nmap directory and I do nmap, it shows our changes. Perfect. Now, I've known about Debbie and having the source code on the repositories. And I've used the first version I showed you, where I used apt-get-source. But the apt-src application is new to me. And it makes things so much easier that I might start compiling a lot more myself now. I hope this inspires you, too, because as you can see, it's super simple. You don't really need to think about anything. You know you're getting it from the Debian repositories. You know that it's designed for a Debian system. You know all the dependencies are not only in the repositories for your system, but you can pull them down with the one simple command and compile it. And I hope this inspires you to compile more applications. Now, I will say, when I just recompiled nmap, it took a super long time. And I know in the past when I've compiled applications, for example, PR boom, when you go to me, make changes and you compile it again, it doesn't necessarily compile everything again, unless you do a clean command. This doesn't seem to do that. It took just as long. I forgot to look at the time there, but, you know, three, four minutes, it seems to recompile everything. Now, again, this command is new to me. If anyone knows anything different to me, do a speed that up, that's awesome. But yeah, we're gonna look a little bit more at compiling things from source soon. So keep on watching. As always, visit films by chris.com. That's Chris and the K. And as always, I hope that you have a great day.